Beispiel #1
0
        private static void ReverseInterpolation(InterpolationCurve curve)
        {
            var bytes = curve.ToBytes().Select(b => (byte)(0x7F - b)).ToArray();

            curve.EarlyControlePoint = (bytes[2], bytes[3]);
            curve.LateControlePoint  = (bytes[0], bytes[1]);
        }
Beispiel #2
0
 /// <summary>
 /// VMD形式に書き込み
 /// </summary>
 public override void Write(BinaryWriter writer)
 {
     writer.Write(Frame);
     writer.Write(Distance);
     writer.Write(Position);
     writer.Write(Rotation);
     writer.Write(InterpolationCurve.CreateVMDFormatBytes(InterpolationCurves, FrameType));
     writer.Write(ViewAngle);
     writer.Write(IsPerspectiveOff);
 }
Beispiel #3
0
        public float CurveAdjustedBlendingTime(InterpolationCurve curve, float t)
        {
            if (curve == InterpolationCurve.Linear)
            {
                return(t);
            }
            else if (curve == InterpolationCurve.EaseInEaseOut)
            {
                float curveTime = t < .5f ? 2 * t * t : -1 + (4 - 2 * t) * t;
                return(Mathf.Clamp01(curveTime));
            }

            return(t);
        }
Beispiel #4
0
        // This will consider the direction, and curve type to return a float value that's interpolated.
        public float InterpolateFloat(InterpolationCurve curve, InterpolationDirection direction,
                                      float time, float beforeTime, float nextTime,
                                      float previousKeyValue, float nextKeyValue,
                                      float minValue, float maxValue)
        {
            float progressBetweenFrames = ProgressBetweenSurroundingKeyframes(time, beforeTime, nextTime);
            float curvedTime            = CurveAdjustedBlendingTime(curve, progressBetweenFrames);

            // Auto.
            if (direction == InterpolationDirection.Auto)
            {
                return(AutoInterpolation(curvedTime, previousKeyValue, nextKeyValue));
            }

            InterpolationDirection moveDirection = direction;

            float forwardDistance;
            float reverseDistance;

            CalculateCircularDistances(previousKeyValue, nextKeyValue, minValue, maxValue, out forwardDistance, out reverseDistance);

            // Shortest path.
            if (moveDirection == InterpolationDirection.ShortestPath)
            {
                if (reverseDistance > forwardDistance)
                {
                    moveDirection = InterpolationDirection.Foward;
                }
                else
                {
                    moveDirection = InterpolationDirection.Reverse;
                }
            }

            // Forward.
            if (moveDirection == InterpolationDirection.Foward)
            {
                return(ForwardInterpolation(curvedTime, previousKeyValue, nextKeyValue, minValue, maxValue, forwardDistance));
            }

            // Reverse.
            if (moveDirection == InterpolationDirection.Reverse)
            {
                return(ReverseInterpolation(curvedTime, previousKeyValue, nextKeyValue, minValue, maxValue, reverseDistance));
            }

            Debug.LogError("Unhandled interpolation direction: " + moveDirection + ", returning min value.");

            return(minValue);
        }
Beispiel #5
0
        /// <summary>
        /// VMD形式から読み込み
        /// </summary>
        public override void Read(BinaryReader reader)
        {
            Frame    = reader.ReadUInt32();
            Distance = reader.ReadSingle();
            Position = reader.ReadVector3();
            Rotation = reader.ReadVector3();

            //補間曲線を読み込み
            var interpolationMatrix = reader.ReadBytes(24);

            InterpolationCurves = InterpolationCurve.CreateByVMDFormat(interpolationMatrix, FrameType);

            ViewAngle        = reader.ReadUInt32();
            IsPerspectiveOff = reader.ReadBoolean();
        }
Beispiel #6
0
        public bool RenderInterpolationCurveType()
        {
            EditorGUI.BeginChangeCheck();

            InterpolationCurve selectedCurveType = (InterpolationCurve)EditorGUILayout.EnumPopup(
                new GUIContent("Animation Curve",
                               "Adjust animation curve timing to the next keyframe."), keyframe.interpolationCurve);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(profile, "Curve type changed");
                keyframe.interpolationCurve = selectedCurveType;
                return(true);
            }

            return(false);
        }
Beispiel #7
0
 protected ValueAnimation(ReadonlyPropertyFloat duration, InterpolationCurve curve)
 {
     m_duration = duration;
     m_curve    = curve;
 }
Beispiel #8
0
 protected ReadonlyVariableAnimation(TVariable variable, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(duration, curve)
 {
     m_variable = variable;
 }
Beispiel #9
0
 protected PropertyAnimation(TProperty property, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(duration, curve)
 {
     m_property = property;
 }
Beispiel #10
0
 public PropertyAnimationFloat(ReadonlyPropertyFloat property, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(property, duration, curve)
 {
 }
Beispiel #11
0
 public ReadonlyAnimaitonInt(ReadonlyInt variable, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(variable, duration, curve)
 {
 }
Beispiel #12
0
 protected abstract ReadonlyVariableAnimation<T, TVariable> CreateAnimation(TVariable variable, ReadonlyPropertyFloat duration, InterpolationCurve curve);
Beispiel #13
0
 protected override ReadonlyVariableAnimation <float, ReadonlyFloat> CreateAnimation(ReadonlyFloat variable, ReadonlyPropertyFloat duration, InterpolationCurve curve)
 {
     return(new ReadonlyAnimationFloat(variable, duration, curve));
 }
Beispiel #14
0
 protected override ReadonlyVariableAnimation <int, ReadonlyInt> CreateAnimation(ReadonlyInt variable, ReadonlyPropertyFloat duration, InterpolationCurve curve)
 {
     return(new ReadonlyAnimaitonInt(variable, duration, curve)
     {
         CastType = m_castType
     });
 }
Beispiel #15
0
 public ReadonlyAnimationColor(ReadonlyColor variable, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(variable, duration, curve)
 {
 }