diff --git a/src/Arts.cs b/src/Arts.cs index bb5ddeb..32a2474 100644 --- a/src/Arts.cs +++ b/src/Arts.cs @@ -46,8 +46,8 @@ static class Arts // Input.HandVisible(Handed.Max, false); // world - Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl); - Hierarchy.Push(m4_dof); + // Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl); + // Hierarchy.Push(m4_dof); // mesh test // meshes["Food"].Draw( @@ -66,57 +66,35 @@ static class Arts // Color.Hex(0x13180AFF).ToLinear() // ); - //// dof - // design - float deadzone = 0.1f; - float strength = 3; + //// dofs - // input - // controls you can pick up (double grip to drop) - // if (!Mono.to_grab.Held) - // { - // Pose to_pose = new Pose( - // V.XYZ(0, 0, 0) - // ); - // } - // else - // { - // to_pose = Rig.r_hld; - // } - // if (!Mono.from_grab.Held) - // { - // Pose from_pose = new Pose( - // to_pose.position + V.XYZ(0, 0, (deadzone + Maths.u_scalar(SKMath.Sin(Time.Totalf)) * deadzone)) - // ); - // } + // stretch_cursor + { + Mesh.Cube.Draw( + mat_mono, + Stretch.to_grab.pose.ToMatrix(5 * U.cm) + ); + Mesh.Cube.Draw( + mat_mono, + Stretch.from_grab.pose.ToMatrix(4 * U.cm) + ); - // data - float stretch = 0.0f; - Pose cursor = new Pose(); + Mesh.Cube.Draw( + mat_mono, + Stretch.cursor.ToMatrix(3 * U.cm) + ); + } - // frame - Vec3 delta = Mono.to_grab.pose.position - Mono.from_grab.pose.position; - stretch = Maths.max(delta.Magnitude - deadzone, 0); + // reach cursor + // pos = trackedPoint + // if down + // pullPoint = pos - Vec3 dir = delta.Normalized; - cursor.position = Mono.to_grab.pose.position + dir * stretch * strength; + // stretch = distance(pullPoint, pos) + // dir = (pos - pullPoint).normalized + // cursor = pos + dir * stretch * 3 - Mesh.Cube.Draw( - mat_mono, - Mono.to_grab.pose.ToMatrix(0.1f) - ); - Mesh.Cube.Draw( - mat_mono, - Mono.from_grab.pose.ToMatrix(0.05f) - ); - - Mesh.Cube.Draw( - mat_mono, - cursor.ToMatrix(0.05f) - ); - - - Hierarchy.Pop(); + // Hierarchy.Pop(); // particles diff --git a/src/Data.cs b/src/Data.cs index bb9e2f3..892ef1f 100644 --- a/src/Data.cs +++ b/src/Data.cs @@ -50,9 +50,6 @@ public class Grab { if (Held) { - Log.Info(held_by.palm.position.ToString()); - - // Apply position and rotation logic here pose.position = held_by.palm.position - pos_offset; pose.orientation = held_by.palm.orientation * ori_offset; } diff --git a/src/Dofs.cs b/src/Dofs.cs new file mode 100644 index 0000000..6fa7d65 --- /dev/null +++ b/src/Dofs.cs @@ -0,0 +1,32 @@ +using StereoKit; + +namespace dofdemo; + +static class Stretch +{ + public static Grab to_grab; + public static Grab from_grab; + + // data + public static float stretch = 0.0f; + public static Pose cursor; + + public static void Init() + { + to_grab = new(); + from_grab = new(); + } + + public static void Frame() + { + Vec3 delta = to_grab.pose.position - from_grab.pose.position; + stretch = Maths.max(delta.Magnitude - deadzone, 0); + + Vec3 dir = delta.Normalized; + cursor.position = to_grab.pose.position + dir * stretch * strength; + } + + // design + static float deadzone = 0.1f; + static float strength = 3; +} \ No newline at end of file diff --git a/src/Mono.cs b/src/Mono.cs index d3b9ca7..79507d6 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -10,11 +10,8 @@ static class Mono public static int score; // to be wrapped in a dof base class - public static Pose dof_pose; - public static float dof_scl; - // custom inside data/class - public static Grab to_grab; - public static Grab from_grab; + // public static Pose dof_pose; + // public static float dof_scl; public static DeltaBool menu; public static Pose menu_pose; @@ -36,10 +33,9 @@ static class Mono menu_scale = 1 * U.cm; mode = Mode.Mount; - dof_pose = new(0, 0, 0); // new(0, -1, -2); - dof_scl = 1.0f; // 0.1f; - to_grab = new(); - from_grab = new(); + // dof_pose = new(0, 0, 0); // new(0, -1, -2); + // dof_scl = 1.0f; // 0.1f; + Stretch.Init(); } public static void Frame() @@ -102,8 +98,8 @@ static class Mono Grab[] grabs = new Grab[] { - to_grab, - from_grab + Stretch.to_grab, + Stretch.from_grab }; foreach (var grab in grabs) { @@ -152,5 +148,7 @@ static class Mono grab.Frame(); } + + Stretch.Frame(); } }