Add Spline
This commit is contained in:
@@ -42,7 +42,7 @@ public:
|
||||
/// Sets the material to the entry slot. Can be used to override the material of the meshes using this slot.
|
||||
/// </summary>
|
||||
/// <param name="entryIndex">The material slot entry index.</param>
|
||||
/// <param name="material">The material to set..</param>
|
||||
/// <param name="material">The material to set.</param>
|
||||
API_FUNCTION() void SetMaterial(int32 entryIndex, MaterialBase* material);
|
||||
|
||||
/// <summary>
|
||||
|
||||
335
Source/Engine/Level/Actors/Spline.cpp
Normal file
335
Source/Engine/Level/Actors/Spline.cpp
Normal file
@@ -0,0 +1,335 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "Spline.h"
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#include "Engine/Animations/CurveSerialization.h"
|
||||
#include <ThirdParty/mono-2.0/mono/metadata/object.h>
|
||||
|
||||
Spline::Spline(const SpawnParams& params)
|
||||
: Actor(params)
|
||||
{
|
||||
}
|
||||
|
||||
void Spline::SetIsLoop(bool value)
|
||||
{
|
||||
if (_loop != value)
|
||||
{
|
||||
_loop = value;
|
||||
UpdateSpline();
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplinePoint(float time) const
|
||||
{
|
||||
Transform t;
|
||||
Curve.Evaluate(t, time, _loop);
|
||||
return _transform.LocalToWorld(t.Translation);
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplineLocalPoint(float time) const
|
||||
{
|
||||
Transform t;
|
||||
Curve.Evaluate(t, time, _loop);
|
||||
return t.Translation;
|
||||
}
|
||||
|
||||
Quaternion Spline::GetSplineOrientation(float time) const
|
||||
{
|
||||
Transform t;
|
||||
Curve.Evaluate(t, time, _loop);
|
||||
Quaternion::Multiply(_transform.Orientation, t.Orientation, t.Orientation);
|
||||
t.Orientation.Normalize();
|
||||
return t.Orientation;
|
||||
}
|
||||
|
||||
Quaternion Spline::GetSplineLocalOrientation(float time) const
|
||||
{
|
||||
Transform t;
|
||||
Curve.Evaluate(t, time, _loop);
|
||||
return t.Orientation;
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplineScale(float time) const
|
||||
{
|
||||
Transform t;
|
||||
Curve.Evaluate(t, time, _loop);
|
||||
return _transform.Scale * t.Scale;
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplineLocalScale(float time) const
|
||||
{
|
||||
Transform t;
|
||||
Curve.Evaluate(t, time, _loop);
|
||||
return t.Scale;
|
||||
}
|
||||
|
||||
Transform Spline::GetSplineTransform(float time) const
|
||||
{
|
||||
Transform t;
|
||||
Curve.Evaluate(t, time, _loop);
|
||||
return _transform.LocalToWorld(t);
|
||||
}
|
||||
|
||||
Transform Spline::GetSplineLocalTransform(float time) const
|
||||
{
|
||||
Transform t;
|
||||
Curve.Evaluate(t, time, _loop);
|
||||
return t;
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplinePoint(int32 index) const
|
||||
{
|
||||
CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Vector3::Zero)
|
||||
return _transform.LocalToWorld(Curve[index].Value.Translation);
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplineLocalPoint(int32 index) const
|
||||
{
|
||||
CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Vector3::Zero)
|
||||
return Curve[index].Value.Translation;
|
||||
}
|
||||
|
||||
Transform Spline::GetSplineTransform(int32 index) const
|
||||
{
|
||||
CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Vector3::Zero)
|
||||
return _transform.LocalToWorld(Curve[index].Value);
|
||||
}
|
||||
|
||||
Transform Spline::GetSplineLocalTransform(int32 index) const
|
||||
{
|
||||
CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Vector3::Zero)
|
||||
return Curve[index].Value;
|
||||
}
|
||||
|
||||
int32 Spline::GetSplinePointsCount() const
|
||||
{
|
||||
return Curve.GetKeyframes().Count();
|
||||
}
|
||||
|
||||
float Spline::GetSplineDuration() const
|
||||
{
|
||||
return Curve.GetLength();
|
||||
}
|
||||
|
||||
float Spline::GetSplineLength() const
|
||||
{
|
||||
float sum = 0.0f;
|
||||
for (int32 i = 1; i < Curve.GetKeyframes().Count(); i++)
|
||||
sum += Vector3::DistanceSquared(Curve[i - 1].Value.Translation * _transform.Scale, Curve[i].Value.Translation * _transform.Scale);
|
||||
return Math::Sqrt(sum);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void FindTimeClosestToPoint(const Vector3& point, const Spline::Keyframe& start, const Spline::Keyframe& end, float& bestDistanceSquared, float& bestTime)
|
||||
{
|
||||
// TODO: implement sth more analytical than brute-force solution
|
||||
const int32 slices = 100;
|
||||
const float step = 1.0f / (float)slices;
|
||||
const float length = Math::Abs(end.Time - start.Time);
|
||||
for (int32 i = 0; i <= slices; i++)
|
||||
{
|
||||
const float t = (float)i * step;
|
||||
Transform result;
|
||||
Spline::Keyframe::Interpolate(start, end, t, length, result);
|
||||
const float distanceSquared = Vector3::DistanceSquared(point, result.Translation);
|
||||
if (distanceSquared < bestDistanceSquared)
|
||||
{
|
||||
bestDistanceSquared = distanceSquared;
|
||||
bestTime = start.Time + t * length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float Spline::GetSplineTimeClosestToPoint(const Vector3& point) const
|
||||
{
|
||||
const int32 pointsCount = Curve.GetKeyframes().Count();
|
||||
if (pointsCount == 0)
|
||||
return 0.0f;
|
||||
if (pointsCount == 1)
|
||||
return Curve[0].Time;
|
||||
const Vector3 localPoint = _transform.WorldToLocal(point);
|
||||
float bestDistanceSquared = MAX_float;
|
||||
float bestTime = 0.0f;
|
||||
for (int32 i = 1; i < pointsCount; i++)
|
||||
FindTimeClosestToPoint(localPoint, Curve[i - 1], Curve[i], bestDistanceSquared, bestTime);
|
||||
if (_loop)
|
||||
FindTimeClosestToPoint(localPoint, Curve[pointsCount - 1], Curve[0], bestDistanceSquared, bestTime);
|
||||
return bestTime;
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplinePointClosestToPoint(const Vector3& point) const
|
||||
{
|
||||
return GetSplinePoint(GetSplineTimeClosestToPoint(point));
|
||||
}
|
||||
|
||||
void Spline::GetSplinePoints(Array<Vector3>& points) const
|
||||
{
|
||||
for (auto& e : Curve.GetKeyframes())
|
||||
points.Add(_transform.LocalToWorld(e.Value.Translation));
|
||||
}
|
||||
|
||||
void Spline::GetSplineLocalPoints(Array<Vector3>& points) const
|
||||
{
|
||||
for (auto& e : Curve.GetKeyframes())
|
||||
points.Add(e.Value.Translation);
|
||||
}
|
||||
|
||||
void Spline::GetSplinePoints(Array<Transform>& points) const
|
||||
{
|
||||
for (auto& e : Curve.GetKeyframes())
|
||||
points.Add(_transform.LocalToWorld(e.Value));
|
||||
}
|
||||
|
||||
void Spline::GetSplineLocalPoints(Array<Transform>& points) const
|
||||
{
|
||||
for (auto& e : Curve.GetKeyframes())
|
||||
points.Add(e.Value);
|
||||
}
|
||||
|
||||
void Spline::ClearSpline()
|
||||
{
|
||||
if (Curve.IsEmpty())
|
||||
return;
|
||||
Curve.Clear();
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::AddSplinePoint(const Vector3& point, bool updateSpline)
|
||||
{
|
||||
const Keyframe k(Curve.IsEmpty() ? 0.0f : Curve.GetKeyframes().Last().Time + 1.0f, Transform(point));
|
||||
Curve.GetKeyframes().Add(k);
|
||||
if (updateSpline)
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::AddSplineLocalPoint(const Vector3& point, bool updateSpline)
|
||||
{
|
||||
const Keyframe k(Curve.IsEmpty() ? 0.0f : Curve.GetKeyframes().Last().Time + 1.0f, Transform(_transform.WorldToLocal(point)));
|
||||
Curve.GetKeyframes().Add(k);
|
||||
if (updateSpline)
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::AddSplinePoint(const Transform& point, bool updateSpline)
|
||||
{
|
||||
const Keyframe k(Curve.IsEmpty() ? 0.0f : Curve.GetKeyframes().Last().Time + 1.0f, _transform.WorldToLocal(point));
|
||||
Curve.GetKeyframes().Add(k);
|
||||
if (updateSpline)
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::AddSplineLocalPoint(const Transform& point, bool updateSpline)
|
||||
{
|
||||
const Keyframe k(Curve.IsEmpty() ? 0.0f : Curve.GetKeyframes().Last().Time + 1.0f, point);
|
||||
Curve.GetKeyframes().Add(k);
|
||||
if (updateSpline)
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
void Spline::UpdateSpline()
|
||||
{
|
||||
}
|
||||
|
||||
void Spline::GetKeyframes(MonoArray* data)
|
||||
{
|
||||
Platform::MemoryCopy(mono_array_addr_with_size(data, sizeof(Keyframe), 0), Curve.GetKeyframes().Get(), sizeof(Keyframe) * Curve.GetKeyframes().Count());
|
||||
}
|
||||
|
||||
void Spline::SetKeyframes(MonoArray* data)
|
||||
{
|
||||
const auto count = (int32)mono_array_length(data);
|
||||
Curve.GetKeyframes().Resize(count, false);
|
||||
Platform::MemoryCopy(Curve.GetKeyframes().Get(), mono_array_addr_with_size(data, sizeof(Keyframe), 0), sizeof(Keyframe) * count);
|
||||
UpdateSpline();
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
#include "Engine/Debug/DebugDraw.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
void DrawSegment(Spline* spline, int32 start, int32 end, const Color& color, const Transform& transform, bool depthTest)
|
||||
{
|
||||
const auto& startKey = spline->Curve[start];
|
||||
const auto& endKey = spline->Curve[end];
|
||||
const Vector3 startPos = transform.LocalToWorld(startKey.Value.Translation);
|
||||
const Vector3 startTangent = transform.LocalToWorld(startKey.TangentOut.Translation);
|
||||
const Vector3 endPos = transform.LocalToWorld(endKey.Value.Translation);
|
||||
const Vector3 endTangent = transform.LocalToWorld(endKey.TangentIn.Translation);
|
||||
const float d = (endKey.Time - startKey.Time) / 3.0f;
|
||||
DEBUG_DRAW_BEZIER(startPos, startPos + startTangent * d, endPos + endTangent * d, endPos, color, 0.0f, depthTest);
|
||||
}
|
||||
|
||||
void DrawSpline(Spline* spline, const Color& color, const Transform& transform, bool depthTest)
|
||||
{
|
||||
const int32 count = spline->Curve.GetKeyframes().Count();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
{
|
||||
Vector3 p = transform.LocalToWorld(spline->Curve[i].Value.Translation);
|
||||
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(p, 5.0f), color, 0.0f, true);
|
||||
if (i != 0)
|
||||
DrawSegment(spline, i - 1, i, color, transform, depthTest);
|
||||
}
|
||||
if (spline->GetIsLoop() && count > 1)
|
||||
DrawSegment(spline, count - 1, 0, color, transform, depthTest);
|
||||
}
|
||||
}
|
||||
|
||||
void Spline::OnDebugDraw()
|
||||
{
|
||||
const Color color = GetSplineColor();
|
||||
DrawSpline(this, color.AlphaMultiplied(0.7f), _transform, true);
|
||||
|
||||
// Base
|
||||
Actor::OnDebugDraw();
|
||||
}
|
||||
|
||||
void Spline::OnDebugDrawSelected()
|
||||
{
|
||||
const Color color = GetSplineColor();
|
||||
DrawSpline(this, color.AlphaMultiplied(0.3f), _transform, false);
|
||||
DrawSpline(this, color, _transform, true);
|
||||
|
||||
// Base
|
||||
Actor::OnDebugDrawSelected();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Spline::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
{
|
||||
// Base
|
||||
Actor::Serialize(stream, otherObj);
|
||||
|
||||
SERIALIZE_GET_OTHER_OBJ(Spline);
|
||||
|
||||
SERIALIZE_MEMBER(IsLoop, _loop);
|
||||
SERIALIZE(Curve);
|
||||
}
|
||||
|
||||
void Spline::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
|
||||
{
|
||||
// Base
|
||||
Actor::Deserialize(stream, modifier);
|
||||
|
||||
DESERIALIZE_MEMBER(IsLoop, _loop);
|
||||
DESERIALIZE(Curve);
|
||||
|
||||
// Initialize spline when loading data during gameplay
|
||||
if (IsDuringPlay())
|
||||
{
|
||||
UpdateSpline();
|
||||
}
|
||||
}
|
||||
|
||||
void Spline::OnEnable()
|
||||
{
|
||||
// Base
|
||||
Actor::OnEnable();
|
||||
|
||||
// Initialize spline
|
||||
UpdateSpline();
|
||||
}
|
||||
247
Source/Engine/Level/Actors/Spline.h
Normal file
247
Source/Engine/Level/Actors/Spline.h
Normal file
@@ -0,0 +1,247 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Actor.h"
|
||||
#include "Engine/Animations/Curve.h"
|
||||
|
||||
/// <summary>
|
||||
/// Spline shape actor that defines spatial curve with utility functions for general purpose usage.
|
||||
/// </summary>
|
||||
API_CLASS() class FLAXENGINE_API Spline : public Actor
|
||||
{
|
||||
DECLARE_SCENE_OBJECT(Spline);
|
||||
typedef BezierCurveKeyframe<Transform> Keyframe;
|
||||
private:
|
||||
|
||||
bool _loop = false;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// The spline bezier curve points represented as series of transformations in 3D space (with tangents). Points are stored in local-space of the actor.
|
||||
/// </summary>
|
||||
/// <remarks>Ensure to call UpdateSpline() after editing curve to reflect the changes.</remarks>
|
||||
BezierCurve<Transform> Curve;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use spline as closed loop.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(0), EditorDisplay(\"Spline\")")
|
||||
FORCE_INLINE bool GetIsLoop() const
|
||||
{
|
||||
return _loop;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use spline as closed loop.
|
||||
/// </summary>
|
||||
API_PROPERTY() void SetIsLoop(bool value);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given time and calculates the point location in 3D (world-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve point location (world-space).</returns>
|
||||
API_FUNCTION() Vector3 GetSplinePoint(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given time and calculates the point location in 3D (local-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve point location (local-space).</returns>
|
||||
API_FUNCTION() Vector3 GetSplineLocalPoint(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given time and calculates the point rotation in 3D (world-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve point rotation (world-space).</returns>
|
||||
API_FUNCTION() Quaternion GetSplineOrientation(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given time and calculates the point rotation in 3D (local-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve point rotation (local-space).</returns>
|
||||
API_FUNCTION() Quaternion GetSplineLocalOrientation(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given time and calculates the point scale in 3D (world-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve point scale (world-space).</returns>
|
||||
API_FUNCTION() Vector3 GetSplineScale(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given time and calculates the point scale in 3D (local-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve point scale (local-space).</returns>
|
||||
API_FUNCTION() Vector3 GetSplineLocalScale(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given time and calculates the transformation in 3D (world-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve point transformation (world-space).</returns>
|
||||
API_FUNCTION() Transform GetSplineTransform(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given time and calculates the transformation in 3D (local-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve point transformation (local-space).</returns>
|
||||
API_FUNCTION() Transform GetSplineLocalTransform(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given index (world-space).
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <returns>The curve point location (world-space).</returns>
|
||||
API_FUNCTION() Vector3 GetSplinePoint(int32 index) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given index (local-space).
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <returns>The curve point location (local-space).</returns>
|
||||
API_FUNCTION() Vector3 GetSplineLocalPoint(int32 index) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given index (world-space).
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <returns>The curve point transformation (world-space).</returns>
|
||||
API_FUNCTION() Transform GetSplineTransform(int32 index) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given index (local-space).
|
||||
/// </summary>
|
||||
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
|
||||
/// <returns>The curve point transformation (local-space).</returns>
|
||||
API_FUNCTION() Transform GetSplineLocalTransform(int32 index) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of points in the spline.
|
||||
/// </summary>
|
||||
API_PROPERTY() int32 GetSplinePointsCount() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total duration of the spline curve (time of the last point).
|
||||
/// </summary>
|
||||
API_PROPERTY() float GetSplineDuration() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total length of the spline curve (distance between all the points).
|
||||
/// </summary>
|
||||
API_PROPERTY() float GetSplineLength() const;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the closest point to the given location and returns the spline time at that point.
|
||||
/// </summary>
|
||||
/// <param name="point">The point in world-space to find the spline point that is closest to it.</param>
|
||||
/// <returns>The spline time.</returns>
|
||||
API_FUNCTION() float GetSplineTimeClosestToPoint(const Vector3& point) const;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the closest point to the given location.
|
||||
/// </summary>
|
||||
/// <param name="point">The point in world-space to find the spline point that is closest to it.</param>
|
||||
/// <returns>The spline position.</returns>
|
||||
API_FUNCTION() Vector3 GetSplinePointClosestToPoint(const Vector3& point) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the spline curve points list (world-space).
|
||||
/// </summary>
|
||||
/// <param name="points">The result points collection.</param>
|
||||
API_FUNCTION() void GetSplinePoints(API_PARAM(Out) Array<Vector3>& points) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the spline curve points list (local-space).
|
||||
/// </summary>
|
||||
/// <param name="points">The result points collection.</param>
|
||||
API_FUNCTION() void GetSplineLocalPoints(API_PARAM(Out) Array<Vector3>& points) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the spline curve points list (world-space).
|
||||
/// </summary>
|
||||
/// <param name="points">The result points collection.</param>
|
||||
API_FUNCTION() void GetSplinePoints(API_PARAM(Out) Array<Transform>& points) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the spline curve points list (local-space).
|
||||
/// </summary>
|
||||
/// <param name="points">The result points collection.</param>
|
||||
API_FUNCTION() void GetSplineLocalPoints(API_PARAM(Out) Array<Transform>& points) const;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Clears the spline to be empty.
|
||||
/// </summary>
|
||||
API_FUNCTION() void ClearSpline();
|
||||
|
||||
/// <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>
|
||||
API_FUNCTION() void AddSplinePoint(const Vector3& point, 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 (local-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
API_FUNCTION() void AddSplineLocalPoint(const Vector3& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the point to the spline curve (at the end).
|
||||
/// </summary>
|
||||
/// <param name="point">The transformation 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>
|
||||
API_FUNCTION() void AddSplinePoint(const Transform& point, bool updateSpline = true);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the point to the spline curve (at the end).
|
||||
/// </summary>
|
||||
/// <param name="point">The transformation of the point to add to the curve (local-space).</param>
|
||||
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
|
||||
API_FUNCTION() void AddSplineLocalPoint(const Transform& point, bool updateSpline = true);
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Updates the spline after it was modified. Recreates the collision and/or any cached state that depends on the spline type.
|
||||
/// </summary>
|
||||
API_FUNCTION() virtual void UpdateSpline();
|
||||
|
||||
protected:
|
||||
|
||||
#if USE_EDITOR
|
||||
virtual Color GetSplineColor()
|
||||
{
|
||||
return Color::White;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
// Internal bindings
|
||||
API_FUNCTION(NoProxy) void GetKeyframes(MonoArray* data);
|
||||
API_FUNCTION(NoProxy) void SetKeyframes(MonoArray* data);
|
||||
|
||||
public:
|
||||
|
||||
// [Actor]
|
||||
#if USE_EDITOR
|
||||
void OnDebugDraw() override;
|
||||
void OnDebugDrawSelected() override;
|
||||
#endif
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
void OnEnable() override;
|
||||
};
|
||||
Reference in New Issue
Block a user