I want to: rotate my cube on a x,y,z center point. And t开发者_StackOverflow中文版he second way: i want to rotate my cube on my cube's center points. How i can do this?
Assuming you have a OpenGL ES GL10 object called gl, in your ondraw or similar:
// 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();
I suggest looking at the android ports of the nehe opengl tutorials as they are brilliant guides to starting opengl with android.
精彩评论