I want to obtain the normals of the triangles in the collada files. However, what I don’t understand is that, each vertex is assigned a normal instead of the face.
Can someone please tell me, how to obtain the normal of the triangle, from the following.
for first triangle, you have 3 vertices.
vertex 1 has 0 0 0
vertex 2 has 1 0 1
vertex 3 has 2 0 2
for each vertex, you have 3 inputs
0 0 0 means position index 0, normal index 0, texcoord index 0.
second vertex
1 0 1 means position index 1, normal index 0, texcoord index 1.
third vertex
2 0 2 means position index 2, normal index 0, texcoord index 2.
Note that all the normals of vertices that make up the first triangle have index 0.
Since all the normals of each vertices of this triangle is the same, you can kind of consider it the face normal.
I realize that this doesn’t really belong here but i figure its close enough to the current discussion that there is no reason to start a new thread.
I am currently trying to write a collada exporter in MaxScript and am having trouble figuring out how to generate the triangle primitives. I have the array of vertices and array of normals but dont understand the logic needed to create triangles by referencing them. Any help would be greatly apreciated.
format "<triangles count=\"%\">
" numfaces to:outfile
format "<input offset=\"0\" semantic=\"VERTEX\" source=\"#%-lib-vertices\" />" obname to:outfile
format "<input offset=\"1\" semantic=\"NORMAL\" source=\"#%-lib-normals\" />" obname to:outfile
format "<input offset=\"2\"/>" to:outfile
format "
" to:outfile
not sure how to generate contents of this tag
format"</p>" to:outfile
format "</triangles>" to:outfile
In uclahklaw’s post each line is a triangle with 3 vertices; each combination of the vertex format (in this case POSITION, NORMAL, TEXCOORD = 3 ints) just indexes the respective source arrays making a vertex, but you will also need to calssify TEXCOORD as being a 2d array.
I’m sorry for waking up this thread again but i feel like my question fits in here somehow,
because it already helped me a lot but there’s still something I don’t understand.
I also have troubles understanding the <triangles> tag.
I understood that there are 12 triangles. Each with 3 inputs defined in the <triangles>.
A triangle should be defined by vertices. I can’t see the three points needed for that.
Do the three numbers in this case mean:
Vertex one has POSITION 0 and NORMAL 0,
vertex two has POSITION 1 and NORMAL 1,
vertex three has POSITIN 2 and NORMAL 2?
I’d really appreciate if anyone could confirm or explain this too me.
If there are more normals than vertices and they all could not be used. Is it an error?
I downloaded this model from official Collada library, its name is “Moon Buggy”.
A “vertex” is not just a position. A vertex includes many attributes that make it unique, including position, normal, texture coordinate, color, etc… It means that your mesh has 1668 unique vertices (position + normal).
Stupid question Marcus, but as a new user I am wondering what makes a vertex coincident? I checked out the wikipedia, but would like to hear from somebody with Collada experience who could maybe simplify the definition for me.
Coincident vertices are ones that share the same position, e.g. a triangle with two vertices at the origin and one elsewhere results in a line. i.e. it’s a degenerate triangle.
The concept of coincidence can apply to all the vertex attributes (position, normal, color, texcoords, tangents, etc. etc.) if one is sorting vertices to remove all redundency from the set of vertices. Any single attribute of a vertex that is unique, that differentiates it from others for the purpose at hand, makes for a unique vertex.