XNA How To: Draw a Model with a Custom Effect
2013-05-19 13:01
316 查看
Drawing a Model With a Custom Effect
When you load a Model, the model is set by default to use the BasicEffect.You can change this by customizing the content pipeline, or you can apply a newEffect to
the Model when you load the Model.
To draw a model with a custom effect
In your game's LoadContent method, load your Model,typically using the ContentManager.
C#
terrain = Content.Load<Model>("terrain");
In LoadContent, load your Effect,
typically using the ContentManager.
C#
MyEffect = content.Load<Effect>("CustomEffect");
Iterate through each ModelMeshPart in your model, and assign your Effect to
the Effect property of the ModelMeshPart.
C#
public static void RemapModel(Model model, Effect effect) { foreach (ModelMesh mesh in model.Meshes) { foreach (ModelMeshPart part in mesh.MeshParts) { part.Effect = effect; } } }
Draw the Model, using the steps outlined in How
To: Render a Model with one exception: instead of using BasicEffect, use the Effect attached
to the model.
C#
foreach (ModelMesh mesh in terrain.Meshes) { foreach (Effect effect in mesh.Effects) { mesh.Draw(); } }
相关文章推荐
- How to create a custom action type with a custom control (BarCheckItem), associated with it
- How to integrate custom security policy with Windows domain authentication in ASP.NET
- How To Draw Graphs with Core Plot, Part 1
- Review:how to draw a mesh in xna
- FCKEditor 2.x: How to add a new button with custom javascript to the toolbar
- How To Draw Graphs with Core Plot, Part 2
- How to use isInEditMode() to see layout with custom View in the editor
- How To Draw Graphs with Core Plot, Part 2
- [How to] Make custom search with Nutch(v 1.0)?(转)
- how to draw a sphere with opengl
- How To Embedded StyleSheet File with Custom Control.
- How to Draw with HTML 5 Canvas
- How to Make Custom Drawn Gradient Backgrounds in a Grouped UITableView with Core Graphics
- How To Embedded StyleSheet File with Custom Control.
- [原] XAF How to implement a custom attribute to customize the Application Model
- Auto Complete Tutorial for iOS: How To Auto Complete With Custom Values
- How to Make Custom Drawn Gradient Backgrounds in a Grouped UITableView with Core Graphics
- How to replace a Django model field with a property
- How to create fully custom Role, User, Event, Resource classes for use with the Security and Scheduler modules
- HOW TO Load a Custom Script with Dependencies