   Best way to get vertex normals in a milkshape exporter
  Hey all, I''m trying to write a milshape exporter for my engine, but in milshape, the vertices are stored in a speperate array, and the normals can be different for the same vertex depending on which triangle is rendering it.  So, has anyone found a good way to get vretex normals out of a milkshape model?  Is the only way to do it to calc them myself>  Any help would be appreciated. 
  yeah i believe it''s the same deal for 3DS files which is what i wrote an importer for.  when i did that i read in all the vertices and normals and then found all the normals that corresponded to each vertex and averaged them to find the normal for that vertex that i''d use in my game.  that way you end up with one normal for each vertex and it looks pretty good, you get a bit of fake curvature at polygon joints which is pleasing using standard hardware T&L.instead of doing this every time at load, i developed my own binary model format and wrote a simple little .exe to convert from .3DS to my .mdl format.  that way i could optimize the format for my own purposes and have speedy run-time loading.-me ;  Vertices have more than one normal for a reason! A vertex with more than one normal lies along a smoothing group boundary, and the proper way to handle it it is to take into account which polygon you''re currently drawing.But perhaps you already knew that. Is there any reason why you want to avoid multiple normals per vertex? ;  i recently made a milkshape exporter too, i solved the problem this way: protected void ExportMesh(Mesh mesh,BinaryWriter w){//vertex format: pos3,tex2,norm3//primtype:trianglelistw.Write(mesh.GetName());w.Write(mesh.GetMaterialIndex());w.Write(mesh.GetTriangleCount()*3);for(int i=0;i<mesh.GetTriangleCount();++i){Triangle t=mesh.GetTriangleAt(i);ushort3 vi=t.GetVertexIndices();ushort3 ni=t.GetNormalIndices();for(int j=0;j<3;++j){Vertex v=mesh.GetVertexAt(vi[j]);MsVec3 n=mesh.GetVertexNormalAt(ni[j]);w.Write(v.GetVertex().x);w.Write(v.GetVertex().y);w.Write(v.GetVertex().z);w.Write(v.GetTexCoords().x);w.Write(v.GetTexCoords().y);w.Write(n.x);w.Write(n.y);w.Write(n.z);}}}this code "rolls out" the indices.of course you throw away the indexlist(is there a better solution?), so either render as a trianglelist or reindex the vertices.(better solution)   [edited by - cody on March 25, 2004 9:03:32 AM]