PDA

View Full Version : gluProject()



schailan
09-09-2002, 03:51 AM
hi all,


here is my pb:

i'm using the gluProject method in order to retreive the screen coordinate of an object in my 3D scene.

I move the camera into the scene and for each event about camera moving i retreive the coordinates which are positive values if the object is in front of the camera but when it's not, the coordinates pass to negative value. The pb is when my camera moves away from the object, the negative values pass to positive value and i'd like to avoid the cycle negative to positive.

Do you understand what i mean? I know it's quite difficult to explain my pb but if anybody can help me do it please!!

thx

Tom Nuydens
09-09-2002, 04:35 AM
If your object is behind the camera, that means it's not on the screen. How do you want to calculate screen coordinates for something that isn't on the screen if not by using negative values?

-- Tom

schailan
09-09-2002, 04:38 AM
Originally posted by Tom Nuydens:
If your object is behind the camera, that means it's not on the screen. How do you want to calculate screen coordinates for something that isn't on the screen if not by using negative values?

-- Tom

yeah i need to calculate object behind the camera that means indeed the object is not on the screen that's why i get negative values but if i move away from the object suddenly, coordinates are positive why???

PH
09-09-2002, 04:41 AM
I know what you mean, the objects will appear on screen and move away from the viewer as the object moves further behind the near plane.
Tom's right, this is why OpenGL does clipping. So you should manually clip your triangles to the near plane prior to projection.