Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ModelMeshPart.Effect Property

Gets or sets the material Effect for this mesh part.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public Effect Effect { get; set; }

Property Value

The material effect for this mesh part.

ModelMesh.Effects is a shortcut for iterating over the MeshParts property of the ModelMesh and looking up the ModelMeshPart.Effect property of each ModelMeshPart.

ModelMesh.Effects is a collection of all the Effect properties of the for the MeshParts of this ModelMesh. Each ModelMeshPart has a single Effect which is a reference to one of the Effects of the parent ModelMesh property. By updating all the effects of the ModelMesh all of the effects of each ModelMeshPart are updated as well.

The Effect property can be used to assign a custom Effect to a model loaded with BasicEffect.

public static void RemapModel(Model model, Effect effect)
{
    foreach (ModelMesh mesh in model.Meshes)
    {
        foreach (ModelMeshPart part in mesh.MeshParts)
        {
            part.Effect = effect;
        }
    }
}

Xbox 360, Windows XP SP2, Windows Vista

Community Additions

ADD
Show:
© 2015 Microsoft