FBX Importer for DirectX

Not applicable
08-07-2015
05:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to import an fbx file into my managed DirectX application. The problem I'm having is importing a skinned mesh.
The transformation of my mesh during animation is incorrect. The mesh appears to rotate around the wrong axis. The mesh in question is a simple mesh containing 3 cubes. Each of these cubes should rotate around the 'Up' axis. Instead they are rotating around the 'Look' axis. Here is screenshot:
I am converting the fbx transform data like so:
// skin info SkinInfo si = new SkinInfo(ncVertices, vertexElements.ToArray(), ncBones); // inst. bone offsets array Matrix[] boneOffsets = new Matrix[ncBones]; // inst. bone matrices lookup array GDEFrame[] boneMatricesLookup = new GDEFrame[ncBones]; foreach(FBXDeformer child in model.Deformer.Children) { // set bone name si.SetBoneName(nc, child.Frame.Name); // compute inverse bind pose transform( inverse transform link * bone transform * geometry transform ) Matrix m = Matrix.Transpose(Matrix.Invert(child.TransformLink) * child.Transform) * model.Frame.TransformationMatrix; // set offset matrix( used to transform vertices si.SetBoneOffsetMatrix(nc, boneOffsets[nc] = m); // set bone influences si.SetBoneInfluence(nc, child.Indices.ToArray(), child.Weights.ToArray()); // set bone matrices lookup frame boneMatricesLookup[nc] = child.Frame; // inc. counter nc++; } // set skin info smc.SetSkinInfo(si) .SetMaxVertexInfluences(si.MaximumVertexInfluences) .SetBoneOffsets(boneOffsets) .SetMatrixPalette(boneMatricesLookup);
How do I correctly convert the fbx transforms?