This project is read-only.


Triangle meshes are essential to 3D graphics. The Model class in Engine Nine can be used to display 3D models.

3D models are typically created using content creation tools such as 3Ds Max, Blender, XSI, etc. These models have to be exported to either .FBX or .X format in order to be consumed by Engine Nine. The exporters for FBX can be downloaded from Autodesk. For the .X format, we recommend Panda DirectX Exporter.

The following example shows how to create a Model in code. Notice the difference between Nine.Graphics.Model and Microsoft.Xna.Framework.Graphics.Model. Different Nine.Graphics.Model  can have it’s own transforms and material settings, but they shares the same underlying Microsoft.Xna.Framework.Graphics.Model resource.

var modelSource = Content.Load<Microsoft.Xna.Framework.Graphics.Model>("Assets/Tank");
scene.Add(new Nine.Graphics.Model(modelSource) { Transform = Matrix.CreateTranslation(10, 0, 0) });
scene.Add(new Nine.Graphics.Model(modelSource) { Transform = Matrix.CreateTranslation(-10, 0, 0) });


Model Material

Materials define the look and feel of a graphics object. To assign a material to a model, set the materials property of the model:


<Model Source="{ContentReference Assets/Tank}" Material="{EnvironmentMapMaterial EnvironmentMap={ContentReference Assets/Glacier}}" />


Even if the texture is not specify for the material, the material will still pick the textures compiled with the model asset (including diffuse texture, normal map and specular maps). This behavior can be toggled using the UseModelTextures property on both the whole model or each model mesh.


<Model Source="{ContentReference Assets/Tank}" Material="{EnvironmentMapMaterial EnvironmentMap={ContentReference Assets/Glacier}}" UseModelTexture="False" />


A model typically contains a lot of meshes represented using ModelMesh class. Each model mesh can be assigned a unique material by explicitly setting the materials on the ModelMesh in the right order:


<Model Source="{ContentReference Assets/Tank}">
        <ModelMesh Material="{BasicMaterial LightingEnabled=False}" />
        <ModelMesh Material="{EnvironmentMapMaterial EnvironmentMap={ContentReference Assets/Glacier}}" />
        <ModelMesh />
        <ModelMesh />
        <ModelMesh />
        <ModelMesh Material="{BasicMaterial Alpha=0.5}" />


Material Level of Detail (LOD)

To improve performance, models further away from the camera are typically drawn using lower quality materials. The MaterialLevels property provides a way to automatically adjust the material quality based on the distance from the model to the camera. The materials inside MaterialLevelOfDetail is ordered from the lowest quality to the highest quality. If material LOD is enabled, the Material property will be ignored.


<Model Source="{ContentReference Assets/Tank}">
        <MaterialLevelOfDetail LevelOfDetailStart="1" LevelOfDetailEnd="100" >
            <BasicMaterial LightingEnabled="False" />
            <EnvironmentMapMaterial EnvironmentMap="{ContentReference Assets/Glacier}" />


Skeleton Animation

3D models are typically animated using a technique called skeleton animation. To use skeleton animation, the input model has to be processed by “Model – Engine Nine”, and the material used by the model has to support GPU skinning.


<Model Source="{ContentReference Assets/Dude}" Material="{SkinnedMaterial }" />


The playback of skeleton animation is controlled using the BoneAnimation class. BoneAnimation supports the ability to easily blend, clip, combine multiple bone animation tracks. It also supports the ability to add custom animation controllers like IK controllers and ragdoll controllers. The Xbox version also supports Xbox Live Avatar animations.

Last edited Sep 25, 2012 at 1:21 PM by yufeih, version 7


No comments yet.