View Full Version : how to project a 3D point in 2D Camera
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?
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().
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
gluProject(what here) ?????
and where is my X,Y screen coordonats of may 3d point, in this gluProject?
03-29-2003, 06:37 AM
Some other stuff you might need:
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?
Check the z-value of the point after it's been transformed. It is behind the camera if it's >0.0.
04-01-2003, 03:52 AM
quick and dirty http://www.opengl.org/discussion_boards/ubb/biggrin.gif
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 http://www.opengl.org/discussion_boards/ubb/smile.gif
04-01-2003, 03:55 AM
ohh and ...you need to restore your rendering matrices after the loadindetity and the translation ... then things will work fine
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.