1

我画了一个像下面这样的实心球体:

glPushMatrix();
    glScalef(0.015, 0.015, 0.015);
    glRotatef(90, 1.0, 0.0, 0.0);
    glTranslatef(0.0, 200, 0.0);
    glRotatef(-20, 0.0, 0.0, 1.0);
    glRotatef(-20, 1.0, 0.0, 0.0);
    glTranslatef(78.75, -110.74, -13.53);
    glutSolidSphere(4.0f,15,15);
glPopMatrix();

我怎样才能得到这个实心球体的变换坐标?

4

2 回答 2

-1

GL_MODELVIEW_MATRIX您可以通过函数获取状态变量glget

ModelView它从堆栈返回当前矩阵。我认为这就是你所需要的。

于 2012-08-28T03:19:37.407 回答
-1

将转换后的坐标放入变量中,然后您就不必检索形状的转换坐标。

float solidSphereX = whatever;
float solidSphereY = whatever;
float solidSphereZ = whatever;
float solidSphereRotationX = whatever in radians;
float solidSphereRotationY = whatever in radians;
float solidSphereRotationZ = whatever in radians;
...
glPushMatrix();
glRotatef(solidSphereRotationX, solidSphereRotationY, solidSphereRotationZ);
glTranslatef(solidSphereX, solidSphereY, solidSphereZ);
glPopMatrix();
于 2012-08-29T19:01:36.907 回答