private bool SetMorphProgress(float progress, string morphName)
 {
     if (!Morphs.ContainsKey(morphName)) return false;
     MaterialMorphData data = Morphs[morphName];
     foreach (var materialMorphOffset in data.Morphoffsets)
     {
         if (materialMorphOffset.MaterialIndex == -1)
         {
             foreach (var pmxSubset in model.SubsetManager.Subsets)
             {
                 MaterialInfo matInfo = pmxSubset.MaterialInfo;
                 matInfo = materialMorphOffset.OffsetCalclationType == 0 ? matInfo.MulMaterialInfo : matInfo.AddMaterialInfo;//0の場合は対象を乗算、1なら対象を加算にセット
                 matInfo.DiffuseColor += materialMorphOffset.Diffuse*progress;
                 matInfo.AmbientColor += new Vector4(materialMorphOffset.Ambient, 1f) * progress;
                 matInfo.SpecularColor += new Vector4(materialMorphOffset.Specular, 1f) * progress;
                 matInfo.SpecularPower += materialMorphOffset.SpecularCoefficient * progress;
                 matInfo.EdgeColor += materialMorphOffset.EdgeColor * progress;
             }
         }
         else
         {
             MaterialInfo matInfo = model.SubsetManager.Subsets[materialMorphOffset.MaterialIndex].MaterialInfo;
             matInfo=materialMorphOffset.OffsetCalclationType==0?matInfo.MulMaterialInfo:matInfo.AddMaterialInfo;//0の場合は対象を乗算、1なら対象を加算にセット
             matInfo.DiffuseColor += materialMorphOffset.Diffuse * progress;
             matInfo.AmbientColor += new Vector4(materialMorphOffset.Ambient, 1f) * progress;
             matInfo.SpecularColor += new Vector4(materialMorphOffset.Specular, 1f) * progress;
             matInfo.SpecularPower += materialMorphOffset.SpecularCoefficient * progress;
             matInfo.EdgeColor += materialMorphOffset.EdgeColor * progress;
         }
     }
     return true;
 }
Example #2
0
        private bool SetMorphProgress(float progress, string morphName)
        {
            if (!this.Morphs.ContainsKey(morphName))
            {
                return(false);
            }
            MaterialMorphData data = this.Morphs[morphName];

            foreach (var materialMorphOffset in data.Morphoffsets)
            {
                if (materialMorphOffset.MaterialIndex == -1)
                {
                    foreach (var pmxSubset in this.model.SubsetManager.Subsets)
                    {
                        MaterialInfo matInfo = pmxSubset.MaterialInfo;
                        matInfo = materialMorphOffset.OffsetCalclationType == 0 ? matInfo.MulMaterialInfo : matInfo.AddMaterialInfo;//Multiply the 0, 1 set for addition
                        matInfo.DiffuseColor  += materialMorphOffset.Diffuse * progress;
                        matInfo.AmbientColor  += new Vector4(materialMorphOffset.Ambient, 1f) * progress;
                        matInfo.SpecularColor += new Vector4(materialMorphOffset.Specular, 1f) * progress;
                        matInfo.SpecularPower += materialMorphOffset.SpecularCoefficient * progress;
                        matInfo.EdgeColor     += materialMorphOffset.EdgeColor * progress;
                    }
                }
                else
                {
                    MaterialInfo matInfo = this.model.SubsetManager.Subsets[materialMorphOffset.MaterialIndex].MaterialInfo;
                    matInfo = materialMorphOffset.OffsetCalclationType == 0?matInfo.MulMaterialInfo:matInfo.AddMaterialInfo;//Multiply the 0, 1 set for addition
                    matInfo.DiffuseColor  += materialMorphOffset.Diffuse * progress;
                    matInfo.AmbientColor  += new Vector4(materialMorphOffset.Ambient, 1f) * progress;
                    matInfo.SpecularColor += new Vector4(materialMorphOffset.Specular, 1f) * progress;
                    matInfo.SpecularPower += materialMorphOffset.SpecularCoefficient * progress;
                    matInfo.EdgeColor     += materialMorphOffset.EdgeColor * progress;
                }
            }
            return(true);
        }