문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top