On Jun 10, 2004, at 11:15 AM, Nick Lockwood wrote:
You have to transform the vector to the camera coordinates, then
compare the z axis as you would if the camera wasn't turned. It's the
same transformation you would do if you wanted to render the vector to
the screen, except you needn't bother with the perspective transform
bit, since the z coordinates are not affected by perspective.
I tried that but it didn't seem to work. I'll try again though.
I'm afraid I can't help you much further than that because vector math
makes my head hurt, but I expect you'll figure it out.
Alternatively you can use gluProject to do the transform using the
OpenGL matrix. Basically you just pass gluProject a some matrices and
some coordinates. The matrices are the same ones you are using to draw
your scene, which you can get by using glGet with the parameters of
GL_MODELVIEW_MATRIX and GL_PROJECTION_MATRIX respectively. The
coordinates are the world coordinates of your vector. What you get
back will be the screen coordinates of your vector, and from the z
value you'll be able to tell if the object is in front or behind.
That's major overkill I think.
Thank you.
Asher Dunn
--------------------------------------------------------
President and Head Developer of Fireye Software
<http://www.fireyesoftware.com/>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|