コード例 #1
0
ファイル: Animation.cs プロジェクト: AD-7/PBL_Game
        public void SetEffect(Effect effect, bool copy)
        {
            for (int i = 0; i < animation.Count; i++)
            {
                foreach (ModelMesh mesh in animation[i].Meshes)
                {
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        Effect toSet = effect;
                        if (copy)
                        {
                            toSet = effect.Clone();
                        }


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

                        if (tag.Texture != null)
                        {
                            setEffectParameter(toSet, "xTexture", tag.Texture);
                        }
                        else
                        {
                        }

                        part.Effect = toSet;
                    }
                }
            }
        }
コード例 #2
0
        private void GenerateMeshTag()
        {
            foreach (ModelMesh mesh in Model.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    MeshTag tag = new MeshTag();

                    tag.Color   = (part.Effect as BasicEffect).DiffuseColor;
                    tag.Texture = (part.Effect as BasicEffect).Texture;

                    part.Tag = tag;
                }
            }
        }
コード例 #3
0
 private void GenerateTags()
 {
     foreach (var mesh in Model.Meshes)
     {
         foreach (var part in mesh.MeshParts)
         {
             if (part.Effect is BasicEffect)
             {
                 var effect = (BasicEffect)part.Effect;
                 var tag    = new MeshTag(effect.DiffuseColor, effect.Texture, effect.SpecularPower);
                 part.Tag = tag;
             }
         }
     }
 }
コード例 #4
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;
             }
         }
     }
 }
コード例 #5
0
ファイル: Animation.cs プロジェクト: AD-7/PBL_Game
 public void generateTags()
 {
     for (int i = 0; i < animation.Count; i++)
     {
         foreach (ModelMesh mesh in animation[i].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;
                 }
             }
         }
     }
 }
コード例 #6
0
        public void SetMeshEffect(string meshName, Effect effect, bool copyEffect)
        {
            foreach (ModelMesh mesh in _model.Meshes)
            {
                if (mesh.Name != meshName)
                {
                    continue;
                }

                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;
                }
            }
        }
コード例 #7
0
ファイル: CustomModel.cs プロジェクト: ExQuid/World_of_Wealth
        /// <summary>
        /// </summary>
        /// <param name="effect"></param>
        /// <param name="copyEffect"></param>
        public void SetModelEffect(Effect effect, bool copyEffect)
        {
            // Loops through the model meshes and then loop through all parts of that mesh
            foreach (ModelMesh mesh in Model.Meshes)
            {
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    // Checks if the effect should copy the effect or change the origin
                    Effect preperedEffect = copyEffect ? effect.Clone() : effect;

                    // Sets the meshtag
                    MeshTag tag = (MeshTag)meshPart.Tag;

                    // Checks if the texture is null
                    if (tag.Texture != null)
                    {
                        // Sets the texture
                        SetEffectParameter(preperedEffect, "BasicTexture", tag.Texture);

                        // Sets the Texture Enabled to true
                        SetEffectParameter(preperedEffect, "TextureEnabled", true);
                    }
                    else
                    // Sets the  Texture Enabled to false inside the effect
                    {
                        SetEffectParameter(preperedEffect, "TextureEnabled", false);
                    }

                    // Sets the rest of the parameters
                    SetEffectParameter(preperedEffect, "DiffuseColor", tag.Color);
                    SetEffectParameter(preperedEffect, "SpecularPower", tag.SpecularPower);



                    // Applies the effect
                    meshPart.Effect = preperedEffect;
                }
            }
        }
コード例 #8
0
 public 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;
             }
             else
             {
                 Effect cacheEffect = part.Effect;
                 MeshTag tag = new MeshTag(
                     cacheEffect.Parameters["LightColor"].GetValueVector3(),
                     cacheEffect.Parameters["Texture"].GetValueTexture2D(),
                     cacheEffect.Parameters["SpecularPower"].GetValueSingle());
                 part.Tag = tag;
             }
 }
コード例 #9
0
ファイル: ModelInstance.cs プロジェクト: BaronVonTeapot/Basic
 /// <summary>
 /// Creates a tag object for each ModelMeshPart in the Model, which can
 /// be used to store effects and other useful rendering data.
 /// </summary>
 public virtual void GenerateTags()
 {
     foreach (ModelMesh mesh in this.Model.Meshes)
     {
         foreach (ModelMeshPart meshPart in mesh.MeshParts)
         {
             if (meshPart.Effect is BasicEffect)
             {
                 BasicEffect tempEffect = (BasicEffect)meshPart.Effect;
                 MeshTag meshTag = new MeshTag(tempEffect.DiffuseColor, tempEffect.Texture,
                                               tempEffect.SpecularPower);
                 meshPart.Tag = meshTag;
             }
         }
     }
 }