/// <summary> /// The draw with technique. /// </summary> /// <param name="effect"> /// The effect. /// </param> /// <param name="technique"> /// The technique. /// </param> public override void DrawWithEffect(ShaderManager.EFFECT_ID effect, string technique) { // code from Riemers XNA tutorial foreach (ModelMesh mesh in this.ObjectModel.Meshes) { int count = 0; foreach (ModelMeshPart mmp in mesh.MeshParts) { if (count < this.ModelTextures.Count) { ShaderManager.SetValue("Texture", this.ModelTextures[count++]); } if (effect == ShaderManager.EFFECT_ID.STATICMODEL) { ShaderManager.SetValue("isGround", this is Ground); } ShaderManager.SetValue("life", Hero.GetHeroLife()); ShaderManager.SetValue("World", this.World); ShaderManager.CommitChanges(); mmp.Effect = ShaderManager.GetEffect(effect); } foreach (Effect e in mesh.Effects) { e.CurrentTechnique = e.Techniques[technique]; } mesh.Draw(); } }
/// <summary> /// The draw with technique. /// </summary> /// <param name="effect"> /// The effect. /// </param> /// <param name="technique"> /// The technique. /// </param> public override void DrawWithEffect(ShaderManager.EFFECT_ID effect, string technique) { int count = 0; // code from Riemers XNA tutorial foreach (ModelMesh mesh in this.ObjectModel.Meshes) { foreach (ModelMeshPart mmp in mesh.MeshParts) { mmp.Effect.Dispose(); mmp.Effect = ShaderManager.GetEffect(effect).Clone(this.scene.Game.GraphicsDevice); } foreach (Effect e in mesh.Effects) { e.CurrentTechnique = e.Techniques[technique]; e.Parameters["Texture"].SetValue(this.ModelTextures[count++]); e.Parameters["life"].SetValue(Hero.GetHeroLife()); e.Parameters["World"].SetValue(this.World); e.Parameters["Bones"].SetValue(this.AnimationPlayer.GetSkinTransforms()); e.CommitChanges(); } mesh.Draw(); } }