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]); }
/// <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); }
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); }
// 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); }
/// <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(); }
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); }
protected ValueAnimation(ReadonlyPropertyFloat duration, InterpolationCurve curve) { m_duration = duration; m_curve = curve; }
protected ReadonlyVariableAnimation(TVariable variable, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(duration, curve) { m_variable = variable; }
protected PropertyAnimation(TProperty property, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(duration, curve) { m_property = property; }
public PropertyAnimationFloat(ReadonlyPropertyFloat property, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(property, duration, curve) { }
public ReadonlyAnimaitonInt(ReadonlyInt variable, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(variable, duration, curve) { }
protected abstract ReadonlyVariableAnimation<T, TVariable> CreateAnimation(TVariable variable, ReadonlyPropertyFloat duration, InterpolationCurve curve);
protected override ReadonlyVariableAnimation <float, ReadonlyFloat> CreateAnimation(ReadonlyFloat variable, ReadonlyPropertyFloat duration, InterpolationCurve curve) { return(new ReadonlyAnimationFloat(variable, duration, curve)); }
protected override ReadonlyVariableAnimation <int, ReadonlyInt> CreateAnimation(ReadonlyInt variable, ReadonlyPropertyFloat duration, InterpolationCurve curve) { return(new ReadonlyAnimaitonInt(variable, duration, curve) { CastType = m_castType }); }
public ReadonlyAnimationColor(ReadonlyColor variable, ReadonlyPropertyFloat duration, InterpolationCurve curve) : base(variable, duration, curve) { }