在 OpenGL 中绘制一个广告牌四边形
我正在开发一个游戏引擎,我希望能够绘制一个广告牌(即屏幕上的矩形)四边形,该四边形的中心底部由一个点确定。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在OpenGL中,有变换矩阵的概念。它们控制屏幕上对象的位置。从它们中,可以读取指向“向上”和“向右”的向量(方向)。这些通常称为上矢量和右矢量(第三个可能称为外观矢量)。 此处描述了如何获取它们。
一旦你拥有了它们,制作一个广告牌四边形就非常简单了。
这些是坐标(P 是控制位置,位于 BB 的底部中心)。您可以像绘制任何其他四边形一样绘制这样的四边形。
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.
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.