0

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.

Daniel Samson
  • 718
  • 4
  • 18
  • What cull mode setting are you using for your rasterizer object? ``D3D11_CULL_FRONT``, ``D3D11_CULL_BACK``, or ``D3D11_CULL_MODE``. Make sure your [face winding order](http://stackoverflow.com/questions/23790272/vertex-winding-order-in-dx11) is consistent. – Chuck Walbourn Oct 28 '14 at 07:06
  • It's D3D11_CULL_NONE - For debug purposes. I plan to change this once I have removed all the problems of importing data from fbx. I think this should be set to D3D11_CULL_FRONT since that more closely matches the model on my 3D modelling app. But it doesn't change the indices order and thus in the case of a plane it will only show the right triangle for the plane. – Daniel Samson Oct 28 '14 at 11:17
  • Is it common for polygons to not have the same winding within a single mesh? I thought that the winding would be the same. – Daniel Samson Oct 28 '14 at 12:50

0 Answers0