載入PLY模型 C

2021-07-08 10:22:41 字數 2142 閱讀 5863

/*

2: 操作說明:

3: 鍵盤按下

4: r=會變成紅色

5: g=會變成綠色

6: b=會變成藍色

7: p=ploygon組成

8: l=line組成

9: model本身會自動旋轉

10: */

#include #include #include #include #include using namespace std;

void loadply(char *file_name,int style);//讀取並畫出ply函式

double r_ang=0.5;//旋轉角度變數

double r=255.0, g=0.0, b=0.0;//顏色儲存變數

int style=gl_polygon;//畫出model的方式

/*lighting 變數*/

const glfloat light_ambient = ;

const glfloat light_diffuse = ;

const glfloat light_specular = ;

const glfloat light_position = ;

const glfloat mat_ambient = ;

const glfloat mat_diffuse = ;

const glfloat mat_specular = ;

const glfloat high_shininess = ;

void loadply(char *file_name,int style)

string str;

int vertex, face;

char ch;

/*讀取header*/

while ( !fin.eof ( ) )

else

//取得face個數

else if(str == "face")

else if(str == "end_header")

else

str.clear ( );

} }

//動態產生array

double *vertex_arrayx = new double[vertex];

double *vertex_arrayy = new double[vertex];

double *vertex_arrayz = new double[vertex];

int pos = 0;

int counter = 0;

double number;

double max_edge = 0;

static double temp_max = 0;

/*讀取vertex*/

while ( !fin.eof ( ) )

else if(pos%3 == 1)

else if(pos%3 == 2)

pos++;

//紀錄最大的邊

if(abs((int)number) > max_edge)

max_edge = abs((int)number);

}

} int point[4];

int i = 0;

counter = 0;

/*畫polygon*/

while ( !fin.eof ( ) )

else if(str == "") continue;

else

} }fin.close();

//調整視角

if(max_edge > temp_max)

temp_max = max_edge;

} void display()

void init()

void keyboard(unsigned char key, int x, int y)

glutpostredisplay();

} void idle(void)

int main(int argc, char** argv)

ply模型格式解析與Loader編寫

ply作為一種多邊形模型資料格式,不同於三維引擎中常用的場景 件格式和指令碼檔案,每個ply檔案只用於描述乙個多邊形模型物件object,該模型物件可以通過諸如頂點 麵等資料進行描述,被統稱作元素element。ply的檔案結構是 檔案頭 資料列表。其中檔案頭以行為單位描述檔案型別 格式與版本 元素...

opengl 模型載入

乙個非常流行的模型導入庫是assimp,它是open asset import library 開放的資產導入庫 的縮寫 assimp資料結構的 簡化 模型如下 opengl中定義乙個頂點,每個頂點包含乙個位置向量 乙個法向量和乙個紋理座標向量 struct vertex 紋理資料,儲存了紋理的id...

keras載入模型

說明 該程式是乙個包含兩個隱藏層的神經網路。演示如何載入乙個儲存好的模型。資料集 mnist from future import print function python提供了 future 模組,把下乙個新版本的特性匯入到當前版本,於是我們就可以在當前版本中測試一些新版本的特性。import ...