Exemple #1
0
        /// <summary>
        /// コピー元のアバターのBlendShapeBindingを基に、コピー先のアバターのBlendShapeBindingを生成します。
        /// </summary>
        /// <param name="sourceBinding"></param>
        /// <param name="source"></param>
        /// <param name="destination"></param>
        /// <returns></returns>
        private static BlendShapeBinding CopyBlendShapeBinding(
            BlendShapeBinding binding,
            GameObject source,
            GameObject destination
            )
        {
            var sourceMesh = CopyVRMBlendShapes.GetMesh(binding, source);

            if (!sourceMesh)
            {
                return(binding);
            }

            var shapeKeyName = sourceMesh.GetBlendShapeName(binding.Index);

            var destinationMesh = CopyVRMBlendShapes.GetMesh(binding.RelativePath, destination);

            if (destinationMesh)
            {
                var index = destinationMesh.GetBlendShapeIndex(shapeKeyName);
                if (index != -1)
                {
                    binding.Index = index;
                    return(binding);
                }
            }

            return(CopyVRMBlendShapes.FindShapeKey(binding, shapeKeyName, destination));
        }
Exemple #2
0
        /// <summary>
        /// BlendShapeBindingに対応するメッシュを返します。
        /// </summary>
        /// <param name="binding"></param>
        /// <param name="avatar"></param>
        /// <returns></returns>
        private static Mesh GetMesh(BlendShapeBinding binding, GameObject avatar)
        {
            var mesh = CopyVRMBlendShapes.GetMesh(binding.RelativePath, avatar);

            if (!mesh || binding.Index > mesh.blendShapeCount)
            {
                return(null);
            }

            return(mesh);
        }