map to xr hardware
This commit is contained in:
parent
c4dc1e079f
commit
76fbe75242
2 changed files with 35 additions and 12 deletions
30
src/Arts.cs
30
src/Arts.cs
|
@ -76,14 +76,14 @@ static class Arts
|
||||||
);
|
);
|
||||||
|
|
||||||
// unit cube
|
// unit cube
|
||||||
Mesh.Cube.Draw(
|
// Mesh.Cube.Draw(
|
||||||
mat_unlit,
|
// mat_unlit,
|
||||||
Matrix.Identity,
|
// Matrix.Identity,
|
||||||
Color.Hex(0x13180AFF).ToLinear()
|
// Color.Hex(0x13180AFF).ToLinear()
|
||||||
);
|
// );
|
||||||
|
|
||||||
// enemy
|
// enemy
|
||||||
Vec3 enemy_pos = V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 1.0f, 0.5f, -1.0f);
|
Vec3 enemy_pos = V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 1.0f, 0.5f, -3.0f);
|
||||||
float enemy_rad = 0.5f;
|
float enemy_rad = 0.5f;
|
||||||
Mesh.Sphere.Draw(
|
Mesh.Sphere.Draw(
|
||||||
mat_unlit,
|
mat_unlit,
|
||||||
|
@ -91,11 +91,18 @@ static class Arts
|
||||||
Color.Hex(0x13180AFF).ToLinear()
|
Color.Hex(0x13180AFF).ToLinear()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// eyes
|
||||||
|
// Mesh.Cube.Draw(
|
||||||
|
// mat_unlit,
|
||||||
|
// Rig.head.ToMatrix().Transform(),
|
||||||
|
// Color.Hex(0x13180AFF).ToLinear()
|
||||||
|
// );
|
||||||
|
|
||||||
// blade
|
// blade
|
||||||
Mesh mesh = new();
|
Mesh mesh = new();
|
||||||
Quat blade_ori = Quat.FromAngles(0, 0, SKMath.Sin(Time.Totalf * 6f) * 30f);
|
Quat blade_ori = Rig.r_hld.orientation;
|
||||||
Vec3 blade_pos = V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 0.1f, 0.5f, 1.0f);
|
Vec3 blade_pos = Rig.r_hld.position;
|
||||||
Vec3 tip_pos = blade_pos + blade_ori * V.XYZ(0, 1, 0);
|
Vec3 tip_pos = blade_pos + blade_ori * V.XYZ(0, 0, 1);
|
||||||
mesh.SetData(
|
mesh.SetData(
|
||||||
new Vertex[] {
|
new Vertex[] {
|
||||||
new( blade_pos, V.XYZ(0,0,1)),
|
new( blade_pos, V.XYZ(0,0,1)),
|
||||||
|
@ -114,8 +121,8 @@ static class Arts
|
||||||
last_tip_pos = Vec3.Lerp(last_tip_pos, tip_pos, Time.Stepf / 0.1f);
|
last_tip_pos = Vec3.Lerp(last_tip_pos, tip_pos, Time.Stepf / 0.1f);
|
||||||
|
|
||||||
// revolver
|
// revolver
|
||||||
Quat rvolv_ori = Quat.Identity;
|
Quat rvolv_ori = Rig.l_aim.orientation;
|
||||||
Vec3 rvolv_pos = V.XYZ(SKMath.Sin(Time.Totalf * 2f) * 0.6f, 0.5f, 0.5f);
|
Vec3 rvolv_pos = Rig.l_aim.position;
|
||||||
|
|
||||||
Lines.Add(
|
Lines.Add(
|
||||||
rvolv_pos,
|
rvolv_pos,
|
||||||
|
@ -133,7 +140,6 @@ static class Arts
|
||||||
bool hit = hit_mag < enemy_rad;
|
bool hit = hit_mag < enemy_rad;
|
||||||
if (hit)
|
if (hit)
|
||||||
{
|
{
|
||||||
Log.Info("" + hit_mag);
|
|
||||||
float hit_dist = flat_z + (Maths.smooth_stop((enemy_rad - hit_mag) / enemy_rad) * enemy_rad);
|
float hit_dist = flat_z + (Maths.smooth_stop((enemy_rad - hit_mag) / enemy_rad) * enemy_rad);
|
||||||
Vec3 hit_pos = rvolv_pos + rvolv_ori * V.XYZ(0, 0, hit_dist);
|
Vec3 hit_pos = rvolv_pos + rvolv_ori * V.XYZ(0, 0, hit_dist);
|
||||||
Mesh.Sphere.Draw(
|
Mesh.Sphere.Draw(
|
||||||
|
|
17
src/Rig.cs
17
src/Rig.cs
|
@ -10,6 +10,8 @@ static class Rig
|
||||||
public static DeltaBool btn_grip = new(false);
|
public static DeltaBool btn_grip = new(false);
|
||||||
public static DeltaBool btn_back = new(false);
|
public static DeltaBool btn_back = new(false);
|
||||||
|
|
||||||
|
public static Pose l_hld, l_aim, r_hld, r_aim;
|
||||||
|
|
||||||
public static Vec3 fullstick = Vec3.Up;
|
public static Vec3 fullstick = Vec3.Up;
|
||||||
public static Pose r_con_stick = Pose.Identity;
|
public static Pose r_con_stick = Pose.Identity;
|
||||||
|
|
||||||
|
@ -30,6 +32,15 @@ static class Rig
|
||||||
btn_select.Step(Input.Key(Key.MouseLeft).IsActive());
|
btn_select.Step(Input.Key(Key.MouseLeft).IsActive());
|
||||||
btn_back.Step(Input.Key(Key.MouseRight).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.A).IsJustActive()) new_dir = new(-1, 0, 0);
|
||||||
if (Input.Key(Key.S).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.W).IsJustActive()) new_dir = new(0, 0, -1);
|
||||||
|
@ -43,6 +54,12 @@ static class Rig
|
||||||
// Hand r_hand = Input.Hand(Handed.Right);
|
// Hand r_hand = Input.Hand(Handed.Right);
|
||||||
// [!] hand input simulates controller...
|
// [!] hand input simulates controller...
|
||||||
Controller r_con = Input.Controller(Handed.Right);
|
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 con_tracked = r_con.trackedPos > TrackState.Lost;
|
||||||
// bool hand_tracked = Input.HandSource(Handed.Right) > HandSource.None;
|
// bool hand_tracked = Input.HandSource(Handed.Right) > HandSource.None;
|
||||||
|
|
Loading…
Add table
Reference in a new issue