11using System.Collections;
12using System.Collections.Generic;
19 private const int RESOLUTION = 12;
27 private GameObject[] _evalObjCopies =
new GameObject[RESOLUTION + 1];
38 Vector3 a =
A.position, b =
B.position, c =
C.position, d =
D.position;
39 _spline = CatmullRom.ToCHS(a, b, c, d);
42 Pose a =
A.ToPose(), b =
B.ToPose(), c =
C.ToPose(), d =
D.ToPose();
43 _spline = CatmullRom.ToCHS(a.
position, b.position, c.position, d.position);
44 _qSpline = CatmullRom.ToQuaternionCHS(a.
rotation, b.rotation,
45 c.rotation, d.rotation);
48 float incr = 1f / RESOLUTION;
51 for (
int i = 0; i <= RESOLUTION; i++) {
52 var obj = _evalObjCopies[i];
57 _evalObjCopies[i] = obj;
60 obj.transform.position = _spline.Value.
PositionAt(t);
61 obj.transform.rotation = _qSpline.Value.
RotationAt(t);
72 if (!_spline.HasValue || (
fullPoseSpline && !_qSpline.HasValue))
return;
75 float incr = 1f / resolution;
76 Vector3? lastPos =
null;
77 for (
float t = 0; t <= 1f; t += incr) {
82 drawer.DrawPose(
new Pose(pos, rot), 0.01f);
85 if (lastPos.HasValue) {
void DrawLine(Vector3 a, Vector3 b)
Draws a gizmo line that connects the two positions.
Color color
Sets or gets the color for the gizmos that will be drawn next.
Have your MonoBehaviour implement this interface to be able to draw runtime gizmos....
Represents a spline for the rotation of a rigid body from one orientation in space to another over a ...
Quaternion RotationAt(float t)
Gets the rotation at time t along this spline. The time is clamped within the t0 - t1 range.
Represents a spline that travels from one point in space to another over a specified time frame....
Vector3 PositionAt(float t)
Gets the position at time t along this spline. The time is clamped to t0, but can extrapolate beyon...
A position and rotation. You can multiply two poses; this acts like Matrix4x4 multiplication,...