示例#1
0
        public void SetModelEffect(Effect effect, bool CopyEffect)
        {
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    Effect toSet = effect;
                    // Copy the effect if necessary
                    if (CopyEffect)
                    {
                        toSet = effect.Clone();
                    }

                    MeshTag tag = ((MeshTag)part.Tag);

                    // If this ModelMeshPart has a texture, set it to the effect
                    if (tag.Texture != null)
                    {
                        setEffectParameter(toSet, "BasicTexture", tag.Texture);
                        setEffectParameter(toSet, "TextureEnabled", true);
                    }
                    else
                    {
                        setEffectParameter(toSet, "TextureEnabled", false);
                    }

                    // Set our remaining parameters to the effect
                    setEffectParameter(toSet, "DiffuseColor", tag.Color);
                    setEffectParameter(toSet, "SpecularPower", tag.SpecularPower);

                    part.Effect = toSet;
                }
            }
        }
示例#2
0
 private void generateTags()
 {
     foreach (ModelMesh mesh in model.Meshes)
     {
         foreach (ModelMeshPart part in mesh.MeshParts)
         {
             if (part.Effect is BasicEffect)
             {
                 BasicEffect effect = (BasicEffect)part.Effect;
                 MeshTag     tag    = new MeshTag(effect.DiffuseColor, effect.Texture,
                                                  effect.SpecularPower);
                 part.Tag = tag;
             }
         }
     }
 }
示例#3
0
 private void generateTags()
 {
     foreach (ModelMesh mesh in model.Meshes)
         foreach (ModelMeshPart part in mesh.MeshParts)
             if (part.Effect is BasicEffect)
             {
                 BasicEffect effect = (BasicEffect)part.Effect;
                 MeshTag tag = new MeshTag(effect.DiffuseColor, effect.Texture,
                 effect.SpecularPower);
                 part.Tag = tag;
             }
 }