hand input
This commit is contained in:
parent
d2b4bc5b85
commit
3ee827ad1f
1 changed files with 72 additions and 56 deletions
128
src/Rig.cs
128
src/Rig.cs
|
@ -6,10 +6,17 @@ static class Rig
|
||||||
{
|
{
|
||||||
public static Pose head = Pose.Identity;
|
public static Pose head = Pose.Identity;
|
||||||
|
|
||||||
|
public static Hand l_hnd;
|
||||||
|
public static Hand r_hnd;
|
||||||
|
|
||||||
public static DeltaBool btn_select = new(false);
|
public static DeltaBool btn_select = new(false);
|
||||||
public static DeltaBool btn_grip = new(false);
|
public static DeltaBool btn_l_grip = new(false);
|
||||||
|
public static DeltaBool btn_r_grip = new(false);
|
||||||
public static DeltaBool btn_back = new(false);
|
public static DeltaBool btn_back = new(false);
|
||||||
|
|
||||||
|
public static Grab? l_held = null;
|
||||||
|
public static Grab? r_held = null;
|
||||||
|
|
||||||
public static Pose l_hld, l_aim, r_hld, r_aim;
|
public static Pose l_hld, l_aim, r_hld, r_aim;
|
||||||
|
|
||||||
public static Vec3 fullstick = Vec3.Up;
|
public static Vec3 fullstick = Vec3.Up;
|
||||||
|
@ -27,64 +34,73 @@ static class Rig
|
||||||
head = Input.Head;
|
head = Input.Head;
|
||||||
|
|
||||||
// flatscreen dev controls
|
// flatscreen dev controls
|
||||||
if (Device.Name == "Simulator")
|
// if (Device.Name == "Simulator")
|
||||||
|
// {
|
||||||
|
// btn_select.Step(Input.Key(Key.MouseLeft).IsActive());
|
||||||
|
// btn_back.Step(Input.Key(Key.MouseRight).IsActive());
|
||||||
|
|
||||||
|
// r_hld = new Pose(
|
||||||
|
// V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 0.1f, 0.5f, 1.0f),
|
||||||
|
// Quat.FromAngles(0, 0, SKMath.Sin(Time.Totalf * 6f) * 30f)
|
||||||
|
// );
|
||||||
|
// l_aim = new Pose(
|
||||||
|
// V.XYZ(SKMath.Sin(Time.Totalf * 2f) * 0.6f, 0.5f, 0.5f),
|
||||||
|
// Quat.Identity
|
||||||
|
// );
|
||||||
|
|
||||||
|
// if (Input.Key(Key.A).IsJustActive()) new_dir = new(-1, 0, 0);
|
||||||
|
// if (Input.Key(Key.S).IsJustActive()) new_dir = new(+1, 0, 0);
|
||||||
|
// if (Input.Key(Key.W).IsJustActive()) new_dir = new(0, 0, -1);
|
||||||
|
// if (Input.Key(Key.R).IsJustActive()) new_dir = new(0, 0, +1);
|
||||||
|
// if (Input.Key(Key.Shift).IsJustActive()) new_dir = new(0, -1, 0);
|
||||||
|
// if (Input.Key(Key.Space).IsJustActive()) new_dir = new(0, +1, 0);
|
||||||
|
// fullstick = new_dir.ToVec3;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Hand r_hand = Input.Hand(Handed.Right);
|
||||||
|
// [!] hand input simulates controller...
|
||||||
|
|
||||||
|
l_hnd = Input.Hand(Handed.Left);
|
||||||
|
Controller l_con = Input.Controller(Handed.Left);
|
||||||
|
// l_hld = l_con.pose;
|
||||||
|
l_hld = l_hnd.palm;
|
||||||
|
// l_aim = l_con.aim;
|
||||||
|
|
||||||
|
r_hnd = Input.Hand(Handed.Right);
|
||||||
|
Controller r_con = Input.Controller(Handed.Right);
|
||||||
|
// r_hld = r_con.pose;
|
||||||
|
r_hld = r_hnd.palm;
|
||||||
|
// r_aim = r_con.aim;
|
||||||
|
|
||||||
|
|
||||||
|
btn_l_grip.Step(l_con.grip > 0.5f || l_hnd.IsGripped);
|
||||||
|
btn_r_grip.Step(r_con.grip > 0.5f || r_hnd.IsGripped);
|
||||||
|
|
||||||
|
btn_select.Step(r_con.x1.IsActive() || r_con.trigger > 0.5f);
|
||||||
|
btn_back.Step(r_con.x2.IsActive());
|
||||||
|
|
||||||
|
bool con_tracked = r_con.trackedPos > TrackState.Lost;
|
||||||
|
// bool hand_tracked = Input.HandSource(Handed.Right) > HandSource.None;
|
||||||
|
if (con_tracked)
|
||||||
{
|
{
|
||||||
btn_select.Step(Input.Key(Key.MouseLeft).IsActive());
|
|
||||||
btn_back.Step(Input.Key(Key.MouseRight).IsActive());
|
|
||||||
|
|
||||||
r_hld = new Pose(
|
Vec2 stick = r_con.stick;
|
||||||
V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 0.1f, 0.5f, 1.0f),
|
Quat stick_rot = Quat.FromAngles(stick.y * -90, 0, stick.x * +90);
|
||||||
Quat.FromAngles(0, 0, SKMath.Sin(Time.Totalf * 6f) * 30f)
|
float stick_sign = r_con.IsStickClicked ? -1 : +1;
|
||||||
);
|
r_con_stick = r_con.aim;
|
||||||
l_aim = new Pose(
|
// r_con_stick.position += r_con_stick.orientation * V.XYZ(0.0065f, -0.012f, -0.05f);
|
||||||
V.XYZ(SKMath.Sin(Time.Totalf * 2f) * 0.6f, 0.5f, 0.5f),
|
// r_con_stick.orientation *= Quat.FromAngles(-50, 0, 0);
|
||||||
Quat.Identity
|
fullstick = r_con_stick.orientation * stick_rot * Vec3.Up * stick_sign;
|
||||||
);
|
|
||||||
|
|
||||||
if (Input.Key(Key.A).IsJustActive()) new_dir = new(-1, 0, 0);
|
// Vec3 fullstick = r_hand.palm.orientation * Vec3.Up;
|
||||||
if (Input.Key(Key.S).IsJustActive()) new_dir = new(+1, 0, 0);
|
float ax = Maths.abs(fullstick.x);
|
||||||
if (Input.Key(Key.W).IsJustActive()) new_dir = new(0, 0, -1);
|
float ay = Maths.abs(fullstick.y);
|
||||||
if (Input.Key(Key.R).IsJustActive()) new_dir = new(0, 0, +1);
|
float az = Maths.abs(fullstick.z);
|
||||||
if (Input.Key(Key.Shift).IsJustActive()) new_dir = new(0, -1, 0);
|
if (ax > ay && ax > az) new_dir = new(Maths.sign(fullstick.x), 0, 0);
|
||||||
if (Input.Key(Key.Space).IsJustActive()) new_dir = new(0, +1, 0);
|
if (ay > ax && ay > az) new_dir = new(0, Maths.sign(fullstick.y), 0);
|
||||||
fullstick = new_dir.ToVec3;
|
if (az > ax && az > ay) new_dir = new(0, 0, Maths.sign(fullstick.z));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Hand r_hand = Input.Hand(Handed.Right);
|
|
||||||
// [!] hand input simulates controller...
|
|
||||||
Controller r_con = Input.Controller(Handed.Right);
|
|
||||||
r_hld = r_con.pose;
|
|
||||||
r_aim = r_con.aim;
|
|
||||||
|
|
||||||
Controller l_con = Input.Controller(Handed.Left);
|
|
||||||
l_hld = l_con.pose;
|
|
||||||
l_aim = l_con.aim;
|
|
||||||
|
|
||||||
bool con_tracked = r_con.trackedPos > TrackState.Lost;
|
|
||||||
// bool hand_tracked = Input.HandSource(Handed.Right) > HandSource.None;
|
|
||||||
if (con_tracked)
|
|
||||||
{
|
|
||||||
btn_select.Step(r_con.x1.IsActive() || r_con.trigger > 0.5f);
|
|
||||||
btn_grip.Step(r_con.grip > 0.5f);
|
|
||||||
btn_back.Step(r_con.x2.IsActive());
|
|
||||||
|
|
||||||
Vec2 stick = r_con.stick;
|
|
||||||
Quat stick_rot = Quat.FromAngles(stick.y * -90, 0, stick.x * +90);
|
|
||||||
float stick_sign = r_con.IsStickClicked ? -1 : +1;
|
|
||||||
r_con_stick = r_con.aim;
|
|
||||||
// r_con_stick.position += r_con_stick.orientation * V.XYZ(0.0065f, -0.012f, -0.05f);
|
|
||||||
// r_con_stick.orientation *= Quat.FromAngles(-50, 0, 0);
|
|
||||||
fullstick = r_con_stick.orientation * stick_rot * Vec3.Up * stick_sign;
|
|
||||||
|
|
||||||
// Vec3 fullstick = r_hand.palm.orientation * Vec3.Up;
|
|
||||||
float ax = Maths.abs(fullstick.x);
|
|
||||||
float ay = Maths.abs(fullstick.y);
|
|
||||||
float az = Maths.abs(fullstick.z);
|
|
||||||
if (ax > ay && ax > az) new_dir = new(Maths.sign(fullstick.x), 0, 0);
|
|
||||||
if (ay > ax && ay > az) new_dir = new(0, Maths.sign(fullstick.y), 0);
|
|
||||||
if (az > ax && az > ay) new_dir = new(0, 0, Maths.sign(fullstick.z));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue