[英]OpenGL rotate 3D Cube on own Axis
我有一个3D立方体,但我想旋转它,但不使用X,Y,Z轴。
我想在自己的轴上旋转立方体。
例如:我将多维数据集从右向左移动:我的多维数据集应该在顶点的左下轴上旋转大约90度,而不在Z轴上旋转大约90度。
我尝试了这个:
//prespektive...
gluPerspective(45,1.0,2.0,30.0);
//look at...
gluLookAt(0.0,2.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
//try to rotate cube on bottom-right-axis
glTranslatef(-(-0.7), 0.40, -(-0.25));
glRotatef(90, 1,0,0);
glRotatef(90, 0,1,0);
glRotatef(90, 0,0,1);
glTranslatef(-0.7, 0.40, -0.25);
但这是行不通的。 任何想法 ?
你为什么破坏投影矩阵。 旋转多维数据集之前,请转到MODELVIEW
矩阵模式
// Setup the projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,1.0,1.0,30.0); // front clip plane to 1.0
// Now go to modelview
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//look at...
gluLookAt(0.0,2.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
//try to rotate cube on bottom-right-axis
glTranslatef(-(-0.7), 0.40, -(-0.25));
glRotatef(90, 1,0,0);
glRotatef(90, 0,1,0);
glRotatef(90, 0,0,1);
glTranslatef(-0.7, 0.40, -0.25);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.