• Create Account

### #ActualBrother Bob

Posted 08 April 2012 - 06:19 AM

First we should clear up some confusion. To begin with, a vertex is a collection of attributes that defines a point on a model. A vertex can have different attributes, such as position, normal, texture coordinate, color, and so on; whatever attribute you have to describe your vertex. A vertex is not only the position.

The model you linked contains three different attributes: position (the v-tag), texture coordinate (the vt-tag) and normal (the vn-tag). These tags list all individual position attributes, all texture coordinate attributes and all normal attributes that will be used by your list of vertices.

Then you have the face descriptors (the f-tag). Let's take two typical lines from the file. First, "f 1/1/1 2/2/2 3/3/3". The list of triplets references each individual attribute that makes the vertex, and the tree triplets makes the three vertices in the face (the triangle in this case, since there are three vertices).

So, first, 1/1/1 means that the first vertex of the triangle is made up of the first position in the position list, the first texture coordinate in the texture coordinate list, and the first normal in the normal list. Likewise, 2/2/2 and 3/3/3 makes up two more vertices, of the second and third attribute of each corresponding list.

Then look at an example of what I think is confusing you: "f 4/4/5 3/3/6 5/5/7". It follows the very same pattern as previous example. The face is made up of three vertices, and the first vertex is made up from the fourth position, fourth texture coordinate, and the fifth normal. Likewise, the second vertex is made up of the third position, third texture coordinate, and the sixth normal.

So no vertex has two normals, but you may have two different vertices that have the same position but different normals. That is what 1/1/1 and 1/1/496 means; two vertices with the same position but different normals.

If your API does not support individual attribute indices, then you need to split and duplicate vertices. You cannot base your vertex arrays on the position attribute and attach texture coordinate and normal to each position. You have to base it on the face list, and build the vertices from there. Merging and duplicating vertices from one indexed format to another is not very difficult, but definitely a challenge if you're a beginner.

I would drop the index completely and build a flat vertex array instead. That is, load all attributes into separate arrays, load the face list, and construct a vertex array by passing over the face list and copying the attributes into the vertex array in the order determined by the face indices. When you have passed over the whole face list, you have a flat vertex array that stores the attributes in the order specified by the face list.

### #1Brother Bob

Posted 08 April 2012 - 06:18 AM

First we should clear up some confusion. To begin with, a vertex is a collection of attributes that defines a point on a model. A vertex can have different attributes, such as position, normal, texture coordinate, color, and so on; whatever attribute you have to describe your vertex. A vertex is not only the position.

The model you linked contains three different attributes: position (the v-tag), texture coordinate (the vt-tag) and normal (the vn-tag). These tags lists all individual position attributes, all texture coordinate attributes and all normal attributes that will be used by your your list of vertices.

Then you have the face descriptors (the f-tag). Let's take two typical lines from the file. First, "f 1/1/1 2/2/2 3/3/3". The list of triplets references each individual attribute that makes the vertex, and the tree triplets makes the three vertices in the face (the triangle in this case, since there are three vertices).

So, first, 1/1/1 means that the first vertex of the triangle is made up of the first position in the position list, the first texture coordinate in the texture coordinate list, and the first normal in the normal list. Likewise, 2/2/2 and 3/3/3 makes up two more vertices, of the second and third attribute of each corresponding list.

Then look at an example of what I think is confusing you: "f 4/4/5 3/3/6 5/5/7". It follows the very same pattern as previous example. The face is made up of three vertices, and the first vertex is made up from the fourth position, fourth texture coordinate, and the fifth normal. Likewise, the second vertex is made up of the third position, third texture coordinate, and the sixth normal.

So no vertex has two normals, but you may have two different vertices that have the same position but different normals. That is what 1/1/1 and 1/1/496 means; two vertices with the same position but different normals.

If your API does not support individual attribute indices, then you need to split and duplicate vertices. You cannot base your vertex arrays on the position attribute and attach texture coordinate and normal to each position. You have to base it on the face list, and build the vertices from there. Merging and duplicating vertices from one indexed format to another is not very difficult, but definitely a challenge if you're a beginner.

I would drop the index completely and build a flat vertex array instead. That is, load all attributes into separate arrays, load the face list, and construct a vertex array by passing over the face list and copying the attributes into the vertex array in the order determined by the face indices. When you have passed over the whole face list, you have a flat vertex array that stores the attributes in the order specified by the face list.

PARTNERS