handed arrays of input data

This commit is contained in:
ethan merchant 2024-12-21 13:59:00 -05:00
parent 9d97b091e7
commit 0b5e6ee9da
2 changed files with 27 additions and 21 deletions

View file

@ -293,7 +293,6 @@ static class Arts
Color.White
);
VFX.Play(min_hit_pos);
}
}

View file

@ -7,10 +7,19 @@ static class Rig
public static Pose head = Pose.Identity;
public static DeltaBool btn_select = new(false);
public static DeltaBool btn_grip = new(false);
public static DeltaBool btn_back = new(false);
public static Pose l_hld, l_aim, r_hld, r_aim;
public static DeltaBool[] btn_grip;
public static DeltaBool l_btn_grip => btn_grip[(int)Handed.Left];
public static DeltaBool r_btn_grip => btn_grip[(int)Handed.Right];
public static Pose[] pose_hld;
public static Pose l_hld => pose_hld[(int)Handed.Left];
public static Pose r_hld => pose_hld[(int)Handed.Right];
public static Pose[] pose_aim;
public static Pose l_aim => pose_aim[(int)Handed.Left];
public static Pose r_aim => pose_aim[(int)Handed.Right];
public static Vec3 fullstick = Vec3.Up;
public static Pose r_con_stick = Pose.Identity;
@ -19,7 +28,9 @@ static class Rig
public static void Init()
{
btn_grip = new DeltaBool[] { new(false), new(false) };
pose_hld = new Pose[] { new(), new() };
pose_aim = new Pose[] { new(), new() };
}
public static void Frame()
@ -32,11 +43,11 @@ static class Rig
btn_select.Step(Input.Key(Key.MouseLeft).IsActive());
btn_back.Step(Input.Key(Key.MouseRight).IsActive());
r_hld = new Pose(
pose_hld[(int)Handed.Right] = new Pose(
V.XYZ(SKMath.Sin(Time.Totalf * 6f) * 0.6f * 0.0f, 0.5f, 1.0f),
Quat.FromAngles(0, 0, 45) * Quat.FromAngles(0, SKMath.Sin(Time.Totalf * 6f) * 60f, 0)
);
l_aim = new Pose(
pose_aim[(int)Handed.Left] = new Pose(
V.XYZ(1.0f, 0.5f, 0.5f), // V.XYZ(SKMath.Sin(Time.Totalf * 2f) * 0.6f, 0.5f, 0.5f),
Quat.Identity
);
@ -51,23 +62,19 @@ static class Rig
}
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;
btn_grip[(int)Handed.Left].Step(l_con.grip > 0.5f);
pose_hld[(int)Handed.Left] = l_con.pose;
pose_aim[(int)Handed.Left] = l_con.aim;
Controller r_con = Input.Controller(Handed.Right);
btn_grip[(int)Handed.Right].Step(r_con.grip > 0.5f);
pose_hld[(int)Handed.Right] = r_con.pose;
pose_aim[(int)Handed.Right] = r_con.aim;
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(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);