91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

自己構建的半邊結構,并實現了loop細分算法,并實現了3d模型的縮放等

資源截圖

代碼片段和文件信息

#include?“stdafx.h“
#include???
#include?“GL\glut.h“
#include?
#include?
#include?
#include?
#include
#include
using?namespace?std;

//用于點線面的個數
int?numofvertex?=?0;
int?numofface?=?0;
int?numofline?=?0;
//定義窗口大小
int?WIDTH?=?600;
int?HEIGHT?=?600;
float?maxx?=?-1;
float?maxy?=?-1;
float?maxz?=?-1;
float?minx?=?1;
float?miny?=?1;
float?minz?=?1;
//定義攝像機位置和方向
GLfloat?ShootPosition[]?=?{?000?};
GLfloat?ShootDirect[]?=?{?000?};
//與實現旋轉角度大小相關的參數,只需要兩個就可以完成
float?scale?=?1.0;
float?px;
float?py;
float?theta1?=?0;
float?theta2?=?0;
float?radius?=?0;

int?displaystate?=?0;
float?PI?=?3.1415926;

//定義點、面、邊等結構
struct?vertex;
struct?face;
struct?halfedge;
struct?he_face;
struct?normalVec;
struct?iedge;
vertex*?vertexs;
face*?faces;
he_face**?hefaces;
normalVec*?normalvectors;
iedge**?iedges;
//定義半邊結構
struct?halfedge?{
halfedge*?next;//下一條半邊
halfedge*?opposite;//與其相反的半邊
int?end;//所指的點
bool?visit;//是否被訪問過
he_face*?face;//所屬的面
//定義構造函數并初始化
halfedge()?{
next?=?NULL;
opposite?=?NULL;
end?=?-1;
face?=?NULL;
visit?=?false;
}
};
//定義半邊結構中的點結構
struct?vertex?{
//點坐標
float?x;
float?y;
float?z;
//指向該點的半邊
halfedge*?edge;
//是否被訪問過
bool?visit;
//空構造函數,初始化
vertex()?{
visit?=?false;
}
//構造函數
vertex(float?a?float?b?float?c)?{
x?=?a;
y?=?b;
z?=?c;
edge?=?NULL;
visit?=?false;
}
};
//定義正常的點的結構或者成為向量
struct?normalVec?{
//點坐標
float?x;
float?y;
float?z;
normalVec()?{

}
normalVec(float?a?float?b?float?c)?{
x?=?a;
y?=?b;
z?=?c;
}
};
//定義半邊中面的結構
struct?he_face?{
//包含的半邊
halfedge*?edge;
//是否被訪問過
bool?visit;
he_face()?{
edge?=?NULL;
visit?=?false;
}
};
//定義正常的面的結構
struct?face?{
//構成該面的點的數量
int?numofv;
//構成該面的點
int*?vertexs;
face()?{

}
face(int?nv)?{
numofv?=?nv;
vertexs?=?new?int[nv];
}
};
//定義自己的邊結構
struct?iedge?{
//起點
int?start;
//在loop細分中的中間點
int?middle;
//所含半邊(兩條)
halfedge*?he;
iedge*?next;
iedge()?{
start?=?-1;
he?=?NULL;
next?=?NULL;
middle?=?-1;
}
};

//讀取3d文件,off格式?
void?readFile()?{
char?data[100];
ifstream?infile;
infile.open(“bunny.off“);
//讀取“off”字符
infile?>>?data;
//讀取點、面、邊的數量
infile?>>?numofvertex;
infile?>>?numofface;
infile?>>?numofline;
vertexs?=?new?vertex[numofvertex];
faces?=?new?face[numofface];
int?vnum?=?0;
int?fnum?=?0;
//構建“點”集
while?(vnum? float?x;
float?y;
float?z;
infile?>>?x;
infile?>>?y;
infile?>>?z;
vertexs[vnum]?=?vertex(x?y?z);
vnum++;
}
//構建“面”集
while?(fnum {
int?numofv;
infile?>>?numofv;
face?f?=?face(numofv);
for?(int?i?=?0;?i? {
int?v;
infile?>>?v;
f.vertexs[i]?=?v;
}
faces[fnum]?=?f;
fnum++;
}
infile.close();
}


int?getMiddle(int?start?int?end?iedge**?iedges)?{
iedge*?temp?=?iedges[start];

評論

共有 條評論