In the XNA 3D Model is generally Autodesk Company's FBX format. The Load method is basically the same as the 2D, but it is very different when drawing.
A Load:
protected override void LoadContent()
{
tankModel = Content.Load<Model>("tank");//载入fbx model
tankBonesTransforms = new Matrix[tankModel.Bones.Count];//创建一个model的boneTransform数组,用来保存所有的model boneTransform.
}
Two Draw:
Tankmodel.copyabsolutebonetransformsto (tankbonestransforms)//Copy the Bonetransform in model to the array, prepare for drawing
Matrix projection = Matrix.createperspectivefieldofview (Mathhelper.piover4, GraphicsDevice.Viewport.AspectRatio, 10, 20000);//Create a projection matrix
Matrix view = Matrix.createlookat (new Vector3 (1500, 0) * 1 + new Vector3 (0, 0), new Vector3 (0,, 0), Vector3. up);//Create a view matrix to convert world coordinates to camera coordinates
foreach (Modelmesh m in tankmodel.meshes)//Start drawing each object in world coordinates
{
foreach (Basiceffect e in m.effects)
{
E.world = Tankbonestransforms[m.parentbone.index];
E.view = View;
E.projection = projection;
E.lightingenabled = true;
E.specularcolor = new Vector3 (0.8f, 0.8f, 0.6f);
E.specularpower = 16;
E.textureenabled = true;
}
M.draw ()///Use the Draw method in Modelmesh to draw instead of using the Draw method in SpriteBatch
Sample Download Address: http://www.52winphone.com/bbs/viewthread.php?tid=282&extra=page%3D1