资源简介

用OpenGL+glut实现简单人物在简单场景中的漫游,所有物体都是用线框表示的,以便于观察,具体介绍和效果图可以到http://blog.sina.com.cn/s/blog_487547aa0100afd4.html看。

资源截图

代码片段和文件信息

// Robot.cpp: implementation of the CRobot class.
//
//////////////////////////////////////////////////////////////////////

#include “Robot.h“

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//int CRobot::shoulder=0;
//int CRobot::leg=0;
CRobot::CRobot()
{
flagS=1;
flagL=1;
shoulder=0;
leg=0;
}

CRobot::~CRobot()
{

}

void CRobot::DrawRobot()
{
glColor3f(0.01.00.0);
glPushMatrix();
glRotatef(90.00.01.00.0);
glPushMatrix();
glScalef(16.0 20.0 10.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.012.00.0);
glScalef(3.04.03.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.018.00.0);
glScalef(8.08.08.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(10.010.00);
glPushMatrix();
glTranslatef(0.0-5.00);
glScalef(4.010.04.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0-10.00.0);
glTranslatef(0.0-5.00.0);
glScalef(4.010.04.0);
glutWireCube(1.0);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef(-10.010.00);
glPushMatrix();
glTranslatef(0.0-5.00);
glScalef(4.010.04.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0-10.00.0);
glTranslatef(0.0-5.00.0);
glScalef(4.010.04.0);
glutWireCube(1.0);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef(5.0-10.00);
glPushMatrix();
glTranslatef(0.0-8.00);
glScalef(6.016.06.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0-16.00.0);
glTranslatef(0.0-8.00.0);
glScalef(6.016.06.0);
glutWireCube(1.0);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef(-5.0-10.00);
glPushMatrix();
glTranslatef(0.0-8.00);
glScalef(6.016.06.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0-16.00.0);
glTranslatef(0.0-8.00.0);
glScalef(6.016.06.0);
glutWireCube(1.0);
glPopMatrix();
glPopMatrix();
glPopMatrix();
}

void CRobot::DrawWalkedRobot()
{
if(flagS==1)
shoulder=shoulder+1;
if(flagS==-1)
shoulder=shoulder-1;
if(shoulder>=30)
flagS=-1;
if(shoulder<=-30)
flagS=1;
if(flagL==1)
leg=leg+1;
if(flagL==-1)
leg=leg-1;
if(leg>=30)
flagL=-1;
if(leg<=-30)
flagL=1;
glColor3f(0.01.00.0);
glPushMatrix();
glRotatef(90.00.01.00.0);
glPushMatrix();
glScalef(16.0 20.0 10.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.012.00.0);
glScalef(3.04.03.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(0.018.00.0);
glScalef(8.08.08.0);
glutWireCube(1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(10.010.00);
glRota

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      66560  2008-05-01 00:01  glutRobotInScene\RobotInScene.ncb

     文件       1367  2008-04-30 23:53  glutRobotInScene\RobotInScene.plg

     文件        673  2008-04-28 16:11  glutRobotInScene\Scene.h

     文件        638  2008-04-28 16:12  glutRobotInScene\Robot.h

     文件        549  2008-04-28 17:11  glutRobotInScene\RobotInScene.dsw

     文件       3837  2008-04-29 21:06  glutRobotInScene\RobotInScene.dsp

     文件        756  2008-04-29 21:55  glutRobotInScene\Text.h

     文件       2295  2008-04-30 11:10  glutRobotInScene\Text.cpp

     文件       4578  2008-04-30 23:47  glutRobotInScene\RobotInScene.cpp

     文件       3683  2008-04-30 23:50  glutRobotInScene\Scene.cpp

     文件       5612  2008-04-30 23:51  glutRobotInScene\Robot.cpp

     文件      58368  2008-05-01 00:01  glutRobotInScene\Debug\vc60.idb

     文件      53248  2008-04-30 23:53  glutRobotInScene\Debug\vc60.pdb

     文件     402432  2008-04-30 23:53  glutRobotInScene\Debug\RobotInScene.pdb

     文件     250876  2008-04-30 23:53  glutRobotInScene\Debug\RobotInScene.ilk

     文件     217167  2008-04-30 23:53  glutRobotInScene\Debug\RobotInScene.exe

     文件       9040  2008-04-30 11:15  glutRobotInScene\Debug\Text.obj

     文件      14246  2008-04-30 23:53  glutRobotInScene\Debug\Robot.obj

     文件      19683  2008-04-30 23:53  glutRobotInScene\Debug\RobotInScene.obj

     文件     334992  2008-04-30 23:53  glutRobotInScene\Debug\RobotInScene.pch

     文件      11024  2008-04-30 23:53  glutRobotInScene\Debug\Scene.obj

     文件      54784  2008-05-01 00:01  glutRobotInScene\RobotInScene.opt

     目录          0  2008-05-01 00:00  glutRobotInScene\Debug

     目录          0  2008-05-01 00:00  glutRobotInScene

----------- ---------  ---------- -----  ----

              1516408                    24


评论

共有 条评论