# Models from 3ds max lose their transformations when input into XNA

I am making models in 3ds max. However when I export them to .fbx format and then input them into XNA, they lose their scaling. It is most likely something to do with not using the transforms from the model correctly.

Is the following code correct using XNA 3.0?

Matrix[] transforms = new Matrix[playerModel.Bones.Count];
playerModel.CopyAbsoluteBoneTransformsTo(transforms);

// Draw the model.
foreach (ModelMesh mesh in playerModel.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.World =
transforms[mesh.ParentBone.Index] *
Matrix.CreateScale(Vector3.One*20) *
Matrix.CreateTranslation(position);

effect.View = view;
effect.Projection = projection;
}
mesh.Draw();
}


It also seems to work if I export it in .obj format, which is probably vertex only format, then import it back into 3ds max and then export it to .fbx for XNA.

Here's an image reference in case you don't understand what I am saying. The left is in XNA and the right in 3ds max.

• Can you confirm where the loss is happening? Is it the export stage or the import stage? Is is the scaling or the transformations (your title and body conflict)? – MichaelHouse Oct 9 '12 at 22:10
• What do you mean, the models lose their scaling? Ideally yoour models shouldn't be scaled at all when exporting. Do an XForm Reset, or Reset Scale in the Hierarchy panel, then your model should be at 100% scale. – user13213 Oct 10 '12 at 6:31

When exporting, the model data is exported and the transformation data is also exported, they are not baked into each other.

I've seen many folks forget to take into account the transformation data when loading their models into Xna.

If you are properly using a transform array populated by the CopyAbsoluteBoneTransformsTo method then you are using the transformation data (including scale), but not going about it properly would result in a problem you are describing.

If you think this may be a clue, then post your code and we can see if you are coding it properly.

• Thank you. You seem to know whats my problem.I uploaded my code. – jacobian Oct 13 '12 at 21:56
• i'm using "CopyAbsoluteBoneTransformsTo()" i don't know if its the same thing.I can't find "CopyAbsoluteTransformsTo()" – jacobian Oct 13 '12 at 23:24
• That's the one I meant: CopyAbsoulteBoneTransformsTo. Instead of using a count variable to index the transforms array, most folks use mesh.ParentBone.Index. I'm not sure it would make a difference but it would be a smidgen safer. Otherwise it appears you are taking the transformation data imported with the model correctly. – Steve H Oct 14 '12 at 22:36
• another thing that would be safer is when setting up your transform array is to use playerModel.Bones.Count instead of playerModel.Meshes.Count. The model often contains one more Bone matrix than the number of meshes. It's the root transform and it's data gets applied to all transforms during the CopyAbsoluteBoneTransformsTo method. What I'm seeing, your code should be taking that into account but I can't be sure without debugging it. So play it safe and use standard methodologies. – Steve H Oct 14 '12 at 22:59
• Oh yes,thanks. I did change that ,i should have updated my code above.I will do that now. However i am still having the same problem. – jacobian Oct 15 '12 at 19:06

The best solution i found was to reset the xform, In 3ds max

1. In the utilities panel goto "Reset Xform"
2. Then with the model selected click "Reset Selected"

from what i understand reset xform places the mdels transformations in a separate modifier called "xform"

However i still dont understand why xna was unable to just get the transformations from the model