title: FBX SDK Fix Indices / Draw Order C++
body: <p>I am learning some DirectX 11 tutorials. I have been using the Autodesk FBX SDK to import models into my direct x scene. But I have ran into problems with the indices aka the order in which you draw the vertices. My FBX class imports the same values as the Autodesk FBX converter.  It then  uses FbxAxisSystem to convert the scene to be compatible with DirectX, then it inverts the Z Axis, and swaps the Y and Z axis so that the rotation matches the the model in my 3D modelling program. So far so good right? except the triangles are completely out of order. Resulting in a strange looking mesh.</p>
  
  <p>I have narrowed it down to two things: either its the drawing order or its the render. I am using std::vector to store both vertex buffer and the indices buffer. To simplify the problem - my vertex layout is </p>
  
  <pre><code>{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
  </code></pre>
  
  <p>AFAIK the render is working correctly but I am not entirely sure because I find the bit width and the DrawIndex a little confusing. Here is some of the code:</p>
  
  <pre><code>// ... in the initialise function after importing the object
  indexBufferDesc.ByteWidth = sizeof(DWORD) * sizeof(Obj-&gt;MeshIndicesBuffer);
  iinitData.pSysMem = &amp;(Obj-&gt;MeshIndicesBuffer[0]);
  // ...
  vertexBufferDesc.ByteWidth = sizeof(float) * sizeof(Obj-&gt;MeshVertexBuffer);
  vertexBufferData.pSysMem = &amp;(Obj-&gt;MeshVertexBuffer[0]);
  // ... In the draw function
  DrawIndexed(Obj-&gt;MeshIndicesBuffer.size(), 0, 0);
  </code></pre>
  
  <p>Just to be clear I am using std::vector to store the buffers.</p>
  
  <p>How do fix the indices so that this draws in the correct order? Is there an formula / algorithm? Does FBX SDK have a function for this?</p>
  
  <p>I have posted on my G+ the plane I am trying to render.</p>
  
  <p><a href="https://plus.google.com/105066841304290992400/posts/LVb5VPQQxGw" rel="nofollow">https://plus.google.com/105066841304290992400/posts/LVb5VPQQxGw</a></p>
  
  <p>I understand the basic principles of rendering polygons (I can render a cube using arrays) but I don't know how the indices are generated and why this isn't drawing in the "right" order from my FBX file.</p>