From fd530efdccd8d9838626f651cc1529b12610da6d Mon Sep 17 00:00:00 2001 From: spatialfree Date: Mon, 10 Jan 2022 10:27:00 -0500 Subject: [PATCH] lift reach cursor --- app/Glove.cs | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/app/Glove.cs b/app/Glove.cs index 09ab35a..1ccfae8 100644 --- a/app/Glove.cs +++ b/app/Glove.cs @@ -17,49 +17,39 @@ public class Glove { Vec3 direction; public Pull? pulling = null; + float stretch; float stretchDeadzone = 0; Vec3 pullPoint; - bool planted = false; public void Step() { Pose shoulder = mono.Shoulder(chirality); Con con = mono.Con(chirality), otherCon = mono.Con(!chirality); + bool reach = con.device.IsX2Pressed; bool pull = otherCon.gripBtn.frameDown; + bool lift = con.device.IsX1Pressed; - if (!planted) { - pullPoint = con.pos; - } else { - // reach cursor + if (reach) { // shoulder stuff // pullPoint = (shoulder.orientation * origin) + shoulder.position; // shoulder.orientation.Inverse * (con.pose.position - shoulder.position) - direction = PullRequest.Direction(con.pos, pullPoint); + if (lift) { + pullPoint = con.pos + -direction * stretch; + } else { + direction = PullRequest.Direction(con.pos, pullPoint); + } + } else { + pullPoint = con.pos; } switch (pulling) { default: - if (con.device.stick.Magnitude > 0.1f) { - if (con.device.stick.y < 0f) { - planted = true; - } - } else { - planted = false; - } - if (pull) { // need the rotation of the wrist rather than the hand for this to be reliable Vec3 localPos = con.ori.Inverse * (otherCon.pos - con.pos); - if (chirality ? localPos.x < 0 : localPos.x > 0) { - pulling = Pull.Stretch; - } else { - pulling = Pull.Backhanded; - } - - stretchDeadzone = Vec3.Distance(con.pos, otherCon.pos); - } else { - stretchDeadzone = 0; + pulling = (chirality ? localPos.x < 0 : localPos.x > 0) ? Pull.Stretch : Pull.Backhanded; } + stretchDeadzone = pull ? Vec3.Distance(con.pos, otherCon.pos) : 0; virtualGlove.orientation = con.ori; break; @@ -80,8 +70,7 @@ public class Glove { pulling = null; } - float stretch = Vec3.Distance(pullPoint, con.pos); - stretch = Math.Max(stretch - stretchDeadzone, 0); + stretch = Math.Max(Vec3.Distance(pullPoint, con.pos) - stretchDeadzone, 0); virtualGlove.position = con.pos + direction * stretch * 3; Render(con.Pose(), virtualGlove);