Learn WP7 XNA Game development (six 3d model loading)

Source: Internet
Author: User
Tags foreach
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.