2
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ 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)? \$\endgroup\$
    – House
    Oct 9, 2012 at 22:10
  • \$\begingroup\$ 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. \$\endgroup\$
    – user13213
    Oct 10, 2012 at 6:31

2 Answers 2

0
\$\begingroup\$

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.

\$\endgroup\$
5
  • \$\begingroup\$ Thank you. You seem to know whats my problem.I uploaded my code. \$\endgroup\$
    – jacobian
    Oct 13, 2012 at 21:56
  • \$\begingroup\$ i'm using "CopyAbsoluteBoneTransformsTo()" i don't know if its the same thing.I can't find "CopyAbsoluteTransformsTo()" \$\endgroup\$
    – jacobian
    Oct 13, 2012 at 23:24
  • \$\begingroup\$ 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. \$\endgroup\$
    – Steve H
    Oct 14, 2012 at 22:36
  • \$\begingroup\$ 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. \$\endgroup\$
    – Steve H
    Oct 14, 2012 at 22:59
  • \$\begingroup\$ 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. \$\endgroup\$
    – jacobian
    Oct 15, 2012 at 19:06
0
\$\begingroup\$

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .