I'm trying to render a mesh but I'm not getting anything on the screen. To render I'm using:
public void DrawModel(Vector3 pos, Vector3 rotation)
{
boneTransforms = new Matrix[Character.Model.Bones.Count];
Character.Model.Root.Transform = Matrix.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z) *
Matrix.CreateScale(.8f) *
Matrix.CreateTranslation(pos);
Character.Model.CopyAbsoluteBoneTransformsTo(boneTransforms);
foreach (ModelMesh mesh in Character.Model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.World = boneTransforms[mesh.ParentBone.Index];
effect.View = Session.TileEngine.Camera.CameraViewMatrix;
effect.Projection = Session.TileEngine.Camera.CameraProjectionMatrix;
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
}
mesh.Draw();
}
}
with CameraViewMatrix and CameraProjectionMatrix being:
cameraViewMatrix = Matrix.CreateLookAt(
new Vector3(Game1.BackBufferWidth / 2, Game1.BackBufferHeight / 2, 0),
new Vector3(Game1.BackBufferWidth / 2, Game1.BackBufferHeight / 2, -200),
Vector3.Up);
_cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(45.0f), //how wide the camera sees
((float)(Game1.BackBufferWidth))/((float)(Game1.BackBufferHeight)),
1.0f, //near clipping plane
10000.0f); //far clipping plane
I've used code similar this to render meshes before, so I'm not sure what the problem is.