Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将一个矩形旋转到位,我的意思是在将数组传递给 GL 进行渲染之前,旋转它在顶点数组中的坐标。
我有一个这样定义的矩形:
vect0 = -1.0, 0.0, 0 vect1 = -1.0, 1.0, 0 vect2 = 1.0, 1.0, 0 vect3 = 1.0, 0, 0 GLfloat verts[] = {vect0,vect1,vect2,vect3};
有什么方法可以旋转这些坐标,使得在渲染矩形时,它会在 x、y 或 z 轴上以任意角度旋转?
谢谢,保罗
您需要使用旋转矩阵。根据您编写的 OpenGL ES 版本,这可能像glRotatef(1.0/1.1) 一样简单,或者您需要使用数学库来创建矩阵并将其发送到着色器。(2.0)
glRotatef
如果您绝对必须在发送顶点之前创建旋转,请使用数学库并将每个顶点乘以旋转矩阵。我不会推荐它,除非你绝对 100% 确定顶点在初始旋转后永远不会旋转。