Add more Spline API for curve editing
This commit is contained in:
@@ -244,6 +244,14 @@ void Spline::ClearSpline()
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::RemoveSplinePoint(int32 index, bool updateSpline)
|
||||
{
|
||||
CHECK(index >= 0 && index < GetSplinePointsCount());
|
||||
Curve.GetKeyframes().RemoveAtKeepOrder(index);
|
||||
if (updateSpline)
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::SetSplinePoint(int32 index, const Vector3& point, bool updateSpline)
|
||||
{
|
||||
CHECK(index >= 0 && index < GetSplinePointsCount());
|
||||
@@ -331,6 +339,22 @@ void Spline::AddSplineLocalPoint(const Transform& point, bool updateSpline)
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::InsertSplinePoint(int32 index, float time, const Transform& point, bool updateSpline)
|
||||
{
|
||||
const Keyframe k(time, _transform.WorldToLocal(point));
|
||||
Curve.GetKeyframes().Insert(index, k);
|
||||
if (updateSpline)
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::InsertSplineLocalPoint(int32 index, float time, const Transform& point, bool updateSpline)
|
||||
{
|
||||
const Keyframe k(time, point);
|
||||
Curve.GetKeyframes().Insert(index, k);
|
||||
if (updateSpline)
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::SetTangentsLinear()
|
||||
{
|
||||
const int32 count = Curve.GetKeyframes().Count();
|
||||
|
||||
@@ -216,12 +216,19 @@ public:
|
||||
/// </summary>
|
||||
API_FUNCTION() void ClearSpline();
|
||||
|
||||
/// <summary>
|
||||
/// Removes the spline curve point at the given index.
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="updateSpline">True if update spline after removing the point, otherwise false.</param>
|
||||
API_FUNCTION() void RemoveSplinePoint(int32 index, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the spline curve at the given index (world-space).
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="point">The location of the point to set (world-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
/// <param name="updateSpline">True if update spline after editing the point, otherwise false.</param>
|
||||
API_FUNCTION() void SetSplinePoint(int32 index, const Vector3& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
@@ -229,7 +236,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="point">The location of the point to set (local-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
/// <param name="updateSpline">True if update spline after editing the point, otherwise false.</param>
|
||||
API_FUNCTION() void SetSplineLocalPoint(int32 index, const Vector3& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
@@ -237,7 +244,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="point">The transformation of the point to set (world-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
/// <param name="updateSpline">True if update spline after editing the point, otherwise false.</param>
|
||||
API_FUNCTION() void SetSplineTransform(int32 index, const Transform& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
@@ -245,7 +252,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="point">The transformation of the point to set (local-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
/// <param name="updateSpline">True if update spline after editing the point, otherwise false.</param>
|
||||
API_FUNCTION() void SetSplineLocalTransform(int32 index, const Transform& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
@@ -255,7 +262,7 @@ public:
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="point">The transformation of the tangent to set (world-space).</param>
|
||||
/// <param name="isIn">True if set arrive tangent, otherwise sets leave tangent (in or out).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
/// <param name="updateSpline">True if update spline after editing the point, otherwise false.</param>
|
||||
API_FUNCTION() void SetSplineTangent(int32 index, const Transform& point, bool isIn, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
@@ -265,7 +272,7 @@ public:
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="point">The transformation of the tangent to set (local-space).</param>
|
||||
/// <param name="isIn">True if set arrive tangent, otherwise sets leave tangent (in or out).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
/// <param name="updateSpline">True if update spline after editing the point, otherwise false.</param>
|
||||
API_FUNCTION() void SetSplineLocalTangent(int32 index, const Transform& point, bool isIn, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
@@ -273,14 +280,14 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="time">The time to set.</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
/// <param name="updateSpline">True if update spline after editing the point, otherwise false.</param>
|
||||
API_FUNCTION() void SetSplinePointTime(int32 index, float time, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the point to the spline curve (at the end).
|
||||
/// </summary>
|
||||
/// <param name="point">The location of the point to add to the curve (world-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
/// <param name="updateSpline">True if update spline after editing the point, otherwise false.</param>
|
||||
API_FUNCTION() void AddSplinePoint(const Vector3& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
@@ -304,6 +311,24 @@ public:
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
API_FUNCTION() void AddSplineLocalPoint(const Transform& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
/// Inserts the spline curve point at the given index (world-space).
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="time">The time value.</param>
|
||||
/// <param name="point">The location of the point to add to the curve (world-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after removing the point, otherwise false.</param>
|
||||
API_FUNCTION() void InsertSplinePoint(int32 index, float time, const Transform& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
/// Inserts the spline curve point at the given index (local-space).
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <param name="time">The time value.</param>
|
||||
/// <param name="point">The location of the point to add to the curve (local-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after removing the point, otherwise false.</param>
|
||||
API_FUNCTION() void InsertSplineLocalPoint(int32 index, float time, const Transform& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the curve tangent points to make curve linear.
|
||||
/// </summary>
|
||||
|
||||
@@ -37,5 +37,27 @@ namespace FlaxEngine
|
||||
Internal_SetKeyframes(__unmanagedPtr, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the spline keyframe.
|
||||
/// </summary>
|
||||
/// <param name="index">The spline point index.</param>
|
||||
/// <returns>The keyframe.</returns>
|
||||
public BezierCurve<Transform>.Keyframe GetSplineKeyframe(int index)
|
||||
{
|
||||
return SplineKeyframes[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the spline keyframe.
|
||||
/// </summary>
|
||||
/// <param name="index">The spline point index.</param>
|
||||
/// <param name="keyframe">The keyframe.</param>
|
||||
public void SetSplineKeyframe(int index, BezierCurve<Transform>.Keyframe keyframe)
|
||||
{
|
||||
SetSplineLocalTransform(index, keyframe.Value, false);
|
||||
SetSplineLocalTangent(index, keyframe.Value + keyframe.TangentIn, true, false);
|
||||
SetSplineLocalTangent(index, keyframe.Value + keyframe.TangentOut, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user