There is no single formula because there is no single way to position the sprite. That is, because 2D coordinates are different from 3D coordinates (duh) there are multiple ways of correlating the 2D screen coordinates to 3D coordinates. Specifically, you pretty much always have to decide on a plane of motion in the 3D scene so that you only need two coordinates to define a position on that plane.
One common way which is useful for HUD/interface stuff is relating X and Y coordinates on the screen to X and Y coordinates relative to the camera (with a constant Z coordinate.) Thus the plane of motion is perpendicular to the camera. There is code in the Code Archives to accomplish this.
If however you were trying to do some different correlation (eg. many games, including one I'm working on now, correlate 2D coordinates to points on the constant plane of the ground) you would need different code.
|