11using System.Collections;
12using System.Collections.Generic;
19 [AddComponentMenu(
"")]
22 [QuickButton(
"Spawn Default",
"spawnDefaultSource0")]
25 [QuickButton(
"Spawn Default",
"spawnDefaultSource1")]
28 [Header(
"Debug View")]
34 private void Update() {
43 movement0 =
new Movement(pose0, pose0SourceChild.ToPose(), 0.1f);
49 movement1 =
new Movement(pose1, pose1SourceChild.ToPose(), 0.1f);
53 movement0, movement1);
57 private void spawnDefaultSource0() { spawnDefaultSource(
false); }
58 private void spawnDefaultSource1() { spawnDefaultSource(
true); }
59 private void spawnDefaultSource(
bool isSecondSource) {
60 var newPoseSourceObj =
new GameObject(
"Pose Source " + (isSecondSource ? 1 : 0));
61 newPoseSourceObj.transform.parent = this.transform;
62 newPoseSourceObj.transform.ResetLocalTransform();
63 newPoseSourceObj.transform.localPosition += Vector3.right * 0.2f
64 * (isSecondSource ? 1 : -1);
65 if (isSecondSource) {
pose1Source = newPoseSourceObj.transform; }
70 if (maybePoseSpline.HasValue) {
71 var spline = maybePoseSpline.Value;
73 drawer.
color = LeapColor.brown.WithAlpha(0.4f);
75 Vector3? prevPos =
null;
77 int drawPosePer = 8, counter = 0;
78 float tStep = 1f / numSteps;
79 for (
float t = 0f; t <= 1f; t += tStep) {
80 var pose = spline.PoseAt(t);
82 if (counter % drawPosePer == 0) {
83 drawer.DrawPose(pose, 0.02f);
86 if (prevPos.HasValue) {
87 drawer.
DrawLine(prevPos.Value, pose.position);
90 prevPos = pose.position;
98 drawer.
matrix = Matrix4x4.TRS(renderPose.position, renderPose.rotation, Vector3.one);
100 drawer.
DrawCube(Vector3.right * ((len / 2f) + (thick / 2f)),
new Vector3(len, thick, thick));
102 drawer.
DrawCube(Vector3.up * ((len / 2f) + (thick / 2f)),
new Vector3(thick, len, thick));
104 drawer.
DrawCube(Vector3.forward * ((len / 2f) + (thick / 2f)),
new Vector3(thick, thick, len));
void PushMatrix()
Saves the current gizmo matrix to the gizmo matrix stack.
void DrawLine(Vector3 a, Vector3 b)
Draws a gizmo line that connects the two positions.
Matrix4x4 matrix
Sets or gets the matrix used to transform all gizmos.
void DrawCube(Vector3 position, Vector3 size)
Draws a filled gizmo cube at the given position with the given size.
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 poses – positions and rotations – that travel from one position and rotation ...
static readonly Movement identity