PDA

View Full Version : how to project a 3D point in 2D Camera

andriuha
03-28-2003, 10:15 AM
I have a Camera, with this camera i can move and look around in my 3D world
I made my Camera with gluLookAt, so my Camera have: position(pos.x, pos.y, pos.z)
View(view.x, view.y, view.z).
Camera(pos.x, pos.y, pos.z, viewx.x, view.y, view.x, 0, 1, 0)
and remember that with my camera I can move in an look around.
Now the problem: I want to project a point(x,y,z) from my 3D World to my 2D Camera Screen?

JONSKI
03-28-2003, 12:24 PM
You first multiply your world coordinate to your transformation matrix. This gives you a transformed coordinate. You then multiply your newly transformed coordinate with the projection matrix. This leaves you with your projected (screen space) coordinate.

... Or you can just use gluProject().

andriuha
03-29-2003, 04:00 AM
Ok, I think that gluProject is better.
Can you tell more detalied haw to use this function?
I have Camera Position
Camera View
Planet Position

gluProject(what here) ?????
and where is my X,Y screen coordonats of may 3d point, in this gluProject?

JONSKI
03-29-2003, 06:37 AM
gluProject() usage:
http://www.cevis.uni-bremen.de/~uwe/opengl/gluProject.html

Some other stuff you might need:
http://www.cevis.uni-bremen.de/~uwe/opengl/opengl.html

andriuha
03-30-2003, 02:49 AM
ok, gluProject work, bat have a bag,
my point is drawn twice, in front and backward of my camera.
ex. if this point if in front of my camera, then i turn back my camera there also this point, how to fix it?

john
03-30-2003, 02:13 PM
Check the z-value of the point after it's been transformed. It is behind the camera if it's >0.0.

raverbach
04-01-2003, 03:52 AM
quick and dirty http://www.opengl.org/discussion_boards/ubb/biggrin.gif