diff options
Diffstat (limited to 'Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs')
-rw-r--r-- | Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs b/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs new file mode 100644 index 00000000..9f8602c6 --- /dev/null +++ b/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs @@ -0,0 +1,123 @@ +using UnityEngine; +using System.Collections; + + +namespace XftWeapon { + public class SplineControlPoint + { + public Vector3 Position; + public Vector3 Normal; + + public int ControlPointIndex = -1; + public int SegmentIndex = -1; + + public float Dist; + + protected Spline mSpline; + + + public SplineControlPoint NextControlPoint + { + get + { + return mSpline.NextControlPoint(this); + } + } + + public SplineControlPoint PreviousControlPoint + { + get + { + return mSpline.PreviousControlPoint(this); + } + } + + public Vector3 NextPosition + { + get + { + return mSpline.NextPosition(this); + } + } + + + public Vector3 PreviousPosition + { + get + { + return mSpline.PreviousPosition(this); + + } + } + + + public Vector3 NextNormal + { + get + { + return mSpline.NextNormal(this); + } + } + + + public Vector3 PreviousNormal + { + get { return mSpline.PreviousNormal(this); } + } + + public bool IsValid + { + get + { + return (NextControlPoint != null); + } + } + + + Vector3 GetNext2Position() + { + SplineControlPoint cp = NextControlPoint; + if (cp != null) + return cp.NextPosition; + return NextPosition; + } + + + Vector3 GetNext2Normal() + { + SplineControlPoint cp = NextControlPoint; + if (cp != null) + return cp.NextNormal; + + + return Normal; + } + + + public Vector3 Interpolate(float localF) + { + localF = Mathf.Clamp01(localF); + + return Spline.CatmulRom(PreviousPosition, Position, NextPosition, GetNext2Position(), localF); + + } + + + public Vector3 InterpolateNormal(float localF) + { + localF = Mathf.Clamp01(localF); + + return Spline.CatmulRom(PreviousNormal, Normal, NextNormal, GetNext2Normal(), localF); + } + + + public void Init(Spline owner) + { + mSpline = owner; + SegmentIndex = -1; + } + + } +} + + |