I'm making a game in XNA 4.0 and I really don't understand the effect and basiceffect stuff.
I currently have this:
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
if (mesh.Name != collisionShapeName)
{
effect.TextureEnabled = true;
effect.Texture = _textures[name];
effect.SpecularColor = new Vector3(_specularColor);
effect.SpecularPower = 32;
}
}
}
And I have found a tutorial for rendering shadow and I need to apply this code on mine:
foreach (ModelMesh mesh in model.Meshes)
{
foreach (ModelMeshPart part in mesh.MeshParts)
part.Effect = material.effect;
}
So I put this code before my foreach (BasicEffect effect in mesh.Effects)
, but it doesn't work, here's the error thrown on this line foreach (BasicEffect effect in mesh.Effects)
:
Unable to cast object of type 'Effect' to type 'BasicEffect'.
I'm really lost here...