Need a Formula Betwin 2D to 3D

Monkey Forums/Monkey Programming/Need a Formula Betwin 2D to 3D

hardcoal(Posted 2012) [#1]
Hi, Lets say I have a 2D scrolling game that uses 3D graphics.
and I want a 2D image to follow the movement of a 3D mesh.

My camera position is -300 and my camera zoom is 40

In this case I need to multiply the Image Coords with the number 104 (more or less).

what I want is a formula where I insert the camera position and the camera zoom and the formula returns the relation number.

anyone knows how to do it?


AdamRedwoods(Posted 2012) [#2]
gluProject()

The idea is to transform the 3D point using the model matrix and the projection matrix, then normalize (so it's between 0 and 1), and convert the x,y into something usable based on your camera viewport size.