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.
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
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
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:
// ... in the initialise function after importing the object
indexBufferDesc.ByteWidth = sizeof(DWORD) * sizeof(Obj->MeshIndicesBuffer);
iinitData.pSysMem = &(Obj->MeshIndicesBuffer[0]);
// ...
vertexBufferDesc.ByteWidth = sizeof(float) * sizeof(Obj->MeshVertexBuffer);
vertexBufferData.pSysMem = &(Obj->MeshVertexBuffer[0]);
// ... In the draw function
DrawIndexed(Obj->MeshIndicesBuffer.size(), 0, 0);
Just to be clear I am using std::vector to store the buffers.
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?
I have posted on my G+ the plane I am trying to render.
https://plus.google.com/105066841304290992400/posts/LVb5VPQQxGw
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.