1

I am trying to import in XNA an .fbx model exported with blender.

Here is my drawing code

public void Draw()
    {
        Matrix[] modelTransforms = new Matrix[Model.Bones.Count];
        Model.CopyAbsoluteBoneTransformsTo(modelTransforms);

        foreach (ModelMesh mesh in Model.Meshes)
        {
            foreach (BasicEffect be in mesh.Effects)
            {
                be.EnableDefaultLighting();
                be.World = GameCamera.World * Translation * modelTransforms[mesh.ParentBone.Index];
                be.View = GameCamera.View;
                be.Projection = GameCamera.Projection;
            }
            mesh.Draw();
        }
    }

The problem is that when I start the game some model parts are overlying others instead of being behind. I've tried to download other models from internet but they have the same problem.

chiarfe
  • 522
  • 3
  • 15
  • [here](http://gamedev.stackexchange.com/questions/37555/xna-model-parts-are-overlying-others) you can find the answer (also read comments) – chiarfe Sep 26 '12 at 14:05

1 Answers1

0

This line:

be.World = GameCamera.World * Translation * modelTransforms[mesh.ParentBone.Index];

is usually arrainged the other way around, and the order that you multiply matrices in will make the results different. Try this:

be.World = modelTransforms[mesh.ParentBone.Index] * GameCamera.World * Translation;
Steve H
  • 5,479
  • 4
  • 20
  • 26