2
\$\begingroup\$

I downloaded the FBX of this free model:

http://www.turbosquid.com/FullPreview/Index.cfm/ID/485548

Yet when i try and display it in my project

foreach (ModelMesh mesh in player.Meshes)
{
    foreach (BasicEffect beffect in mesh.Effects)
    {
        beffect.View = view;
        beffect.Projection = projection;
        beffect.EnableDefaultLighting();
    }
    mesh.Draw();
}

I end up with the teeth of the model way out from the body, and the eyes expanded so large they stick out the sides of the model.

Could someone tell me what i am doing wrong? Or is the model the issue?

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Try to set World matrix to BasicEffect, this drawing code should work:

Matrix baseWorld = Matrix.CreateScale(1) * Matrix.CreateRotationX(0) * Matrix.CreateTranslation(new Vector3(0,0,0));
Matrix[] modelTransforms=new Matrix[player.Bones.Count];
player.CopyAbsoluteBoneTransformsTo(modelTransforms);

foreach (ModelMesh mesh in player.Meshes)
{
    Matrix localWorld = modelTransforms[mesh.ParentBone.Index] * baseWorld;
    foreach (BasicEffect beffect in mesh.Effects)
    {
        beffect.View = view;
        beffect.Projection = projection;
        beffect.World = localWorld;
        beffect.EnableDefaultLighting();
    }
    mesh.Draw();
}
\$\endgroup\$

You must log in to answer this question.

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