diff --git a/Assets/meshes/assets.glb b/Assets/meshes/assets.glb index 5ff1115..7a87dbc 100644 --- a/Assets/meshes/assets.glb +++ b/Assets/meshes/assets.glb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d14a38f568ecca9c13cfd7698720c4c8dbff855e3c4fd0f79f76d527042ee776 -size 53500 +oid sha256:ceac98fcf441d1cc1e1fa30e44c4bedbbb059730a9b05ce3a155d6cdc9e3dd0e +size 105968 diff --git a/src/Arts.cs b/src/Arts.cs index 0e5cc5b..dae8b4f 100644 --- a/src/Arts.cs +++ b/src/Arts.cs @@ -79,15 +79,13 @@ static class Arts // stretch_cursor { - float flip_x = Stretch.to_grab.Held && Stretch.to_grab.held_by.handed == Handed.Left ? -1 : 1; meshes["con"].Draw( mat_mono, - Stretch.to_grab.pose.ToMatrix(V.XYZ(flip_x, 1, 1) * 1.5f * U.cm) + Stretch.to_grab.pose.ToMatrix(1.5f * U.cm) ); - flip_x = Stretch.from_grab.Held && Stretch.from_grab.held_by.handed == Handed.Left ? -1 : 1; meshes["con"].Draw( mat_mono, - Stretch.from_grab.pose.ToMatrix(V.XYZ(flip_x, 1, 1) * 1.5f * U.cm) + Stretch.from_grab.pose.ToMatrix(1.5f * U.cm) ); Mesh.Cube.Draw( diff --git a/src/Data.cs b/src/Data.cs index d40f6fb..4ebfdf6 100644 --- a/src/Data.cs +++ b/src/Data.cs @@ -13,7 +13,7 @@ public class Grab public Pose pose; private Vec3 pos_offset; private Quat ori_offset; - public Hand? held_by; + public Controller? held_by; private bool snap_to_hand = false; public Grab(float x, float y, float z, bool snap_to_hand = false) @@ -25,16 +25,16 @@ public class Grab this.snap_to_hand = snap_to_hand; } - public bool OnGrab(ref Hand hand, ref Grab grab_ref) + public bool OnGrab(ref Controller con, ref Grab grab_ref) { if (!Held) // Allow only one hand at a time to grab { - if (Vec3.Distance(hand.palm.position, pose.position) < 0.14f) + if (Vec3.Distance(con.pose.position, pose.position) < 0.14f) { - held_by = hand; + held_by = con; grab_ref = this; - pos_offset = hand.palm.orientation.Inverse * (hand.palm.position - pose.position); - ori_offset = hand.palm.orientation.Inverse * pose.orientation; + pos_offset = con.pose.orientation.Inverse * (con.pose.position - pose.position); + ori_offset = con.pose.orientation.Inverse * pose.orientation; return true; } } @@ -54,13 +54,13 @@ public class Grab { if (snap_to_hand) { - pose.orientation = held_by.palm.orientation; - pose.position = held_by.palm.position; + pose.orientation = held_by.pose.orientation; + pose.position = held_by.pose.position; } else { - pose.orientation = held_by.palm.orientation * ori_offset; - pose.position = held_by.palm.position - held_by.palm.orientation * pos_offset; + pose.orientation = held_by.pose.orientation * ori_offset; + pose.position = held_by.pose.position - held_by.pose.orientation * pos_offset; } } } diff --git a/src/Mono.cs b/src/Mono.cs index 0cd9d13..8ea5701 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -111,7 +111,7 @@ static class Mono { if (Rig.btn_l_grip.delta == +1) { - grab.OnGrab(ref Rig.l_hnd, ref Rig.l_held); + grab.OnGrab(ref Rig.l_con, ref Rig.l_held); } } } @@ -132,7 +132,7 @@ static class Mono { if (Rig.btn_r_grip.delta == +1) { - grab.OnGrab(ref Rig.r_hnd, ref Rig.r_held); + grab.OnGrab(ref Rig.r_con, ref Rig.r_held); } } } diff --git a/src/Rig.cs b/src/Rig.cs index cefe9f8..d1901d1 100644 --- a/src/Rig.cs +++ b/src/Rig.cs @@ -6,8 +6,8 @@ static class Rig { public static Pose head = Pose.Identity; - public static Hand l_hnd; - public static Hand r_hnd; + public static Hand l_hnd, r_hnd; + public static Controller l_con, r_con; public static DeltaBool btn_select = new(false); public static DeltaBool btn_l_grip = new(false); @@ -17,8 +17,6 @@ static class Rig public static Grab? l_held = null; public static Grab? r_held = null; - public static Pose l_hld, l_aim, r_hld, r_aim; - public static Vec3 fullstick = Vec3.Up; public static Pose r_con_stick = Pose.Identity; @@ -26,7 +24,8 @@ static class Rig public static void Init() { - + l_con = new(); + r_con = new(); } public static void Frame() @@ -62,21 +61,16 @@ static class Rig // [!] hand input simulates controller... l_hnd = Input.Hand(Handed.Left); - Controller l_con = Input.Controller(Handed.Left); - // l_hld = l_con.pose; - l_hld = l_hnd.palm; - // l_aim = l_con.aim; + l_con = Input.Controller(Handed.Left); r_hnd = Input.Hand(Handed.Right); - Controller r_con = Input.Controller(Handed.Right); - // r_hld = r_con.pose; - r_hld = r_hnd.palm; - // r_aim = r_con.aim; - + r_con = Input.Controller(Handed.Right); btn_l_grip.Step(l_con.grip > 0.5f || l_hnd.IsGripped); btn_r_grip.Step(r_con.grip > 0.5f || r_hnd.IsGripped); + // double grip? + btn_select.Step(r_con.x1.IsActive() || r_con.trigger > 0.5f); btn_back.Step(r_con.x2.IsActive());