示例#1
0
        public static List <AnimParam> GetAvatarFaceParamaters(List <SkinnedMesh> skinnedMeshList)
        {
            var animParamList = new List <AnimParam>();

            for (int skinnedMeshIndex = 0; skinnedMeshIndex < skinnedMeshList.Count; skinnedMeshIndex++)
            {
                IFaceEmotionSkinnedMesh skinnedMesh = skinnedMeshList[skinnedMeshIndex];
                if (skinnedMesh.BlendShapeCount <= 0)
                {
                    continue;
                }

                var mesh     = skinnedMesh.Mesh;
                var renderer = skinnedMesh.Renderer;

                for (int blendShapeIndex = 0; blendShapeIndex < mesh.blendShapeCount; blendShapeIndex++)
                {
                    var blendShapeName = mesh.GetBlendShapeName(blendShapeIndex);
                    var weight         = renderer.GetBlendShapeWeight(blendShapeIndex);

                    var animParam = new AnimParam("", blendShapeName, weight);
                    animParamList.Add(animParam);
                }
            }

            return(animParamList);
        }
示例#2
0
        /// <summary>
        /// 選択したblendshapeのプロパティを反映する
        /// </summary>
        /// <param name="animProperties"></param>
        /// <param name="skinnedMeshes"></param>
        public static void ApplyAnimationProperties(List <AnimParam> animProperties, VRCAvatar avatar)
        {
            for (int skinnedMeshIndex = 0; skinnedMeshIndex < avatar.SkinnedMeshList.Count; skinnedMeshIndex++)
            {
                IFaceEmotionSkinnedMesh skinnedMesh = avatar.SkinnedMeshList[skinnedMeshIndex];
                if (skinnedMesh.BlendShapeCount <= 0)
                {
                    continue;
                }

                var mesh        = skinnedMesh.Mesh;
                var renderer    = skinnedMesh.Renderer;
                var blendshapes = skinnedMesh.Blendshapes;

                if (renderer == null)
                {
                    continue;
                }

                // 一旦すべてリセットする
                for (int i = 0; i < avatar.DefaultFaceEmotion.Count; i++)
                {
                    var defaultAnimProperty = avatar.DefaultFaceEmotion[i];
                    var index = mesh.GetBlendShapeIndex(defaultAnimProperty.BlendShapeName);
                    if (index < 0)
                    {
                        continue;
                    }
                    renderer.SetBlendShapeWeight(index, defaultAnimProperty.Value);
                    blendshapes[index].IsContains = false;
                }

                // アニメーションファイルに含まれるものだけ値を変更して
                // 適用させるチェックマークにチェックをいれる
                foreach (var animProperty in animProperties)
                {
                    var index = mesh.GetBlendShapeIndex(animProperty.BlendShapeName);
                    if (index >= 0)
                    {
                        renderer.SetBlendShapeWeight(index, animProperty.Value);
                        blendshapes[index].IsContains = true;
                    }
                }
            }
        }