lift reach cursor
This commit is contained in:
parent
1db659b39e
commit
fd530efdcc
1 changed files with 14 additions and 25 deletions
39
app/Glove.cs
39
app/Glove.cs
|
@ -17,49 +17,39 @@ public class Glove {
|
||||||
Vec3 direction;
|
Vec3 direction;
|
||||||
|
|
||||||
public Pull? pulling = null;
|
public Pull? pulling = null;
|
||||||
|
float stretch;
|
||||||
float stretchDeadzone = 0;
|
float stretchDeadzone = 0;
|
||||||
Vec3 pullPoint;
|
Vec3 pullPoint;
|
||||||
|
|
||||||
bool planted = false;
|
|
||||||
|
|
||||||
public void Step() {
|
public void Step() {
|
||||||
Pose shoulder = mono.Shoulder(chirality);
|
Pose shoulder = mono.Shoulder(chirality);
|
||||||
Con con = mono.Con(chirality), otherCon = mono.Con(!chirality);
|
Con con = mono.Con(chirality), otherCon = mono.Con(!chirality);
|
||||||
|
bool reach = con.device.IsX2Pressed;
|
||||||
bool pull = otherCon.gripBtn.frameDown;
|
bool pull = otherCon.gripBtn.frameDown;
|
||||||
|
bool lift = con.device.IsX1Pressed;
|
||||||
|
|
||||||
if (!planted) {
|
if (reach) {
|
||||||
pullPoint = con.pos;
|
|
||||||
} else {
|
|
||||||
// reach cursor
|
|
||||||
// shoulder stuff
|
// shoulder stuff
|
||||||
// pullPoint = (shoulder.orientation * origin) + shoulder.position;
|
// pullPoint = (shoulder.orientation * origin) + shoulder.position;
|
||||||
// shoulder.orientation.Inverse * (con.pose.position - 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) {
|
switch (pulling) {
|
||||||
default:
|
default:
|
||||||
if (con.device.stick.Magnitude > 0.1f) {
|
|
||||||
if (con.device.stick.y < 0f) {
|
|
||||||
planted = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
planted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pull) {
|
if (pull) {
|
||||||
// need the rotation of the wrist rather than the hand for this to be reliable
|
// need the rotation of the wrist rather than the hand for this to be reliable
|
||||||
Vec3 localPos = con.ori.Inverse * (otherCon.pos - con.pos);
|
Vec3 localPos = con.ori.Inverse * (otherCon.pos - con.pos);
|
||||||
if (chirality ? localPos.x < 0 : localPos.x > 0) {
|
pulling = (chirality ? localPos.x < 0 : localPos.x > 0) ? Pull.Stretch : Pull.Backhanded;
|
||||||
pulling = Pull.Stretch;
|
|
||||||
} else {
|
|
||||||
pulling = Pull.Backhanded;
|
|
||||||
}
|
|
||||||
|
|
||||||
stretchDeadzone = Vec3.Distance(con.pos, otherCon.pos);
|
|
||||||
} else {
|
|
||||||
stretchDeadzone = 0;
|
|
||||||
}
|
}
|
||||||
|
stretchDeadzone = pull ? Vec3.Distance(con.pos, otherCon.pos) : 0;
|
||||||
virtualGlove.orientation = con.ori;
|
virtualGlove.orientation = con.ori;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -80,8 +70,7 @@ public class Glove {
|
||||||
pulling = null;
|
pulling = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
float stretch = Vec3.Distance(pullPoint, con.pos);
|
stretch = Math.Max(Vec3.Distance(pullPoint, con.pos) - stretchDeadzone, 0);
|
||||||
stretch = Math.Max(stretch - stretchDeadzone, 0);
|
|
||||||
virtualGlove.position = con.pos + direction * stretch * 3;
|
virtualGlove.position = con.pos + direction * stretch * 3;
|
||||||
|
|
||||||
Render(con.Pose(), virtualGlove);
|
Render(con.Pose(), virtualGlove);
|
||||||
|
|
Loading…
Add table
Reference in a new issue