Question

I'm working on a game engine, and I want to be able to draw a billboarded (i.e. rectangular to the screen) quad with the center-bottom of the quad being determined by a single point.

Was it helpful?

Solution

In OpenGL, there is the concept of transformation matrices. These govern the positioning of the objects on the screen. From them, it is possible to read vectors (directions) that point "up" and "right". These are commonly called up-vector and right-vector (and the third may be called look-vector). How to get them is described here.

Once you have them, making a billboarded quad is very simple.

P - right * .5 + up
+-------------+ P + right * .5 + up
|             |
|             |
|             |
|      P      |
+------+------+ P + right * .5
P - right * .5

These are the coordinates (P is the governing position, at the bottom center of your BB). You can draw such quad the same way as any other quad.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top