Build an OpenGL mesh viewer with glut(2)-Load M file into half-edge data structure

In this project, we focus on triangle mesh model which its data is stored into M file.  The format of M file is very simple, it contains two parts, one is for “vertex”, another part is for “face”.


Every “Vertex” has its index number and 3 float-point numbers as its vector value, each “Face” has its index number and 3 int numbers which are vertex index number.

Our task is how to load those data into memory for preparing rending in OpenGL. First, we have to read those data line by line and store them into a special data structure. The best solution for storing those data is using half-edge which is very popular, to understand the concept can refer

 Define half-edge data structure in our project

Create new file and name it as MeshModel.cpp in the project, define half-edge data structure in it.

Create another file name as “Main.cpp”  which contain main() function. In this file we need to load M file and push its data into half-edge structure we defined above.



Posted in CG

Leave a Reply


Related Posts