I'm quite new to working with 3D objects. I'm currently trying to get one to load in Monogame. The object itself was imported into Blender and exported as an fbx file (which was the only file type I could get the new content pipeline to work with).
The command to load the model is here:
var _model = content.Load<Microsoft.Xna.Framework.Graphics.Model>("Ship");
And the code to draw it is:
public override void Draw(IDrawParameters p)
{
// Copy any parent transforms.
Matrix[] transforms = new Matrix[_model.Bones.Count];
_model.CopyAbsoluteBoneTransformsTo(transforms);
// Draw the model. A model can have multiple meshes, so loop.
foreach (ModelMesh mesh in _model.Meshes)
{
// This is where the mesh orientation is set, as well
// as our camera and projection.
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationX(_modelRotation) *
Matrix.CreateRotationY(_modelRotation);
effect.View = Matrix.CreateLookAt(eye, Vector3.Zero,
Vector3.Up);
effect.Projection = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(45.0f), _aspectRatio, 1.0f, 10000.0f);
}
// Draw the mesh, using the effects set above.
mesh.Draw();
}
base.Draw(p);
}
I've tried a number of variations of the draw code, mostly taken from the web. However, whatever I try, I get nothing appearing on the screen - no error, but nothing on the screen.
Is there anything specific in the code below that might cause this; or, is there a possibility that the content.Load
didn't work, but it just didn't tell me?
UPDATE
More than one of the answers below are correct in my case. The first problem that I had was the transform:
effect.World = transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationX(_modelRotation) *
Matrix.CreateRotationY(_modelRotation);
The second issue was with the Alpha flag; both of these together made it show, but only because I'd written a routine to change the eye position - the original rendering was inside the object.
eye
as you call it in your code, other than that, the code seems fine to me. \$\endgroup\$