資源簡(jiǎn)介
用opengl實(shí)現(xiàn)的小車建模和漫游,可以對(duì)小車進(jìn)行操控,適合新手學(xué)習(xí)

代碼片段和文件信息
//原始作者:朱慧君,提供了初步思路及簡(jiǎn)易的運(yùn)動(dòng)方程
//修改者:樊麗,精簡(jiǎn)并修改現(xiàn)有功能,以匹配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;//標(biāo)準(zhǔn)精確度
AutoPartWheel??*?newP;
int?ij;
newV?=?NULL;
newP?=?NULL;
i=0;
j=0;
/////------------------------------------配置標(biāo)準(zhǔn)值
double?d_w1_2?=?1.0;////左右輪距的一半
double?d_w2_2?=?1.6;////前后輪距的一半---------軸距一半
zeroV?=?new?CVertex(000);
defV?=?new?CVertex(32320);
////////////////////原點(diǎn)
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;//標(biāo)準(zhǔn)精確度
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);?//?關(guān)閉混合
////-------------
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
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????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個(gè)文件信息
- 上一篇:虛擬環(huán)境漫游系統(tǒng)
- 下一篇:Qt下的自定義圖像顯示控件
評(píng)論
共有 條評(píng)論