DirectX Export Script for Blender v. 2.71 I recently downloaded the newest version of Blender(v 2.71). I immediately encountered a problem when exporting my models to DirectX format(.x). The new export script tries to minimize the file size( I assume this is the reason ) and in so doing has created the need to rewrite the X file importer for my application.

The file now has a single reference for each position, and a single reference for each normal. For a cube the file looks like this:

Mesh Cube { // Cube mesh
      8;
       1.000000; 1.000000;-1.000000;,
       1.000000;-1.000000;-1.000000;,
      -1.000000;-1.000000;-1.000000;,
      -1.000000; 1.000000;-1.000000;,
       1.000000; 0.999999; 1.000000;,
       0.999999;-1.000001; 1.000000;,
      -1.000000;-1.000000; 1.000000;,
      -1.000000; 1.000000; 1.000000;;
      12;
      3;1,2,3;,
      3;7,6,5;,
      3;0,4,5;,
      3;1,5,6;,
      3;6,7,3;,
      3;0,3,7;,
      3;0,1,3;,
      3;4,7,5;,
      3;1,0,5;,
      3;2,1,6;,
      3;2,6,3;,
      3;4,0,7;;
      MeshNormals { // Cube normals
        12;
         0.000000;-0.000000;-1.000000;,
         0.000000;-0.000000; 1.000000;,
         1.000000;-0.000001;-0.000000;,
        -0.000000;-1.000000;-0.000000;,
        -1.000000; 0.000000;-0.000000;,
         0.000000; 1.000000; 0.000000;,
         0.000000; 0.000000;-1.000000;,
        -0.000000;-0.000000; 1.000000;,
         1.000000; 0.000000; 0.000000;,
        -0.000000;-1.000000; 0.000000;,
        -1.000000; 0.000000;-0.000000;,
         0.000000; 1.000000; 0.000000;;
        12;
        3;0,0,0;,
        3;1,1,1;,
        3;2,2,2;,
        3;3,3,3;,
        3;4,4,4;,
        3;5,5,5;,
        3;6,6,6;,
        3;7,7,7;,
        3;8,8,8;,
        3;9,9,9;,
        3;10,10,10;,
        3;11,11,11;;
      } // End of Cube normals


Notice that the positions and normals are no longer in a 1-to-1 correspondence. This means that in my application I must map the normals to the appropriate positions...not difficult. The problem is that I must execute a vertex splitting algorithm for each mesh I import. There are only 8 vertices referenced for 12 faces and each face has a different normal...Vertices cannot be shared if their normals are different. My application expects 36 vertices;
3 per face(12 faces for a cube).

For a cube, the algorithm isn't too bad but for an entire scene a splitting algorithm can take quite some time. Furthermore, on occasion the entire scene may need to be reloaded upon events such as 'lost' device. This is undesirable behavior.

My question is this: Should an X file be formatted in this manner? It makes the file smaller but increases the load time of each mesh. The X files in the DirectX SDK all have 1:1 correspondence between positions and normals...

I can customize the script of course...I just want to know about the X file format...
The x file makes sense, it has a 1 to 1 correspondence of vertex to normals. If you use smooth shading, you should fix your rendering code.

The rendering code:
1. Upload vertices array , normals array and  UV's array.


Draw triangles using the vertex indexes provided


It's rather simple, look here:
http://www.songho.ca/opengl/gl_vertexarray.html