reach cursor deadzone
This commit is contained in:
parent
10029f21d3
commit
63acd14576
2 changed files with 40 additions and 4 deletions
|
@ -40,7 +40,7 @@ public class Monolith {
|
||||||
Mesh cube = Default.MeshCube;
|
Mesh cube = Default.MeshCube;
|
||||||
|
|
||||||
public void Run() {
|
public void Run() {
|
||||||
Renderer.SetClip(0.0f, 1000f);
|
Renderer.SetClip(0.02f, 1000f);
|
||||||
// Renderer.
|
// Renderer.
|
||||||
// mic = new Mic();
|
// mic = new Mic();
|
||||||
Vec3 pos = new Vec3(0, 0, 0);
|
Vec3 pos = new Vec3(0, 0, 0);
|
||||||
|
@ -90,6 +90,8 @@ public class Monolith {
|
||||||
bool rightGripping = false, leftGripping = false;
|
bool rightGripping = false, leftGripping = false;
|
||||||
bool gripLeft = false;
|
bool gripLeft = false;
|
||||||
|
|
||||||
|
bool rightGripDown = false, leftGripDown = false;
|
||||||
|
|
||||||
|
|
||||||
float grindDir = 1f;
|
float grindDir = 1f;
|
||||||
bool grinding = false;
|
bool grinding = false;
|
||||||
|
@ -197,11 +199,41 @@ public class Monolith {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rCon.grip > 0.5f) {
|
if (rCon.grip > 0.5f) {
|
||||||
leftReachCursor.origin = lShoulder.orientation.Inverse * (rCon.pose.position - lShoulder.position);
|
Vec3 toPos = lShoulder.orientation.Inverse * (rCon.pose.position - lShoulder.position);
|
||||||
|
if (!rightGripDown) {
|
||||||
|
float deadzone = Vec3.Distance(leftReachCursor.origin, toPos);
|
||||||
|
if (deadzone < 0.1f) {
|
||||||
|
leftReachCursor.deadzone = deadzone;
|
||||||
|
rightGripDown = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightGripDown) {
|
||||||
|
leftReachCursor.origin = toPos;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
leftReachCursor.deadzone = 0;
|
||||||
|
rightGripDown = false;
|
||||||
}
|
}
|
||||||
if (lCon.grip > 0.5f) {
|
if (lCon.grip > 0.5f) {
|
||||||
rightReachCursor.origin = rShoulder.orientation.Inverse * (lCon.pose.position - rShoulder.position);
|
Vec3 toPos = rShoulder.orientation.Inverse * (lCon.pose.position - rShoulder.position);
|
||||||
|
if (!leftGripDown) {
|
||||||
|
float deadzone = Vec3.Distance(rightReachCursor.origin, toPos);
|
||||||
|
if (deadzone < 0.1f) {
|
||||||
|
rightReachCursor.deadzone = deadzone;
|
||||||
|
leftGripDown = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftGripDown) {
|
||||||
|
rightReachCursor.origin = toPos;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rightReachCursor.deadzone = 0;
|
||||||
|
leftGripDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rightReachCursor.Step(new Pose[] { rCon.pose }, 0.2f);
|
rightReachCursor.Step(new Pose[] { rCon.pose }, 0.2f);
|
||||||
|
|
|
@ -39,9 +39,11 @@ public class ReachCursor : SpatialCursor {
|
||||||
this.min = 1f;
|
this.min = 1f;
|
||||||
this.str = 3f;
|
this.str = 3f;
|
||||||
this.max = 10f;
|
this.max = 10f;
|
||||||
|
this.deadzone = 0;
|
||||||
}
|
}
|
||||||
Vec3 pos;
|
Vec3 pos;
|
||||||
public Vec3 origin;
|
public Vec3 origin;
|
||||||
|
public float deadzone;
|
||||||
public override void Step(Pose[] poses, float scalar) {
|
public override void Step(Pose[] poses, float scalar) {
|
||||||
pos = poses[0].position;
|
pos = poses[0].position;
|
||||||
Vec3 wrist = mono.Wrist(chirality).position;
|
Vec3 wrist = mono.Wrist(chirality).position;
|
||||||
|
@ -52,6 +54,8 @@ public class ReachCursor : SpatialCursor {
|
||||||
str = min + (scalar * max);
|
str = min + (scalar * max);
|
||||||
|
|
||||||
float stretch = Vec3.Distance(from, wrist);
|
float stretch = Vec3.Distance(from, wrist);
|
||||||
|
stretch = Math.Max(stretch - deadzone, 0);
|
||||||
|
|
||||||
Vec3 dir = (pos - from).Normalized;
|
Vec3 dir = (pos - from).Normalized;
|
||||||
p0 = pos + dir * stretch * str;
|
p0 = pos + dir * stretch * str;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue