资源简介
基于opengl的3D机器人,带有光照阴暗效果,机器人可以行走,手、头脚、肩膀都可以自由旋转。

代码片段和文件信息
#include
#include
#include
#include
#include
#include
using namespace std;
int all_rotate=0;
int head_rotate=0;
int shoulder_y=0;
int shoulder_x=0;
int larm_r=0;
int rarm_r=0;
int llw=0;
int rlw=0;
int robot_move=0;
int turn_back=0;
float l=0;
float k=0;
float a=0.2b=0.9c=0.3d=0.3; //a--torso b--body c--shoulder d--arm and leg
void torso()
{
glPushMatrix();
glScalef(float(1.0/a)1.01.0);
glutSolidSphere(a 30 17);
glPopMatrix();
}
void body()
{
glPushMatrix();
glTranslatef(01.50);
glScalef(1.0float(1.5/b)1.0);
glutSolidSphere(b 30 17);
glPopMatrix();
}
void shoulder()
{
glPushMatrix();
glScalef(float(1.5/c)1.01.0);
glutSolidSphere(c 30 17);
glPopMatrix();
}
void head()
{
glPushMatrix();
glTranslatef(00.50);
glutSolidSphere(0.5f 30 17);
glTranslatef(000.5);
glutSolidSphere(0.1f 30 17);
glPopMatrix();
}
void upperarm() //手脚的画法相同,所以直接使用同一个函数
{
glPushMatrix();
glTranslatef(0-10);
glScalef(1.0float(1.0/d)1.0);
glutSolidSphere(d 30 17);
glPopMatrix();
}
void lowerarm()
{
glPushMatrix();
glTranslatef(0-10);
glScalef(1.0float(1.0/d)1.0);
glutSolidSphere(d 30 17);
glPopMatrix();
}
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)
{
glClearColor(0.00.00.00.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(0.10.90.1);
glPushMatrix();
glRotatef((float)all_rotate0.01.00.0);
glPushMatrix();
glTranslatef(00robot_move);
glPushMatrix();
body(); //身体
glPopMatrix();
glPushMatrix(); //(000)
glTranslatef(030); //(030)
glPushMatrix(); //先画头,这样头和脖子就不会一起旋转
glRotatef(head_rotate0.01.00.0);
head();
glPopMatrix(); //(030)
glRotatef((GLfloat)shoulder_y0.01.00.0); //shoulder、arms rotate based on Y axis
glRotatef((GLfloat)shoulder_x1.00.00.0); //shoulder、arms rotate based on X axis
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-03-09 18:57 Robot\
目录 0 2017-03-09 18:57 Robot\Robot\
文件 882 2017-01-03 12:56 Robot\Robot.sln
文件 9216 2017-03-09 18:57 Robot\Robot.suo
目录 0 2017-03-09 18:57 Robot\Robot\Debug\
文件 610 2017-03-09 18:55 Robot\Robot\Debug\cl.command.1.tlog
文件 19180 2017-03-09 18:55 Robot\Robot\Debug\CL.read.1.tlog
文件 274 2017-03-09 18:55 Robot\Robot\Debug\CL.write.1.tlog
文件 2 2017-03-09 18:56 Robot\Robot\Debug\li
文件 2 2017-03-09 18:56 Robot\Robot\Debug\li
文件 2 2017-03-09 18:56 Robot\Robot\Debug\li
文件 2 2017-03-09 18:56 Robot\Robot\Debug\li
文件 2 2017-03-09 18:56 Robot\Robot\Debug\li
文件 2 2017-03-09 18:56 Robot\Robot\Debug\li
文件 1356 2017-03-09 18:56 Robot\Robot\Debug\li
文件 3538 2017-03-09 18:56 Robot\Robot\Debug\li
文件 612 2017-03-09 18:56 Robot\Robot\Debug\li
文件 350 2017-03-09 18:56 Robot\Robot\Debug\mt.command.1.tlog
文件 266 2017-03-09 18:56 Robot\Robot\Debug\mt.read.1.tlog
文件 266 2017-03-09 18:56 Robot\Robot\Debug\mt.write.1.tlog
文件 464 2017-03-09 18:55 Robot\Robot\Debug\rc.command.1.tlog
文件 238 2017-03-09 18:55 Robot\Robot\Debug\rc.read.1.tlog
文件 246 2017-03-09 18:55 Robot\Robot\Debug\rc.write.1.tlog
文件 406 2017-03-09 18:55 Robot\Robot\Debug\Robot.exe.em
文件 472 2017-03-09 18:55 Robot\Robot\Debug\Robot.exe.em
文件 381 2017-03-09 18:56 Robot\Robot\Debug\Robot.exe.intermediate.manifest
文件 57 2017-03-09 18:56 Robot\Robot\Debug\Robot.lastbuildstate
文件 1828 2017-03-09 18:56 Robot\Robot\Debug\Robot.log
文件 69088 2017-03-09 18:55 Robot\Robot\Debug\robot.obj
文件 713 2017-03-09 18:55 Robot\Robot\Debug\Robot.vcxprojResolveAssemblyReference.cache
文件 0 2017-03-09 18:55 Robot\Robot\Debug\Robot.write.1.tlog
............此处省略7个文件信息
- 上一篇:数据通信原理 试题举例2
- 下一篇:Hdocs.zip
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- 机器人单机械臂滑模控制程序
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 智能寻迹机器人源程序及pcb图
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- 发那科fanuc机器人robot(电气调试启动
- Fanuc机器人PNS程序和RSR程序启动改.d
- OPENGL实现世界上最小的3D游戏
- 微信聊天机器人源码
- 机器人操作系统ROS2
- ipad微信协议机器人
- VS2012OpenGL配置所需要的全部libdllh文件
- 水下自重构机器人行走运动稳定性准
- 机器人运动学及动力学
- Geometrical methods in robotics
- 基于改进势场栅格法的移动机器人路
- 基于改进人工势场法的救灾机器人路
- 机器人-SPS程序-简析
评论
共有 条评论