If I have a Model that is drawn with a different effect occasionally, what is the typical approach to this?
Models have effects stored in each of their meshes, and you seem to be forced to use those.
Typically this is done:
foreach (ModelMesh mesh in model.Meshes)
{
foreach (Effect effect in mesh.Effects)
{
effect.Parameters["World"].SetValue(world);
// Other stuff related to this specific effect is done here.
}
mesh.Draw();
}
I want to be able to do this:
foreach (ModelMesh mesh in model.Meshes)
{
myEffect.CurrentTechnique.Passes[0].Apply();
mesh.Draw(); // Mesh will be drawn with "myEffect".
}
What are our options?