#include
#include
#include
#include
//行星
GLfloat rot0 = 30.0;
GLfloat rot1 = 0.0;
GLfloat rot2 = 0.0;
GLfloat rot3 = 0.0;
GLfloat rot4 = 0.0;
GLfloat rot5 = 0.0;
GLfloat rot6 = 0.0;
GLfloat rot7 = 0.0;
GLfloat rot8 = 0.0;
//卫星
GLfloat rot9 = 0.0;
GLfloat rot10 = 0.0;
GLfloat rot11 = 0.0;
void init()
{
glClearColor(0.0,0.0,0.0,0.0);
glClearDepth(1.0);
glShadeModel(GL_FLAT);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glLoadIdentity();
//gluLookAt(0, 10, 10, 0,0,0,0, 1,0);
//glRotatef(45.0,0.0,0.0,1.0);
glTranslatef(0.0,0.0,-20.0);
glRotatef(90.0,1.0,0.0,0);
glPushMatrix();
//绘制太阳
glColor3f(1.0,0.0,0.0);
glutSolidSphere(2.0,32,32);
//绘制地球
glPushMatrix();
glColor3f(0.0,0.0,1.0);
// 绘制辅助轨道
glRotatef(90,1.0,0,0.0);
glutSolidTorus(0.02, 5.0, 10, 64);
glRotatef(-90,1.0,0,0.0);
// 设置地球公转速度
glRotatef(rot0,0.0,1.0,0.0);
// 设置地球半径
glTranslatef(5.0,0.0,0.0);
// 设置地球自转速度
//glRotatef(rot1,0.0,1.0,0.0);
// 绘制地球
glutSolidSphere(0.4,32,32);
// 绘制地球的卫星-月亮
glColor3f(0.5,0.6,0.5);
// 抵消地球自转影响
//glRotatef(-rot1,0.0,1.0,0.0);
// 绘制辅助轨道
glRotatef(90,1.0,0,0.0);
glRotatef(-90,1.0,0,0.0);
// 设置月亮公转速度
glRotatef(rot9,0.0,1.0,0.0);
// 设置月亮公转半径
glTranslatef(0.6,0.0,0.0);
// 绘制月亮
glutSolidSphere(0.1,10,8);
glPopMatrix();
// 绘制水星
glPushMatrix();
glColor3f(0.0,1.0,1.0);
// 绘制辅助轨道
glRotatef(90,1.0,0,0.0);
glutSolidTorus(0.02, 2.5, 10, 64);
glRotatef(-90,1.0,0,0.0);
// 设置水星公转速度
glRotatef(rot1,0.0,1.0,0.0);
// 设置水星公转半径
glTranslatef(2.5,0.0,0.0);
// 设置水星自传
glRotatef(rot3,0.0,1.0,0.0);
// 绘制水星
glutSolidSphere(0.2,32,32);
glPopMatrix();
//绘制金星
glPushMatrix();
glColor3f(0.0,1.0,0.0);
//绘制辅助轨道
glRotatef(90,1.0,0,0.0);
glutSolidTorus(0.02, 3.4, 10, 64);
glRotatef(-90,1.0,0,0.0);
// 设置金星公转速度
glRotatef(rot2,0.0,3.0,0.0);
// 设置金星公转半径
glTranslatef(3.4,0.0,0.0);
// 设置金星自传
glRotatef(rot0,0.0,1.0,0.0);
// 绘制金星
glutSolidSphere(0.3,32,32);
glPopM