i am asked to change the mesh data structure in the apiMeshShape plug-in of Maya. So now I wanna draw a 3D mesh represented in Vertex-vertex structure (as you can see in en.wikipedia.org/wiki/Polygon_mesh) using opengl.
1)First, i don't know exactly how to represent the Vertex-vertex mesh. I wonder if the data structure as follow is ok?
MPointArray vertices; //the position of all the vertices
MIntArray vertices_connects_counts; //how many other vertices each vertex connect with
MIntArray vertices_connects; //the index array storing each the vertices' index connected with all the vertices
take the cube example in the http://en.wikipedia.org/wiki/Polygon_mesh as the example.
vertices_connects_counts = {5,5,5,5,5,5,5,5,4,4};
vertices_connects = {1,5,4,3,9,
2,6,5,0,9,
3,7,6,1,9,
2,6,7,4,9,
5,0,3,7,8,
6,1,0,4,8,
7,2,1,5,8,
4,3,2,6,8,
5,6,7,8,
0,1,2,3 };
2)Secondly, if the data structure above is right i wonder how to draw the mesh using openGL? Which parameter should i pass into glBegin()?
1) That's a functional data structure for your needs as described.
2) Allow me to quote the Wikipedia article that you linked:
but not widely used since the face and edge information is implicit. Thus, it is necessary to traverse the data in order to generate a list of faces for rendering.
That's what you have to do. If you insist on keeping this data structure (and I wouldn't), then you're going to have to walk the connectivity graph and build a list of vertex faces. Then you'll have the data to send to OpenGL.