diff --git a/app/Board.cs b/app/Board.cs new file mode 100644 index 0000000..aa05f1c --- /dev/null +++ b/app/Board.cs @@ -0,0 +1,115 @@ +namespace Oriels; + +public class Board { + // velocity button controls + // "center off mass" thrust vector steering + + Mesh meshCube = Mesh.Cube; + + public bool goofy = false; + + public Vec3 front, back, pos, dir, vector; + public float vel; + + float length = 1.5f; + public Board() { + front = new Vec3(0, 0, -1) * length / 2; + back = new Vec3(0, 0, 1) * length / 2; + dir = new Vec3(0, 0, -1); + vel = 0; + } + + public void Frame() { + // tilt steer ("back wheel" turns *rudder) + // button velocity controls + Con con = goofy ? Mono.inst.rig.rCon : Mono.inst.rig.lCon; + float accel = con.device.trigger; + float deccel = con.device.grip; + float lean = Mono.inst.rig.LocalPos(Mono.inst.rig.Head.position).x; + + // float length = 1.5f; + float drag = 0.1f; + float speed = 4f; + float brake = 12f; + float tight = 60f; + + + // velocity + vel *= 1f - (drag * Time.Elapsedf); + vel += accel * speed * Time.Elapsedf; + vel = MathF.Max(vel - deccel * brake * Time.Elapsedf, 0); + + // steering + vector = Quat.LookDir(dir) * Quat.FromAngles(0, lean * tight, 0) * Vec3.Forward; + back += vector * vel * Time.Elapsedf; + dir = (front - back).Normalized; + + front = back + dir * length; + pos = Vec3.Lerp(front, back, 0.5f); + + + Mono.inst.rig.pos = pos; + Mono.inst.rig.ori = Quat.LookDir(dir); + + // hover + // if (rig.lCon.gripBtn.held) { + // rig.pos.y = pid.Update(rig.LocalPos(rig.Head.position).y); + // } + + + meshCube.Draw(Material.Default, + Matrix.TRS( + Mono.inst.rig.FloorCenter, + Quat.LookDir(dir), + new Vec3(0.05f, 0.2f, 0.2f) + ) + ); + + // mini board in hand for debugging + // meshCube.Draw(Material.Default, + // Matrix.TRS( + // rig.rCon.pos, + // board.ori, + // new Vec3(0.4f, 0.1f, reach * 2) * 0.1f + // ) + // ); + // // front wheel + // meshCube.Draw(Material.Default, + // Matrix.TRS( + // rig.rCon.pos + board.dir * reach * 0.1f, + // Quat.LookDir(frontDir), + // new Vec3(0.05f, 0.2f, 0.2f) * 0.1f + // ) + // ); + + + + + + // pillars to hover through + // spawn in front every 1m away from last + if (Vec3.Distance(pos, lastSpawnPos) > 1f) { + // odd or even + float chirality = pillarIndex % 2 == 0 ? 1f : -1f; + pillars[pillarIndex] = pos + Quat.LookDir(dir) * new Vec3(chirality * 8 * Mono.inst.noise.uvalue, 0, -24); + + lastSpawnPos = pos; + + pillarIndex++; + if (pillarIndex >= pillars.Length) { pillarIndex = 0; } + } + + for (int i = 0; i < pillars.Length; i++) { + meshCube.Draw(Material.Default, + Matrix.TRS( + pillars[i], + Quat.Identity, + new Vec3(0.1f, 20f, 0.1f) + ) + ); + } + } + Vec3[] pillars = new Vec3[64]; + int pillarIndex = 0; + Vec3 lastSpawnPos = Vec3.Zero; +} \ No newline at end of file diff --git a/app/Mono.cs b/app/Mono.cs index 9d1d14e..a279cbe 100644 --- a/app/Mono.cs +++ b/app/Mono.cs @@ -45,12 +45,12 @@ public class Mono { dofs = new dof[] { // new StretchFinger(), - new WaveCursor() { handed = Handed.Left }, - new WaveCursor() { handed = Handed.Right }, - new Trackballer() { handed = Handed.Left }, + new WaveCursor() { handed = Handed.Left }, + new WaveCursor() { handed = Handed.Right }, + new Trackballer() { handed = Handed.Left }, new Trackballer() { handed = Handed.Right }, - // new StretchCursor() { }, - // new StretchCursor() { }, + // new StretchCursor() { }, + // new StretchCursor() { }, }; } @@ -77,10 +77,6 @@ public class Mono { // Space.Mono spaceMono = new Space.Mono(); Greenyard.Mono greenyard = new Greenyard.Mono(); - Board board = new Board(); - - - PullRequest.PID pid = new PullRequest.PID(8, 0.8f); // ------------------------------------------------- @@ -89,11 +85,6 @@ public class Mono { rig.Step(); // ------------------------------------------------- - - // THE BACK BREAKING PROBLEM WITH THE CURRENT DOF SYSTEM - // is that I can't pass input to it in a dynamic way - // a pointer would solve this problem but c# doesn't have pointers - // except for unsafe code, which opens up a whole new can of worms // dof.Frame(); dofs[0].Frame(); @@ -128,7 +119,6 @@ public class Mono { ); - // rGlove.Step(); lGlove.Step(); // rBlock.Step(); lBlock.Step(); @@ -145,7 +135,6 @@ public class Mono { // spaceMono.Frame(); greenyard.Frame(); - // board.Frame(); // ------------------------------------------------- @@ -196,123 +185,15 @@ public class Mono { public float stretchStr = 0.333f; public float playerY = 0; - - } +/* + COMMENTS + + debug bool + rendering the raw output + particularly for hand tracking dofs (so Moses can better test them!) + raw = 0.333f alpha ~ -[Serializable] -public class Board { - // velocity button controls - // "center off mass" thrust vector steering - - Mesh meshCube = Mesh.Cube; - - public bool goofy = false; - - public Vec3 front, back, pos, dir, vector; - public float vel; - - float length = 1.5f; - public Board() { - front = new Vec3(0, 0, -1) * length / 2; - back = new Vec3(0, 0, 1) * length / 2; - dir = new Vec3(0, 0, -1); - vel = 0; - } - - public void Frame() { - // tilt steer ("back wheel" turns *rudder) - // button velocity controls - Con con = goofy ? Mono.inst.rig.rCon : Mono.inst.rig.lCon; - float accel = con.device.trigger; - float deccel = con.device.grip; - float lean = Mono.inst.rig.LocalPos(Mono.inst.rig.Head.position).x; - - // float length = 1.5f; - float drag = 0.1f; - float speed = 4f; - float brake = 12f; - float tight = 60f; - - - // velocity - vel *= 1f - (drag * Time.Elapsedf); - vel += accel * speed * Time.Elapsedf; - vel = MathF.Max(vel - deccel * brake * Time.Elapsedf, 0); - - // steering - vector = Quat.LookDir(dir) * Quat.FromAngles(0, lean * tight, 0) * Vec3.Forward; - back += vector * vel * Time.Elapsedf; - dir = (front - back).Normalized; - - front = back + dir * length; - pos = Vec3.Lerp(front, back, 0.5f); - - - Mono.inst.rig.pos = pos; - Mono.inst.rig.ori = Quat.LookDir(dir); - - // hover - // if (rig.lCon.gripBtn.held) { - // rig.pos.y = pid.Update(rig.LocalPos(rig.Head.position).y); - // } - - - meshCube.Draw(Material.Default, - Matrix.TRS( - Mono.inst.rig.FloorCenter, - Quat.LookDir(dir), - new Vec3(0.05f, 0.2f, 0.2f) - ) - ); - - // mini board in hand for debugging - // meshCube.Draw(Material.Default, - // Matrix.TRS( - // rig.rCon.pos, - // board.ori, - // new Vec3(0.4f, 0.1f, reach * 2) * 0.1f - // ) - // ); - // // front wheel - // meshCube.Draw(Material.Default, - // Matrix.TRS( - // rig.rCon.pos + board.dir * reach * 0.1f, - // Quat.LookDir(frontDir), - // new Vec3(0.05f, 0.2f, 0.2f) * 0.1f - // ) - // ); - - - - - - // pillars to hover through - // spawn in front every 1m away from last - if (Vec3.Distance(pos, lastSpawnPos) > 1f) { - // odd or even - float chirality = pillarIndex % 2 == 0 ? 1f : -1f; - pillars[pillarIndex] = pos + Quat.LookDir(dir) * new Vec3(chirality * 8 * Mono.inst.noise.uvalue, 0, -24); - - lastSpawnPos = pos; - - pillarIndex++; - if (pillarIndex >= pillars.Length) { pillarIndex = 0; } - } - - for (int i = 0; i < pillars.Length; i++) { - meshCube.Draw(Material.Default, - Matrix.TRS( - pillars[i], - Quat.Identity, - new Vec3(0.1f, 20f, 0.1f) - ) - ); - } - } - Vec3[] pillars = new Vec3[64]; - int pillarIndex = 0; - Vec3 lastSpawnPos = Vec3.Zero; -} \ No newline at end of file +*/ \ No newline at end of file diff --git a/app/dofs/oriel/Oriel.cs b/app/dofs/oriel/Oriel.cs index 3db19d4..1a4c7e1 100644 --- a/app/dofs/oriel/Oriel.cs +++ b/app/dofs/oriel/Oriel.cs @@ -339,4 +339,15 @@ public class Oriel { new Vec3(1, 1, -1), new Vec3(-1, 1, -1), new Vec3(1, -1, -1), new Vec3(-1, -1, -1) }; -} \ No newline at end of file +} + + +/* + COMMENTS + + try rendering as additive for an AR effect! + + compositor + multi-oriel requires a compositor approach + even if you just start with input management +*/ \ No newline at end of file diff --git a/app/dofs/stretch-cursor/wave/WaveCursor.cs b/app/dofs/stretch-cursor/wave/WaveCursor.cs index 47dd256..a3d97b4 100644 --- a/app/dofs/stretch-cursor/wave/WaveCursor.cs +++ b/app/dofs/stretch-cursor/wave/WaveCursor.cs @@ -27,8 +27,6 @@ class WaveCursor : dof { cursor.orientation = hand.palm.orientation; } - - // Demo(); } public float deadzone = 0.03f; @@ -96,4 +94,10 @@ class WaveCursor : dof { ); } } -} \ No newline at end of file +} + + +/* + COMMENTS + +*/ \ No newline at end of file diff --git a/app/dofs/trackballer/Trackballer.cs b/app/dofs/trackballer/Trackballer.cs index 794494d..5ea8b04 100644 --- a/app/dofs/trackballer/Trackballer.cs +++ b/app/dofs/trackballer/Trackballer.cs @@ -72,32 +72,31 @@ class Trackballer : dof { Mesh.Cube.Draw(Mono.inst.matHolo, Matrix.TRS(anchor, ori, 0.04f), new Color(0, outT, 0)); } - - - // pad momentum! - // like we did w/ vader life alyx immortal - // all the difference in the world! - // and makes for the third iteration of the trackballer - - - Quat newOri = momentum * ori; if (new Vec3(newOri.x, newOri.y, newOri.z).LengthSq > 0) { ori = newOri; } - - // show that you are about to boolean in and out - - // trackballer demo - // fly around a "ship" with the cursor - // and turn it with the thumb trackballer } // design public Handed handed = Handed.Left; public float[] layer = new float[] { 0.00333f, 0.02f, 0.0666f }; - - - public float scale = 1; } + + +/* + COMMENTS + + distinct interactions to account for (relative to palm orientation) + w/rating assuming perfect tracking + y swipe (10/10) + z swipe (05/10) + x spin (02/10) + + how reliable is the provided palm orientation? + + show when you are about to boolean + + 2d pad? +*/ \ No newline at end of file