Hi yall
I'm trying to extract the mesh data from an M2 in order to process it in another 3D-app (Blender). Since there is no working importer for Blender yet, I want to write it ...
I've read the stuff in the Wiki about the format of the M2 and SKIN files and when I extract it the way I think I should, I get the right vertices but the wrong faces.
Here's what I do:
1. Open the M2 and get the count (@0x40) and offset (@0x3c) of the vertex list
2. Read in all the vertices 0-n (position @ofs +i*48 and normal @ofs + i*48+0x14)
This gives me the complete vertex list and it looks correct (if I plot them on the screen, the shape is recognizable).
Now I try to get the mesh data from the associated SKIN file (00 for now):
1. Open the SKIN and get the count (@0x04) and offset (@0x0of the vertexindeces list
2. Read all the vertexindices 0-n (vertexindex @ofs + i*2)
3. Get the count (@0x0c) and offset (@0x10) of the triangles
4. Read all the triangles 0-[n/3] (vertexindex1 @ofs + i*6, vertexindex2 @ofs + i*6 +2, vertexindex3 @ofs + i*6 + 4)
Now I iterate through all the triangles and build the "real" triangles by using the 3 vertexindices of each triangle to look up the vertexindex in skin vertexindices list and then taking that to lookup the (final) vertex in the m2 vertexlist.
When rendering, this looks... weird...
What am I missing?
Cheers
Hamu