ModelMeshPart.Effect Property

Gets or sets the material Effect for this mesh part.

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

Syntax

public Effect Effect { get; set; }

Property Value

The material effect for this mesh part.

Remarks

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.

Example

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;
        }
    }
}

See Also

Reference

ModelMeshPart Class
ModelMeshPart Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP