cursor magement++

This commit is contained in:
spatialfree 2021-12-06 13:18:01 -05:00
parent 19b2a23a6d
commit 77448e7712
3 changed files with 33 additions and 12 deletions

View file

@ -424,7 +424,7 @@ public class MonoNet {
Quat toRot = (con.aim.orientation * heldRot * spinRot).Normalized; Quat toRot = (con.aim.orientation * heldRot * spinRot).Normalized;
Vec3 toPos = cursor + (con.aim.orientation * heldRot * spinRot).Normalized * offset; Vec3 toPos = cursor + (con.aim.orientation * heldRot * spinRot).Normalized * offset;
// cursor - offset; // cursor - offset;
if (con.stick.Magnitude > 0.1f) { if (con.stick.y > 0.1f) {
toRot = blocks[index].solid.GetPose().orientation; toRot = blocks[index].solid.GetPose().orientation;
} }
blocks[index].solid.Move(toPos, toRot); blocks[index].solid.Move(toPos, toRot);

View file

@ -131,13 +131,28 @@ public class Mono {
// Lines.Add(headPos + Vec3.Up * -0.2f, rShoulder, new Color(1, 0, 0), 0.01f); // Lines.Add(headPos + Vec3.Up * -0.2f, rShoulder, new Color(1, 0, 0), 0.01f);
// Lines.Add(headPos + Vec3.Up * -0.2f, lShoulder, new Color(1, 0, 0), 0.01f); // Lines.Add(headPos + Vec3.Up * -0.2f, lShoulder, new Color(1, 0, 0), 0.01f);
if (domCon.IsX1JustPressed) { // if (domCon.IsX1JustPressed) {
domPlanted = !domPlanted; // domPlanted = !domPlanted;
} // }
if (subCon.IsX1JustPressed) { // if (subCon.IsX1JustPressed) {
subPlanted = !subPlanted; // subPlanted = !subPlanted;
// }
if (domCon.stick.Magnitude > 0.1f) {
if (domCon.stick.y < 0f) {
domPlanted = true;
}
} else {
domPlanted = false;
} }
if (subCon.stick.Magnitude > 0.1f) {
if (subCon.stick.y < 0f) {
subPlanted = true;
}
} else {
subPlanted = false;
}
cursor.Step(new Pose[] { domCon.pose, new Pose(rShoulder, Quat.LookDir(middl)) }, 1); cursor.Step(new Pose[] { domCon.pose, new Pose(rShoulder, Quat.LookDir(middl)) }, 1);
if (!domPlanted) { if (!domPlanted) {
@ -152,7 +167,7 @@ public class Mono {
// cursor.p1 = subCursor.p0; // override *later change all one handed cursors to be dual wielded by default* // cursor.p1 = subCursor.p0; // override *later change all one handed cursors to be dual wielded by default*
cubicFlow.Step(new Pose[] { new Pose(cursor.p0, domCon.aim.orientation), new Pose(subCursor.p0, subCon.aim.orientation) }, 1); cubicFlow.Step(new Pose[] { new Pose(cursor.p0, domCon.aim.orientation), new Pose(subCursor.p0, subCon.aim.orientation) }, 1);
if (domCon.stick.Magnitude > 0.1f || subCon.stick.Magnitude > 0.1f) { if (domCon.stick.y > 0.1f || subCon.stick.y > 0.1f) {
Bezier.Draw(cubicFlow.p0, cubicFlow.p1, cubicFlow.p2, cubicFlow.p3, Color.White); Bezier.Draw(cubicFlow.p0, cubicFlow.p1, cubicFlow.p2, cubicFlow.p3, Color.White);
net.me.cursor0 = cubicFlow.p0; net.me.cursor1 = cubicFlow.p1; net.me.cursor2 = cubicFlow.p2; net.me.cursor3 = cubicFlow.p3; net.me.cursor0 = cubicFlow.p0; net.me.cursor1 = cubicFlow.p1; net.me.cursor2 = cubicFlow.p2; net.me.cursor3 = cubicFlow.p3;
} else { } else {

View file

@ -99,14 +99,17 @@ public class TwistCursor : SpatialCursor {
} }
Vec3 twistFrom = -Vec3.Right; Vec3 twistFrom = -Vec3.Right;
Quat quat; Quat quat;
public int chirality = 1;
public override void Step(Pose[] poses, float scalar) { public override void Step(Pose[] poses, float scalar) {
// chirality = Math.Sign(scalar);
Vec3 pos = poses[0].position; Vec3 pos = poses[0].position;
quat = poses[0].orientation; quat = poses[0].orientation;
Quat from = Quat.LookAt(Vec3.Zero, quat * Vec3.Forward, twistFrom); Quat from = Quat.LookAt(Vec3.Zero, quat * Vec3.Forward, twistFrom);
float twist = 1 - ((Vec3.Dot(from * Vec3.Up, quat * Vec3.Up) + 1) / 2); float twist = 1 - ((Vec3.Dot(from * Vec3.Up, quat * Vec3.Up) + 1) / 2);
// float wrap = twist - twistFrom; // wrap around 0 to 1 // float wrap = twist - twistFrom; // wrap around 0 to 1
// (wrap > 0.5f) ? 1 - wrap : wrap; // (wrap > 0.5f) ? 1 - wrap : wrap;
outty = Vec3.Dot(from * Vec3.Up, quat * Vec3.Right * chirality) > 0;
p0 = pos + quat * Vec3.Forward * twist * str; p0 = pos + quat * Vec3.Forward * twist * str;
// model.Draw(Matrix.TS(p0, 0.02f)); // model.Draw(Matrix.TS(p0, 0.02f));
@ -118,6 +121,8 @@ public class TwistCursor : SpatialCursor {
twistFrom = quat * Vec3.Up; // -Vec3.Right * chirality; twistFrom = quat * Vec3.Up; // -Vec3.Right * chirality;
} }
public bool outty;
} }
public class CubicFlow : SpatialCursor { public class CubicFlow : SpatialCursor {
@ -135,8 +140,9 @@ public class CubicFlow : SpatialCursor {
Pose sub = poses[1]; Pose sub = poses[1];
Controller domCon = Input.Controller(Handed.Right); Controller domCon = Input.Controller(Handed.Right);
Controller subCon = Input.Controller(Handed.Left); Controller subCon = Input.Controller(Handed.Left);
subTwist.chirality = -1;
if (domCon.stick.Magnitude < 0.1f) { if (domCon.stick.y < 0.1f) {
domTwist.Calibrate(); domTwist.Calibrate();
domTwisting = false; domTwisting = false;
} else { } else {
@ -147,7 +153,7 @@ public class CubicFlow : SpatialCursor {
} }
domTwist.Step(new Pose[] { dom }, scalar); domTwist.Step(new Pose[] { dom }, scalar);
if (subCon.stick.Magnitude < 0.1f) { if (subCon.stick.y < 0.1f) {
subTwist.Calibrate(); subTwist.Calibrate();
subTwisting = false; subTwisting = false;
} else { } else {
@ -164,12 +170,12 @@ public class CubicFlow : SpatialCursor {
p3 = sub.position; p3 = sub.position;
if (domUp) { // domUp if (domTwist.outty) { // domUp
p0 = domTwist.p0; p0 = domTwist.p0;
p1 = dom.position; p1 = dom.position;
} }
if (subUp) { if (subTwist.outty) {
p2 = sub.position; p2 = sub.position;
p3 = subTwist.p0; p3 = subTwist.p0;
} }