資源簡介
importobj類 讀取 3dsmax obj文件

代碼片段和文件信息
#include?“cube.h“
#include?“prefix.h“
cube::cube(void)
{
texture=NULL;
vertex_count=8;
face_count=6;
vertex_list=new?VERTEX[8];
face_list=new?FACE[6];
vertex_list[0].xyz[0]=-1;//上左前點
vertex_list[0].xyz[1]=1;
vertex_list[0].xyz[2]=1;
vertex_list[1].xyz[0]=-1;//上左后點
vertex_list[1].xyz[1]=1;
vertex_list[1].xyz[2]=-1;
vertex_list[2].xyz[0]=1;//上右后點
vertex_list[2].xyz[1]=1;
vertex_list[2].xyz[2]=-1;
vertex_list[3].xyz[0]=1;//上右前點
vertex_list[3].xyz[1]=1;
vertex_list[3].xyz[2]=1;
vertex_list[4].xyz[0]=-1;//下左前點
vertex_list[4].xyz[1]=-1;
vertex_list[4].xyz[2]=1;
vertex_list[5].xyz[0]=-1;//下左后點
vertex_list[5].xyz[1]=-1;
vertex_list[5].xyz[2]=-1;
vertex_list[6].xyz[0]=1;//下右后點
vertex_list[6].xyz[1]=-1;
vertex_list[6].xyz[2]=-1;
vertex_list[7].xyz[0]=1;//下右前點
vertex_list[7].xyz[1]=-1;
vertex_list[7].xyz[2]=1;
face_list[0].bTriangle=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].bTriangle=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].bTriangle=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].bTriangle=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].bTriangle=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].bTriangle=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;
///計算每個面上的法向量
calculateNormals();
}
void?cube:: SetTexture(GLTexture*text)
{
texture=text;
}
void?cube:: SetTexture2(GLTexture*text2)
{
texture2=text2;
}
void?cube:: draw()
{
int?i=0;
if(texture)? texture->Use();
glBegin(GL_QUADS);
glNormal3fv(face_list[0].normal);
glTexCoord2f(0.0+0.333*i0.0);
glVertex3fv(vertex_list[face_list[0].index[0]].xyz);
glTexCoord2f(0.333+0.333*i0.0);
glVertex3fv(vertex_list[face_list[0].index[1]].xyz);
glTexCoord2f(0.333+0.333*i0.5);
glVertex3fv(vertex_list[face_list[0].index[2]].xyz);
glTexCoord2f(0.0+0.333*i0.5);
glVertex3fv(vertex_list[face_list[0].index[3]].xyz);
glNormal3fv(face_list[1].normal);
glTexCoord2f(0.0+0.333*i0.5);
glVertex3fv(vertex_list[face_list[1].index[0]].xyz);
glTexCoord2f(0.333+0.333*i0.5);
glVertex3fv(vertex_list[face_list[1].index[1]].xyz);
glTexCoord2f(0.333+0.333*i1.0);
glVertex3fv(vertex_list[face_list[1].index[2]].xyz);
glTexCoord2f(0.0+0.333*i1.0);
glVertex3fv(vertex_list[face_list[1].index[3]].xyz);
i++;
glNormal3fv(face_list[2].normal);
glTexCoord2f(0.0+0.333*i0.0);
glVertex3fv(vertex_list[face_list[2].index[0]].xyz);
glTexCoord2f(0.333+0.333*i0.0);
glVer
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5071??2011-05-22?01:24??assig2_modelling\assig2_modelling\assig2_modelling\assig2_modelling.vcproj
?????文件???????1427??2011-06-03?16:30??assig2_modelling\assig2_modelling\assig2_modelling\assig2_modelling.vcproj.2FF45DFAE74B44E.admin.user
?????文件???????1413??2010-05-17?10:10??assig2_modelling\assig2_modelling\assig2_modelling\assig2_modelling.vcproj.COMPUTER.Administrator.user
?????文件???????1409??2011-05-05?10:34??assig2_modelling\assig2_modelling\assig2_modelling\assig2_modelling.vcproj.hxp-PC.hxp.user
?????文件???????1409??2011-05-19?17:13??assig2_modelling\assig2_modelling\assig2_modelling\assig2_modelling.vcproj.stu-03.Administrator.user
?????文件???????1409??2011-05-13?11:33??assig2_modelling\assig2_modelling\assig2_modelling\assig2_modelling.vcproj.stu-14.Administrator.user
?????文件???????1413??2010-05-10?20:05??assig2_modelling\assig2_modelling\assig2_modelling\assig2_modelling.vcproj.teacher7.jszxxhs.user
?????文件???????1413??2010-12-13?10:57??assig2_modelling\assig2_modelling\assig2_modelling\assig2_modelling.vcproj.teacher8.Administrator.user
?????文件?????????76??2010-05-04?14:11??assig2_modelling\assig2_modelling\assig2_modelling\bottleprofile.txt
?????文件???????6737??2011-05-06?20:58??assig2_modelling\assig2_modelling\assig2_modelling\cube.cpp
?????文件????????412??2011-05-13?00:29??assig2_modelling\assig2_modelling\assig2_modelling\cube.h
?????文件???????7613??2011-05-13?01:27??assig2_modelling\assig2_modelling\assig2_modelling\cylinder.cpp
?????文件????????905??2011-05-13?00:30??assig2_modelling\assig2_modelling\assig2_modelling\cylinder.h
?????文件?????538662??2011-05-13?11:10??assig2_modelling\assig2_modelling\assig2_modelling\data\black_white.bmp
?????文件??????16896??2010-05-10?11:02??assig2_modelling\assig2_modelling\assig2_modelling\data\Book1.xls
?????文件?????????76??2010-05-04?14:11??assig2_modelling\assig2_modelling\assig2_modelling\data\bottleprofile.txt
?????文件????6912054??2011-05-05?10:15??assig2_modelling\assig2_modelling\assig2_modelling\data\img7.bmp
?????文件?????289098??2010-05-16?15:58??assig2_modelling\assig2_modelling\assig2_modelling\data\NO1.bmp
?????文件????????202??2010-05-04?14:34??assig2_modelling\assig2_modelling\assig2_modelling\data\wineglassprofile.txt
?????文件????????476??2011-05-27?23:45??assig2_modelling\assig2_modelling\assig2_modelling\data_struct.h
?????文件????????663??2011-05-27?23:45??assig2_modelling\assig2_modelling\assig2_modelling\Debug\assig2_modelling.exe.em
?????文件????????728??2011-05-27?23:45??assig2_modelling\assig2_modelling\assig2_modelling\Debug\assig2_modelling.exe.em
?????文件????????621??2011-05-31?22:05??assig2_modelling\assig2_modelling\assig2_modelling\Debug\assig2_modelling.exe.intermediate.manifest
?????文件???????7736??2011-05-31?22:05??assig2_modelling\assig2_modelling\assig2_modelling\Debug\BuildLog.htm
?????文件??????44202??2011-05-27?23:45??assig2_modelling\assig2_modelling\assig2_modelling\Debug\cube.obj
?????文件??????43855??2011-05-27?23:45??assig2_modelling\assig2_modelling\assig2_modelling\Debug\cylinder.obj
?????文件??????46388??2011-05-27?23:45??assig2_modelling\assig2_modelling\assig2_modelling\Debug\GLTexture.obj
?????文件?????275175??2011-05-27?23:45??assig2_modelling\assig2_modelling\assig2_modelling\Debug\ImportObj.obj
?????文件??????37235??2011-05-27?23:45??assig2_modelling\assig2_modelling\assig2_modelling\Debug\ImportVT.obj
?????文件??????50666??2011-05-31?22:05??assig2_modelling\assig2_modelling\assig2_modelling\Debug\main.obj
............此處省略43個文件信息
評論
共有 條評論