我想:在x,y,z中心点旋转我的立方体。第二种方式:我想在立方体的中心点上旋转我的立方体。我怎么能这样做?
答案 0 :(得分:1)
假设您有一个名为gl的OpenGL ES GL10对象,在您的提取或类似中:
// Push matrix so we can pop later
gl.glPushMatrix();
// Translate to the center of your cube
// Or to whatever xyz point you want
glTranslatef(centreX, centreY, 0);
// rotation = degrees to rotate
// x,y,z are unit vectors for rotation to take place
// I.E x=0.0 y=0.0 z=0.0 would rotate around the z-axis
gl.glRotatef(rotation, x, y, z);
// CUBE DRAWING FUNCTION HERE
// Popmatrix so we undo translation and rotation for
// rest of opengl calls
gl.glPopMatrix();
我建议查看the android ports of the nehe opengl tutorials因为他们是使用android启动opengl的精彩指南。