Position a quad with 2d coordinates

Blitz3D Forums/Blitz3D Programming/Position a quad with 2d coordinates

hub(Posted 2003) [#1]
Hi !

My Camera is set to 0,0,0. a quad (in fact a menu title) was displayed at 0,0,1.0001

Now, what's the formulae to position the sprite using 2d coordinates (pixels) ?

Thanks


jhocking(Posted 2003) [#2]
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.


DrakeX(Posted 2003) [#3]
one way to do this would to create a second "sprite" camera that is only responsible for the sprites (quads). this camera would be set to orthographic projection mode and not clear the background. there is a snippet in the code archives that does something similar to this.


BlitzSupport(Posted 2003) [#4]
There are a few ways to position a 3D sprite at 2D co-ordinates in the Code Archives. Here's one...

Handle 3D Sprites as 2D Sprites


hub(Posted 2003) [#5]
Thanks !