資源簡介
openGL四面體、立方體、正N棱柱、齒輪模型、正N角星模型的畫法介紹。平臺為VS2008 語言為C++語言 win7操作系統

代碼片段和文件信息
#include?“cube.h“
#include?“prefix.h“
cube::cube(void)
{
vertex_count=8;
face_count=6;
vertex_list=new?VERTEX[8];
face_list=new?FACE[6];
vertex_list[0].x=-1;//上左前點
vertex_list[0].y=1;
vertex_list[0].z=1;
vertex_list[1].x=-1;//上左后點
vertex_list[1].y=1;
vertex_list[1].z=-1;
vertex_list[2].x=1;//上右后點
vertex_list[2].y=1;
vertex_list[2].z=-1;
vertex_list[3].x=1;//上右前點
vertex_list[3].y=1;
vertex_list[3].z=1;
vertex_list[4].x=-1;//下左前點
vertex_list[4].y=-1;
vertex_list[4].z=1;
vertex_list[5].x=-1;//下左后點
vertex_list[5].y=-1;
vertex_list[5].z=-1;
vertex_list[6].x=1;//下右后點
vertex_list[6].y=-1;
vertex_list[6].z=-1;
vertex_list[7].x=1;//下右前點
vertex_list[7].y=-1;
vertex_list[7].z=1;
face_list[0].bTrangle=false;
face_list[0].index[0]=0;//上面
face_list[0].index[1]=3;
face_list[0].index[2]=2;
face_list[0].index[3]=1;
face_list[1].bTrangle=false;
face_list[1].index[0]=4;//下面
face_list[1].index[1]=5;
face_list[1].index[2]=6;
face_list[1].index[3]=7;
face_list[2].bTrangle=false;
face_list[2].index[0]=0;//前面
face_list[2].index[1]=4;
face_list[2].index[2]=7;
face_list[2].index[3]=3;
face_list[3].bTrangle=false;
face_list[3].index[0]=1;//后面
face_list[3].index[1]=2;
face_list[3].index[2]=6;
face_list[3].index[3]=5;
face_list[4].bTrangle=false;
face_list[4].index[0]=0;//左面
face_list[4].index[1]=1;
face_list[4].index[2]=5;
face_list[4].index[3]=4;
face_list[5].bTrangle=false;
face_list[5].index[0]=2;//右面
face_list[5].index[1]=3;
face_list[5].index[2]=7;
face_list[5].index[3]=6;
}
void?cube:: draw()
{
int?findex;
glBegin(GL_QUADS);
for(findex=0;findex {
glColor3f(?1.0?0.0?0.0?);
glVertex3f(vertex_list[face_list[findex].index[0]].xvertex_list[face_list[findex].index[0]].yvertex_list[face_list[findex].index[0]].z);
glColor3f(?0.0?1.0?0.0?);
glVertex3f(vertex_list[face_list[findex].index[1]].xvertex_list[face_list[findex].index[1]].yvertex_list[face_list[findex].index[1]].z);
glColor3f(?0.0?0.0?1.0?);
glVertex3f(vertex_list[face_list[findex].index[2]].xvertex_list[face_list[findex].index[2]].yvertex_list[face_list[findex].index[2]].z);
glColor3f(?0.0?1.0?1.0?);
glVertex3f(vertex_list[face_list[findex].index[3]].xvertex_list[face_list[findex].index[3]].yvertex_list[face_list[findex].index[3]].z);
}
glEnd();
}
cube::~cube(void)
{
if(vertex_list!=NULL)?
delete?vertex_list;
if(face_list!=NULL)?
delete?face_list;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5261??2012-12-08?19:07??assig5_modelling\assig2_modelling\assig2_modelling.vcproj
?????文件???????1413??2010-10-25?07:45??assig5_modelling\assig2_modelling\assig2_modelling.vcproj.COMPUTER.Administrator.user
?????文件???????1409??2011-12-06?15:19??assig5_modelling\assig2_modelling\assig2_modelling.vcproj.hxp-PC.hxp.user
?????文件???????1403??2012-12-03?10:20??assig5_modelling\assig2_modelling\assig2_modelling.vcproj.HXP.Administrator.user
?????文件???????1413??2010-05-10?20:05??assig5_modelling\assig2_modelling\assig2_modelling.vcproj.teacher7.jszxxhs.user
?????文件???????1411??2012-12-04?14:57??assig5_modelling\assig2_modelling\assig2_modelling.vcproj.user861.Administrator.user
?????文件???????1427??2012-12-09?23:05??assig5_modelling\assig2_modelling\assig2_modelling.vcproj.XTZJ-20120809IA.Administrator.user
?????文件???????2608??2012-12-04?14:56??assig5_modelling\assig2_modelling\cube.cpp
?????文件????????195??2010-05-10?09:07??assig5_modelling\assig2_modelling\cube.h
?????文件???????3869??2012-12-07?18:43??assig5_modelling\assig2_modelling\cylinder.cpp
?????文件????????217??2012-12-06?18:40??assig5_modelling\assig2_modelling\cylinder.h
?????文件???????2515??2012-12-08?19:22??assig5_modelling\assig2_modelling\cylinderchange.cpp
?????文件????????235??2012-12-08?19:07??assig5_modelling\assig2_modelling\cylinderchange.h
?????文件????????276??2012-12-06?23:35??assig5_modelling\assig2_modelling\data\zxc.txt
?????文件??????40376??2012-12-06?23:40??assig5_modelling\assig2_modelling\data\漂亮的杯子.jpg
?????文件????????366??2012-12-08?17:49??assig5_modelling\assig2_modelling\data_struct.h
?????文件????????374??2012-12-07?21:51??assig5_modelling\assig2_modelling\data_struct_new.h
?????文件????????663??2012-12-07?23:48??assig5_modelling\assig2_modelling\Debug\assig2_modelling.exe.em
?????文件????????728??2012-12-07?23:48??assig5_modelling\assig2_modelling\Debug\assig2_modelling.exe.em
?????文件????????621??2012-12-09?23:03??assig5_modelling\assig2_modelling\Debug\assig2_modelling.exe.intermediate.manifest
?????文件???????7564??2012-12-09?23:03??assig5_modelling\assig2_modelling\Debug\BuildLog.htm
?????文件??????26525??2012-12-08?17:49??assig5_modelling\assig2_modelling\Debug\cube.obj
?????文件??????28836??2012-12-08?17:49??assig5_modelling\assig2_modelling\Debug\cylinder.obj
?????文件??????28455??2012-12-08?19:22??assig5_modelling\assig2_modelling\Debug\cylinderchange.obj
?????文件??????30958??2012-12-08?17:49??assig5_modelling\assig2_modelling\Debug\gear.obj
?????文件??????29900??2012-12-08?19:22??assig5_modelling\assig2_modelling\Debug\gearchange.obj
?????文件??????32271??2012-12-09?23:03??assig5_modelling\assig2_modelling\Debug\main.obj
?????文件?????????65??2012-12-09?23:03??assig5_modelling\assig2_modelling\Debug\mt.dep
?????文件??????20291??2012-12-07?23:39??assig5_modelling\assig2_modelling\Debug\prefix.obj
?????文件??????27146??2012-12-08?17:49??assig5_modelling\assig2_modelling\Debug\pyramid.obj
............此處省略29個文件信息
- 上一篇:字體輪廓提取
- 下一篇:vigenere密碼加密解密算法實現軟件Vc++編寫
評論
共有 條評論