Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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();
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.