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?
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().
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?
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
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?
Check the z-value of the point after it’s been transformed. It is behind the camera if it’s >0.0.
quick and dirty
glLoadIdentity();
glTranslated(x,y,z);//here you can control a lot of things …one interesting is zoom with the z value
draw your stuff here
and we´re done
ohh and …you need to restore your rendering matrices after the loadindetity and the translation … then things will work fine