[英]OpenGl - gluShpere sits on its side how can i rotate it up right?
这是我的领域,但这还不是全部代码
GLUquadric *earth = gluNewQuadric();
gluSphere( earth, 35.0, 36, 30);
上面的球体具有地球的纹理,但是它的侧面倾斜了,我该如何改变呢?
更多代码
glRotatef(earthRotation,0.0f, 1.0f, 0.0f);
gluSphere( earth, 35.0, 72, 72);
earthRotation+= 0.3f;
if(earthRotation > 360.0f)
{
earthRotation = 0.0f;
}
我现在做到了,这就是答案(下面更新)
glRotatef(earthRotation,0.0f, 1.0f, 0.0f);
gluLookAt(0.00,0.00,1.0,//eye
50.00,0.00,0.00,//centre
0.00,0.00,1.00);//u
gluSphere( earth, 35.0, 72, 72);
earthRotation+= 0.3f;
if(earthRotation > 360.0f)
{
earthRotation = 0.0f;
}
如果要围绕X,Y,Z轴进行渲染,然后沿X,Y和Z轴调用glRotatef,并具有所需的偏移量,则可以适当倾斜地球。
听起来您可能需要绕X轴额外旋转。
从图像看来,它需要围绕Z轴旋转90度。
glRotatef(90f,0.0f,0.0f,1.0f);
旋转可以堆叠,OPENGL将以相反的顺序旋转(因此,您最后指定的旋转首先进行。
以下代码首先在Z轴上旋转球体直到其旋转,然后在调整后的对象上执行地球旋转。
glRotatef(earthRotation,0.0f, 1.0f, 0.0f);
glRotatef( 90.0f,0.0f,0.0f,1.0f);
gluSphere( earth, 35.0, 72, 72);
earthRotation+= 0.3f;
if(earthRotation > 360.0f)
{
earthRotation = 0.0f;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.