0

我正在尝试确定 glRotate 之后的坐标。

假设我们最初在

 View.x = 0;
 View.y = 0;
 View.z = 10.0f;

我们做一个 glRotate

我如何获得新的更新坐标?

 View.x = ?;
 View.y = ?;
 View.z = ?;

这似乎不起作用(我有什么问题?):

    glRotatef(angle, x, y, z);

    GLfloat theMatrix[16];
    glGetFloatv(GL_MODELVIEW_MATRIX, theMatrix);

    viewX  = View.x * theMatrix[0] + View.y * theMatrix[4] + View.z * theMatrix[8];
    viewY = View.x * theMatrix[1] + View.y * theMatrix[5] + View.z * theMatrix[9];
    viewZ = View.x * theMatrix[2] + View.y * theMatrix[6] + View.z * theMatrix[10];
4

1 回答 1

0

glRotate modifies current modelView matrix... but all the transformations are performed inside the OpenGL pipeline, so you cannot easily get the updated results.

the simplest way is to multiply your vertex data by your rotation matrix. You can use glm library, some other library, or create own code for vector/vertex transformation.

if you want to get updated values for all the vertices you want to draw, then you can use some more advanced stuff like transform feedback

于 2012-05-11T09:02:35.253 回答