lift reach cursor
This commit is contained in:
parent
1db659b39e
commit
fd530efdcc
1 changed files with 14 additions and 25 deletions
37
app/Glove.cs
37
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)
|
||||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue