资源简介
用opengl实现的小车建模和漫游,可以对小车进行操控,适合新手学习

代码片段和文件信息
//原始作者:朱慧君,提供了初步思路及简易的运动方程
//修改者:樊丽,精简并修改现有功能,以匹配AutoPart类
#include “Automotive.h“
myCar::myCar(void)
{
this->normal3f = CVertex(010);
this->position = CVertex(000);
this->ready = 0;
this->rotx = 0;
this->roty = 0;
this->rotz = 0;
this->wheel = NULL;
this->wheel_num = 0;
this->viewangle = 0;
m_carbody = new AutoPartBody(“jeep.3ds“);
}
myCar::~myCar(void)
{
}
bool myCar::CreateDemoCar(void)
{
CVertex * newV;
CVertex * zeroV;
CVertex * defV;//标准精确度
AutoPartWheel * newP;
int ij;
newV = NULL;
newP = NULL;
i=0;
j=0;
/////------------------------------------配置标准值
double d_w1_2 = 1.0;////左右轮距的一半
double d_w2_2 = 1.6;////前后轮距的一半---------轴距一半
zeroV = new CVertex(000);
defV = new CVertex(32320);
////////////////////原点
this->Setpos(* zeroV);
///////////////////方向
this->CreateDemo4Wheel(d_w1_2 d_w2_2);
m_carbody->DrawGL();
this->ready=1;
return true;
}
bool myCar::CreateWheel(int n)
{
if (n>0)
{
if (this->wheel=new AutoPartWheel[n])
{
this->wheel_num = n;
return true;
}
}
return false;
}
bool myCar::Setpos(CVertex p)
{
this->position = p;
return false;
}
bool myCar::SetOri(CVertex ori)
{
this->normal3f = ori;
return false;
}
bool myCar::Rotxyz(double x double y double z)
{
this->rotx += x;
this->roty += y;
this->rotz += z;
while (rotz>360) rotz -= 360;
while (rotz<-360) rotz += 360;
return false;
}
bool myCar::ResetRot(void)
{
this->rotx=0;
this->roty=0;
this->rotz=0;
return false;
}
bool myCar::CreateDemo4Wheel(double dx double dy)
{
CVertex * newV;
CVertex * newV2;
CVertex * zeroV;
CVertex * maxV;
CVertex * defV;//标准精确度
AutoPartWheel * newP;
// double ds2;
int ij;
newV=NULL;
newV2=NULL;
newP=NULL;
i=0;
j=0;
zeroV = new CVertex(000);
maxV = new CVertex(111);
defV = new CVertex(32320);
// ds2=ds/2;
double r=0;
double xx=0;
double h1=0;
double h2=0;
// xx=ds/2 + 0.005;//厚度
// r=dz/2;//三角半径半径
// h1=r/2;
// h2=sqrt(3.0)*h1;
/////-----------------
this->CreateWheel(4);
newV = new CVertex(-dx dy0);
this->wheel[0].Set(* newV);
this->wheel[0].rotable=1;
newV = new CVertex( dx dy0);
this->wheel[1].Set(* newV);
this->wheel[1].rotable=1;
newV = new CVertex(-dx-dy0);
this->wheel[2].Set(* newV);
newV = new CVertex( dx-dy0);
this->wheel[3].Set(* newV);
return false;
}
bool myCar::DrawGL(void)
{
int i=0;
double rott=0;//////////轮子偏向,决定的车身偏向基量
double ws=0;///////////轮子速度决定
if (this->ready == 1)
{
glPushMatrix();
glEnable(GL_DEPTH_TEST); //
glDisable(GL_BLEND); // 关闭混合
////-------------
if (this->viewangle==0)////viewangle世界视角
{
glTranslatef(position.xposition.yposition.z);
if (rotz>360) rotz-=360;
if (rotz<0) rotz+=360;
glRotatef(rotx1.0f0.0f0.0f);
glRotatef(roty0.0f1.0f0.0f);
glRotatef(rot
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-05-04 16:22 OpenGL小车三维模型源码\
文件 24162 2009-08-19 14:29 OpenGL小车三维模型源码\3DS.CPP
文件 3827 2009-08-19 14:39 OpenGL小车三维模型源码\3DS.H
文件 6512 2009-08-19 14:34 OpenGL小车三维模型源码\Automotive.cpp
文件 4790 2009-08-19 14:44 OpenGL小车三维模型源码\Automotive.dsp
文件 543 2009-08-17 15:09 OpenGL小车三维模型源码\Automotive.dsw
文件 323645 2009-08-19 14:42 OpenGL小车三维模型源码\Automotive.exe
文件 1182 2009-08-19 14:26 OpenGL小车三维模型源码\Automotive.h
文件 471464 2009-08-19 14:42 OpenGL小车三维模型源码\Automotive.ilk
文件 123904 2011-03-31 23:11 OpenGL小车三维模型源码\Automotive.ncb
文件 51712 2011-03-31 23:11 OpenGL小车三维模型源码\Automotive.opt
文件 254 2011-03-31 23:04 OpenGL小车三维模型源码\Automotive.plg
文件 809 2009-08-19 14:45 OpenGL小车三维模型源码\Automotive.positions
文件 2026 2009-08-19 14:34 OpenGL小车三维模型源码\AutoPart.cpp
文件 1223 2009-08-19 14:26 OpenGL小车三维模型源码\AutoPart.h
文件 3772 2011-03-20 12:11 OpenGL小车三维模型源码\bitmap.h
目录 0 2012-05-04 16:22 OpenGL小车三维模型源码\Data\
文件 17455 2009-08-15 08:50 OpenGL小车三维模型源码\Data\jeep.3DS
文件 262198 2004-07-19 21:52 OpenGL小车三维模型源码\Data\jeep.bmp
文件 263222 2004-10-26 10:50 OpenGL小车三维模型源码\Data\sand0.BMP
文件 10752 2011-03-18 23:05 OpenGL小车三维模型源码\Data\Thumbs.db
文件 2575 2009-08-15 08:59 OpenGL小车三维模型源码\Data\wheel.3DS
目录 0 2012-05-04 16:22 OpenGL小车三维模型源码\Debug\
文件 85529 2011-03-20 11:55 OpenGL小车三维模型源码\Debug\3DS.obj
文件 299089 2011-03-20 12:11 OpenGL小车三维模型源码\Debug\Automotive.exe
文件 463276 2011-03-20 12:11 OpenGL小车三维模型源码\Debug\Automotive.ilk
文件 45212 2011-03-20 11:55 OpenGL小车三维模型源码\Debug\Automotive.obj
文件 3721528 2011-03-20 12:03 OpenGL小车三维模型源码\Debug\Automotive.pch
文件 648192 2011-03-20 12:11 OpenGL小车三维模型源码\Debug\Automotive.pdb
文件 30431 2011-03-20 11:55 OpenGL小车三维模型源码\Debug\AutoPart.obj
文件 41298 2011-03-20 11:55 OpenGL小车三维模型源码\Debug\MainApp.obj
............此处省略11个文件信息
- 上一篇:虚拟环境漫游系统
- 下一篇:Qt下的自定义图像显示控件
相关资源
- UML建模大全
- OpenGL参考手册
- 数学建模实验报告(八个全)
- vtk QT做的三维地质可视化系统2of2
- 三维重建(旋转)由已知对应图像点
- Qt Creator opengl实现四元数鼠标控制轨迹
- 4 1视图建模教程实例大全
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- PSCAD风电建模实例双馈风力发电机的
- 三维地形的仿真显示实现了对地图的
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 大学作业之数学建模锇狼追兔
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 图形学集成程序dda、中点算法、多边
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- 幕墙快速建模与出图犀牛插件.rar
- 采场围岩三维力学特征与冲击地压的
- 厚冲积层薄基岩采场围岩三维力学特
- 基于属性驱动的矿体动态建模
- 基于数字摄影测量的结构面、关键块
- 基于实体与块体混合模型的三维矿体
评论
共有 条评论