PDA

View Full Version : Marking points in space



Sektor
02-17-2004, 03:53 AM
I have drawn a grid and i'd like to somehow mark some 3d points. I have tried to draw spheres centered in these points, but a sphere that is closer will be larger than a sphere that is further away from the eye. I would like them all to be the same size when seen from any point.

I have also tried to draw them in 2D by using glRasterPos3f and glDrawPixels, but if I use this approach, how can I center the bitmap (or whatever I draw with glDrawPixels) in a point?

Hope I've made myself clear. Thank you in advance!

chowe6685
02-17-2004, 04:12 AM
glBegin(GL_POINTS);

Sektor
02-17-2004, 04:27 AM
You didn't understand what I want.
How can I use GL_POINTS?
A point is very small. I have to use something that can be seen and has the same size no matter how far the eye point is.

Honk
02-17-2004, 04:40 AM
Sektor, you didn't understood.

Just draw your points using:



glBegin(GL_POINTS);
glVertex...
...
glVertex
glEnd();


And the points will all have the same size.

Sektor
02-17-2004, 04:44 AM
The points will indeed have the same size if I use GL_POINTS, but you see, a single point is not visible! I want something bigger, that can be seen.

Honk
02-17-2004, 04:46 AM
Then have a look at glPointSize()

Sektor
02-17-2004, 04:52 AM
Now you're talking! Thanks a lot.

But now I see the "big" point as a square. Any way to make it a circle?

Honk
02-17-2004, 05:01 AM
You could try:



glEnable(GL_POINT_SMOOTH);

for starters.

Sektor
02-17-2004, 05:03 AM
I already tried that, because I read about it at the glPointSize man page, but it's still a square.

Sektor
02-17-2004, 05:20 AM
Done! Blending was not enabled. Thanks a lot!

Honk
02-17-2004, 05:30 AM
You are welcome.

dvm
02-17-2004, 06:55 AM
Why not just go for a:



glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-windowWidth / 2, windowWidth / 2,
-windowHeight / 2, windowHeight / 2,
-100.0, 100.0);

The last two values, resize at your desire.
This would create a good orthographic volume where everything would be of the same size (as long as it is the same size) regardless of the distance. Also try looking up ways to use gluUnproject. This should help you "pointing" point in 3d space. If you don't want an orthographic projection, try scaling the object according to depth. I mean the further away, the bigger they get so to the eye its the same size. Hope I helped!

Sektor
02-18-2004, 03:12 AM
I used glBegin( GL_POINTS ) and glPointSize to do what I wanted. It's great, but I have another question now: how can I select the points? I mean, when the user clicks on the screen, I want to be able to know if he clicked on a point and if so, on which one?

Any help will be appreciated.
Thanks!

[This message has been edited by Sektor (edited 02-18-2004).]

Sektor
02-18-2004, 11:23 AM
No ideas? Please, I really must have this ready by the end of the week. If you have any suggestions at all, I would be grateful.

I'm gonna rephrase the question:
I have drawn a point (using GL_POINTS), but have used glPointSize to modify its size. Is there a way to know the location of the point in screen coordinates and the side of the square (also in screen coordinates)? (Because if you don't use antialiasing and increase the point size, it will look like a square.)

[This message has been edited by Sektor (edited 02-18-2004).]

brcain
02-18-2004, 12:07 PM
Look at OpenGL selection/picking (e.g. RedBook examples select.c, picksquare.c, and pickdepth.c).

Note, I often use the address of the object I'm picking (e.g. pointer to F16 class instance) as the name that I load. This makes determining what's selected explicit rather than using some sort of mapping.

brcain
02-18-2004, 12:11 PM
Originally posted by Sektor:
Is there a way to know the location of the point in screen coordinates )?

You can try gluProject. However, I would recommend picking mechanism instead.

[This message has been edited by brcain (edited 02-18-2004).]

Sektor
02-19-2004, 08:51 AM
Originally posted by brcain:
Look at OpenGL selection/picking (e.g. RedBook examples select.c, picksquare.c, and pickdepth.c).

Note, I often use the address of the object I'm picking (e.g. pointer to F16 class instance) as the name that I load. This makes determining what's selected explicit rather than using some sort of mapping.

Thanks a lot! I read the chapter in the Red book and it worked just fine!