opengl编程如何使得一个矩形始终正对着观察者?

来源:百度知道 编辑:UC知道 时间:2024/05/17 02:05:03
opengl编程如何使得一个矩形始终正对着观察者?
opengl三维图程序编写时如何实现以某个点为定点绘制一个矩形,不论场景如何沿x轴或者y轴旋转保证该矩形
始终正对着观察着的屏幕?
我已经做到只沿着一个轴旋转的情况,可是两个轴同时转以后就不行了。
矩形坐标如下:
glVertex3f(0.0f,0.0f,1.0f);
glVertex3f(cos(double(yrot/180*PI)),0.0f,1.0f+sin(double(yrot/180*PI)));
glVertex3f(cos(double(yrot/180*PI)),1.0f,1.0f+sin(double(yrot/180*PI)));
glVertex3f(0.0f,1.0f,1.0f);
其中yrot即为沿着y周旋转的角度。

This is called "billboard", you need only simply multiply the vertex with a matrix, the link of tutorial is the following, very simple.

http://nehe.gamedev.net/data/articles/article.asp?article=19

there is chinese version of that artical also, called " opengl hong pi shu"

simply saying: load current matrix and transport, then multiply with your vertex.

da bu liao zhong wen, bu hao yi si