Ejemplo n.º 1
0
        private void Start()
        {
            faceMesh = faceSkin.sharedMesh;

            blendShapeValueBuffer = new float[faceMesh.blendShapeCount];

            previousFace = defaultFace;
        }
Ejemplo n.º 2
0
        private void Trigger(FacialExpressionPreset face)
        {
            if (animating)
            {
                return;
            }

            StartCoroutine(ChangeFaceTo(face));
        }
Ejemplo n.º 3
0
        IEnumerator ChangeFaceTo(FacialExpressionPreset currentFace)
        {
            animating = true;

            float t = 0;


            while (t < changeTime)
            {
                float fraction = t / changeTime;

                Zero();

                // Previous
                float weight = 1 - fraction;
                previousFace.targetBlendshapePairs.ForEach(blendShapeIndexPair =>
                {
                    blendShapeValueBuffer[blendShapeIndexPair.Index] += blendShapeIndexPair.MaxValue * weight;
                });

                // Current
                weight = fraction;
                currentFace.targetBlendshapePairs.ForEach(blendShapeIndexPair =>
                {
                    blendShapeValueBuffer[blendShapeIndexPair.Index] += blendShapeIndexPair.MaxValue * weight;
                });

                t += Time.deltaTime;

                yield return(null);
            }

            animating = false;

            previousFace = currentFace;
        }