public override void ApplyEffect(ref CharacterData data, int charIndex)
        {
            if (!enabled)
            {
                return;
            }

            if (hasTransformEffects)
            {
                offset = (data.vertices[0] + data.vertices[2]) / 2f;

                #region Movement

                if (setMovement)
                {
                    movementVec.x = movementX.Evaluate(data.passedTime, charIndex);
                    movementVec.y = movementY.Evaluate(data.passedTime, charIndex);
                    movementVec.z = movementZ.Evaluate(data.passedTime, charIndex);

                    movementVec *= effectIntensity;
                }
                #endregion

                #region Scale
                if (setScale)
                {
                    scaleVec.x = scaleX.Evaluate(data.passedTime, charIndex);
                    scaleVec.y = scaleY.Evaluate(data.passedTime, charIndex);
                }

                #endregion

                #region Rotation
                if (setRotation)
                {
                    rotationEuler.x = rotX.Evaluate(data.passedTime, charIndex);
                    rotationEuler.y = rotY.Evaluate(data.passedTime, charIndex);
                    rotationEuler.z = rotZ.Evaluate(data.passedTime, charIndex);

                    rotationQua.eulerAngles = rotationEuler;
                }
                #endregion

                matrix.SetTRS(movementVec, rotationQua, scaleVec);

                for (byte i = 0; i < data.vertices.Length; i++)
                {
                    data.vertices[i] -= offset;
                    data.vertices[i]  = matrix.MultiplyPoint3x4(data.vertices[i]);
                    data.vertices[i] += offset;
                }
            }

            if (setColor)
            {
                color = colorCurve.GetColor(data.passedTime, charIndex);
                data.colors.LerpUnclamped(color, 1 - data.passedTime / showDuration);
            }
        }
 protected override Vector3 _EvaluateEffect(float passedTime, int charIndex)
 {
     return(new Vector3(
                x.Evaluate(passedTime, charIndex),
                y.Evaluate(passedTime, charIndex),
                z.Evaluate(passedTime, charIndex)
                ));
 }
示例#3
0
        public override void ApplyEffect(ref CharacterData data, int charIndex)
        {
            if (!enabled)
            {
                return;
            }

            if (!isOnOneCharacter)
            {
                isOnOneCharacter = data.passedTime > 0;
            }

            weight = emissionControl.effectWeigth * weightMult;

            if (weight == 0) //no effect
            {
                return;
            }

            if (hasTransformEffects)
            {
                offset = (data.vertices[0] + data.vertices[2]) / 2f;

                #region Movement
                if (setMovement)
                {
                    movementVec.x = movementX.Evaluate(uniformEffectTime, charIndex);
                    movementVec.y = movementY.Evaluate(uniformEffectTime, charIndex);
                    movementVec.z = movementZ.Evaluate(uniformEffectTime, charIndex);

                    movementVec *= effectIntensity * weight;  //movement also needs effects intensity (might change depending on fonts etc.)
                }
                #endregion

                #region Scale
                if (setScale)
                {
                    scaleVec.x = scaleX.Evaluate(uniformEffectTime, charIndex);
                    scaleVec.y = scaleY.Evaluate(uniformEffectTime, charIndex);

                    //weighted scale
                    scaleVec = Vector3.LerpUnclamped(Vector3.one, scaleVec, weight);
                }
                #endregion

                #region Rotation
                if (setRotation)
                {
                    rotationEuler.x = rotX.Evaluate(uniformEffectTime, charIndex);
                    rotationEuler.y = rotY.Evaluate(uniformEffectTime, charIndex);
                    rotationEuler.z = rotZ.Evaluate(uniformEffectTime, charIndex);

                    //weighted rotation
                    rotationQua.eulerAngles = rotationEuler * weight;
                }
                #endregion

                matrix.SetTRS(movementVec, rotationQua, scaleVec);

                for (byte i = 0; i < data.vertices.Length; i++)
                {
                    data.vertices[i] -= offset;
                    data.vertices[i]  = matrix.MultiplyPoint3x4(data.vertices[i]);
                    data.vertices[i] += offset;
                }
            }

            if (setColor)
            {
                color = colorCurve.GetColor(uniformEffectTime, charIndex);
                data.colors.LerpUnclamped(color, Mathf.Clamp(weight, -1, 1));
            }
        }