计算机图形学八大行星程序,计算机图形学模拟太阳系源代码.doc

#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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值