# how can I translate 3d coordinate to 2d(x,y) coord

hi
Im looking for an algorithem to calculate x,y,z to x,y coordinate on screen
thank

gluUnproject

well how about omiting the Z value in (x,y,z) ? If you want to look at 3D space from 2D perspective, you will look at X and Y, thus no matter where in Z coordinate the 3D shapes lie, since you will see them from the Side … Other than that I don’t understand what you really want to accomplish …

[This message has been edited by jubei_GL (edited 10-11-2002).]

but wouldnt you need to have an orthographic projection? Otherwise, the x any y coords may not be the correct values that you are looking for.

J

I’m developing a 3D shooting game… is there anyway to translate a 2D(x,y) coordinate (Mouse click) into 3D?

You can’t transform a 2D point to 3D. It’s an equation system with three equations and two unknowns: impossible to find a unique solution. What you CAN find is a line from the viepwoint throught the “mouse cursor”. You can have a look at gluUnProject, but you will see it requires a third component from the mouse cursor to give you a unique point in 3D space.

err…guys, i think what he’s asking is how to calculate where on the screen an (x,y,z) vertex will be shown (which is an x,y)…

try searching for “Denthor of Asphyxia” tutorials, then look for the one with introduction to 3D…you’ll find your equation there…

if i remember correctly when i dealt with DOS graphics, it’s:

x_screen = x_coord / z_coord * 256
y_screen = y_coord / z_coord * 256

with the 256 being a “trial and error” value… .