这是我的领域,但这不是所有代码
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;
}
答案 0 :(得分:0)
如果您正在渲染X,Y,Z轴,然后沿着X,Y和Z轴使用所需的偏移调用glRotatef,则可以使地球适当倾斜。
听起来你可能需要围绕X轴进行额外的旋转。
从图像看,它看起来需要围绕Z轴旋转90度。
glRotatef(90f,0.0f,0.0f,1.0f);
答案 1 :(得分:0)
旋转可以堆叠,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;
}