View Full Version : Draw Black Circle

02-07-2008, 02:12 PM
Hi ... :D

I have a Freeform with texture, and I want draw black circle on that Freeform, How can I do that :?:

I don't wanna create plane and give it texture and put it on that Freeform , I realy want draw on that texture of Freeform .

Please help me

Thank you very much

02-07-2008, 02:41 PM
for each pixel
If dist to pixel from the center (or any x,y) < threshold
Pixel = Black

This will draw a filled circle.

02-07-2008, 04:31 PM
Please could you put an example or Code for doing that

thank you :oops:

02-07-2008, 05:11 PM
for x := 0 to Image.Width do
for y := 0 to Image.Height do
Dist := Sqrt((x * x) + (y * y));
if Dist < 50 then
Image.Pixels[x, y] := clBlack;

This will draw a 1/4 circle in the left-top corner with a radius of 50. I did this from my naked mind, I didn't try the code, but I think you should be able to make something out of it.

02-07-2008, 06:38 PM
thank you NecroDOME

I'll try with this code

05-07-2008, 01:29 PM
sorry NecroDOME :cry:
but I couldn't do anything with that code, please help me with another code

05-07-2008, 01:42 PM
Just asking for another piece of code won't help you. I guess we need to see your code before we can help you.

Did you allready try to draw a line on your texture, or just make a few pixels black. That would be a good start. If that works, you can use NecroDome's code to make that 1/4 circle, which is your next step. ;)

05-07-2008, 03:28 PM
Maybe you should consider to start easy. I gave a simple piece of code most ppl understand. I'm willing to help, but I aint gonna write you a program.

07-07-2008, 12:55 PM
actually I want to make a shooter game , and I want to draw black circle for the sign of the bullet on the wall , I usually create transparent plane with texture and put it on the wall , but when I shoot quickly the game become very slowly specialy when the player move and when I stop shooting the game come back to the normal speed,
so I want to change my way to another one , and I found that drawing black circle is the best way . the code you put it to me was very good but I didn't know how could I use it specialy the code work with X and Y and I need Z too
that is my probelm ,is there any thing can help me or another idea to make the sign of the bullet

07-07-2008, 02:55 PM
Ah.. you want "decals" to appear on the walls when hit by a bullet. Did you allready figure out how to find the corrent position for the circle to appear (I think it's line/plane intersection)?

Another tricky thing is that if you use the same texture for alot of different walls, all the walls will show this black circle.

I'm sorry but i can't help you with this, because i never have done this myself and i never used GLScene.

You should search the forums (or google) with "decals" and you should find some articles on how to make them. I don't want to discourage you, but it might be way more difficult than you think.

Good luck with it. I really hope you can make this work. ;)

07-07-2008, 03:09 PM
It becomes very slow, Is that because you load the file every time you shoot? Do you pre-catch the bullet hole texture?
When it returns to normal speed, do the decals stay? If so, there is noting wrong with the rendering, but with the generation of the plane/texture.

Maybe you can say something what you do when you "pull the trigger". It also could be that the physics are slow.
Just some ideas to think of.

10-07-2008, 09:15 PM
I use a " Timer" for shooting time ( shoot every 30 seconds ) and I use this code to select the place of the bullet on the wall

SetVector(rayStart, GLDummy_Player.AbsolutePosition);
SetVector(rayVector, GLSceneViewer1.Buffer.ScreenToVector (AffineVectorMake(CurseX, GLSceneViewer1.Height-CurseY, 0)));
if GLFreeForm1.RayCastIntersect(rayStart, rayVector, @iPoint, @iNormal) then
// create transparent plane

I think the problem because that code but I didn't find any another one to select the place on the GLFreeform

11-07-2008, 07:25 AM
You can try to see how long each functies does to complete. Be doing this it becomes clear what is slow I think. I don't think It's your circle drawing stuff but the ray intersection stuff.

11-07-2008, 03:13 PM
is there another code better than I used to select the place of the bullet on the GlFreeForm

12-07-2008, 08:55 AM
What does GlFreeForm do?

13-07-2008, 06:35 AM
it's just a map ( main map ) but it has a lot of curves

13-07-2008, 06:36 AM
it's just a map ( main map ) but it has a lot of curves

13-07-2008, 09:49 AM
Collision detection on a large map is often slow. Could that be the problem? You could try to use a physics engine. Most of them have good optimazations for ray intersection on large scale maps.

16-07-2008, 09:29 PM
were can I find physics engine , is there any demo for that

thank you

17-07-2008, 07:07 AM
You could try newton game dynamics. I have used it before and it works well.
You may want to take a look at TreeCollisions.

Anyway, did you benchmark you functions?