0
votes

I know in mesh representation it is common to use three lists:

Vertex list, all vertices, this is easy to understand

Normal list, normals for each surface I guess?

And the face list, I have no idea what it does and I don't know how to calculate it.

For example, this is a mesh describing a triangular prism I found online.

double vertices[][] = {{0,1,-1},
           {-0.5,0,-1},
           {0.5,0,-1},
           {0,1,-3},
           {-0.5,0,-3},
           {0.5,0,-3},
          };

int faces[][] = {{0,1,2}, //front
         {3,5,4}, //back
         {1,4,5,2},//base
         {0,3,4,1}, //left side
         {0,2,5,3} //right side
        };

double normals[][] = { {0,0,1}, //front face
           {0,0,-1}, //back face
           {0,-1,0}, //base
                   {-2.0/Math.sqrt(5),1.0/Math.sqrt(5),0}, //left
                   {2.0/Math.sqrt(5),1.0/Math.sqrt(5),0} //right
             };

Why are there 4 elements in the base, left and right faces but only 3 at the front and back? How do I calculate them manually?

2

2 Answers

1
votes

Usually, faces stores indices of each triangle in the vertices array. So the first face is a triangle consisting of vertices[0], vertices[1], vertices[2]. The second one consists of vertices[3], vertices[4], vertices[5] and so on.

0
votes

For triangular meshes, a face is a triangle defined by 3 vertices. Normally, a mesh is composed by a list of n vertices and m faces. For example:

Vertices:

Point_0 = {0,0,0}
Point_1 = {2,0,0}
Point_3 = {0,2,0}
Point_4 = {0,3,0}
...
Point_n = {30,0,0}

Faces:

Face_0 = {Point_1, Point_4, Point_5}
Face_1 = {Point_2, Point_4, Point_7}
...
Face_m = {Point_1, Point_2, Point_n}

For the sake of brevity, you can define Face_0 as a set of indices: {1,4,5}.

In addition, the normal vector is computed as a cross product between the vertices of a face. By convention, the direction of the normal vector is directed outside the mesh. For example:

normal_face_0 = CrossProcuct ( (Point_4 - Point_1) ,   (Point_5 - Point_4) )

In your case, it is quite weird to see four indices in a face definition. Normally, there should be only 3 items in the array. Are you sure this is not a mistake?