资源简介

用opengl绘制的3D机器人,实现了光照的利用,并且实现了,机器人的走动,旋转。

资源截图

代码片段和文件信息

#include
#include
#include
#include
#include
int inverse=0;
int larm=0rarm=0;
float l=0;
float k=0;
void init(void)
{
GLfloat mat_diffuse[]={1.01.01.01.0};
GLfloat mat_specular[]={1.01.01.01.0};
GLfloat mat_shininess[]={50.0};
GLfloat light_diffuse[]={0.10.90.11.0};
GLfloat light_position[]={10.010.010.01.0};
GLfloat light_specular[]={0.50.50.51.0};
GLfloat lmodel_ambient[]={0.01.00.01.0};
glClearColor(0.00.00.00.0);
glShadeModel(GL_SMOOTH);
glMaterialfv(GL_FRONTGL_SPECULARmat_specular);
glMaterialfv(GL_FRONTGL_SHININESSmat_shininess);
glLightfv(GL_FRONTGL_DIFFUSEmat_diffuse);
glLightfv(GL_LIGHT0GL_POSITIONlight_position);
glLightfv(GL_LIGHT0GL_DIFFUSElight_diffuse);
glLightfv(GL_LIGHT0GL_SPECULARlight_specular);
glLightModelfv(GL_LIGHT_MODEL_AMBIENTlmodel_ambient);
GLfloat mat_ambient[]={1.01.01.01.0};
GLfloat light_ambient[]={1.01.01.01.0};

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}
void display(void)
{
GLUquadricObj *cylinder_obj1;
GLUquadricObj *cylinder_obj2;
cylinder_obj1=gluNewQuadric();
glClearColor(0.00.00.00.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(0.10.90.1);

glPushMatrix();



glRotatef((GLfloat)inverse0.01.00.0);

glPushMatrix();

glTranslatef(00l);

glPushMatrix();                       //圆柱
glRotatef(90.01.00.00.0);
gluCylinder(cylinder_obj1 2 2 4 20 30);
//gluDisk(cylinder_obj20220.0);
glPopMatrix();

glColor3f(0.10.90.1);
glutSolidSphere(2.02030);

glPushMatrix();
glColor3f(1.01.01.0);
glTranslatef(0.70.91.5);
glutSolidSphere(0.32030);
glPopMatrix();

glPushMatrix();                      //左胳膊
glColor3f(0.10.90.1);

if((int)k%2!=0&&k>1)
glRotatef((GLfloat)-451.00.00.0);
if((int)k%2==0&&k>0)
glRotatef((GLfloat)451.00.00.0);

glRotatef((GLfloat)larm1.00.00.0);
glTranslatef(-2.5-2.50.0);
glScalef(0.52.01.0);
glutSolidCube(2.0);
glPopMatrix();

glPushMatrix();   //眼
glColor3f(1.01.01.0);
glTranslatef(-0.70.91.5);
glutSolidSphere(0.32030);
glPopMatrix();

glPushMatrix();                      //右胳膊
glColor3f(0.10.90.1);

if((int)k%2==0&&k>0)
glRotatef((GLfloat)-451.00.00.0);
if((int)k%2!=0&&k>1)
glRotatef((GLfloat)451.00.00.0);

glRotatef((GLfloat)rarm1.00.00.0);
glTranslatef(2.5-2.50.0);
glScalef(0.52.01.0);
glutSolidCube(2.0);
glPopMatrix();

glPushMatrix();                       //左腿                 
//glColor3f(1.01.00.1);

if((int)k%2==0&&k>0)
glRotatef((GLfloat)-201.00.00.0);
else
glRotatef((GLfloat)01.00.00.0);
glTranslatef(-1.0-5.50.0);
glScalef(0.551.31.0);
glutSolidCube(2.0);
glPopMatrix();


glPushMatrix();                       //右腿
//glColor3f(1.01.00.1);

if((int)k%2!=0&&k>1)
glRotatef((GLfloa

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-12-15 15:12  picture\
     目录           0  2012-11-05 11:27  picture\Debug\
     文件       34816  2012-11-26 19:16  picture\Debug\picture.exe
     文件      467720  2012-11-26 19:16  picture\Debug\picture.ilk
     文件      535552  2012-11-26 19:16  picture\Debug\picture.pdb
     目录           0  2012-12-15 14:48  picture\ipch\
     目录           0  2012-12-15 14:48  picture\ipch\picture-bd8ef054\
     文件    34013184  2012-12-15 14:48  picture\ipch\picture-bd8ef054\picture-a4da9c88.ipch
     目录           0  2012-10-30 20:56  picture\picture\
     文件    25513984  2012-12-15 15:12  picture\picture.sdf
     文件         888  2012-10-30 19:33  picture\picture.sln
     文件       11776  2012-12-15 15:12  picture\picture.suo
     目录           0  2012-11-26 19:16  picture\picture\Debug\
     文件         606  2012-11-26 19:16  picture\picture\Debug\cl.command.1.tlog
     文件       13544  2012-11-26 19:16  picture\picture\Debug\CL.read.1.tlog
     文件         264  2012-11-26 19:16  picture\picture\Debug\CL.write.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link-cvtres.read.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link-cvtres.write.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.1752-cvtres.read.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.1752-cvtres.write.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.1752.read.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.1752.write.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.3996-cvtres.read.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.3996-cvtres.write.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.3996.read.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.3996.write.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.5264-cvtres.read.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.5264-cvtres.write.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.5264.read.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.5264.write.1.tlog
     文件           2  2012-11-26 19:16  picture\picture\Debug\link.6620-cvtres.read.1.tlog
............此处省略33个文件信息

评论

共有 条评论