我需要在OpenGL中围绕太阳旋转地球。我目前已经能够围绕太阳旋转,但我需要在一个椭圆轨道上旋转它。现在已经生成了椭圆,但我无法弄清楚如何沿着该椭圆旋转。
“绘制”函数如下:
“绘制”函数如下:
//orbit
glColor3f(1,1,1);
drawEllipse(3.2f,1.0f); //draws ellipse
//sun
glTranslatef(0,0,0);//suns position
glColor3d(1,1,0);
glutSolidSphere(2,50,50);
//EARTH
glRotatef(angle,0.0f,1.0f,0.0f);
glTranslatef(6.0f,0.0f,0.0f);//postion earths
glPushMatrix();
glRotatef(angle2, 0.0f,1.0f,0.0f);
glColor3d(0.5,0.8,1);
glutSolidSphere(1,50,50);
glPopMatrix();