From f6db3e8981241a1d1108d577ff48e3beb4fcc783 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Mon, 2 May 2022 10:56:57 -0400 Subject: [PATCH] board basics --- app/Mono.cs | 41 +++++++++++++++++++++++++++++++++++------ app/MonoNet.cs | 14 +++++++------- app/Rig/Rig.cs | 15 ++++++++++++++- app/Scene.cs | 19 +++++++++++++++++++ 4 files changed, 75 insertions(+), 14 deletions(-) diff --git a/app/Mono.cs b/app/Mono.cs index 03915cf..a9e430a 100644 --- a/app/Mono.cs +++ b/app/Mono.cs @@ -56,20 +56,22 @@ public class Mono { Renderer.SetClip(0.02f, 1000f); } - Vec3 pos = new Vec3(0f, 0f, 0f); // see below + Vec3 pos = new Vec3(0f, 0f, 0f); + Quat ori = Quat.Identity; + float yy = 0f; public void Step() { - Renderer.CameraRoot = Matrix.T(pos); + Renderer.CameraRoot = Matrix.TR(pos, ori); rig.Step(); scene.Step(); // ------------------------------------------------- - rGlove.Step(); lGlove.Step(); + // rGlove.Step(); lGlove.Step(); - rBlock.Step(); lBlock.Step(); + // rBlock.Step(); lBlock.Step(); - cubicCon.Step(); + // cubicCon.Step(); // Vec3 fullstick = rig.Fullstick(false); @@ -77,7 +79,34 @@ public class Mono { // oriel.Step(); - pos.z += Time.Elapsedf * 0.1f; + // board + // use the active con position to point from the head *top down perspective (y = 0) + // to determine the board direction + Con handleCon = rig.HandleCon(); + Vec3 boardDir = (handleCon.pos.X0Z - rig.Head().position.X0Z).Normalized; + Quat boardRot = Quat.LookDir(boardDir); + + // boardDir = (handleCon.pos.X0Z - head.position.X0Z).normalized + // boardRot = Quat.LookDir(boardDir) + // boardPos += boardDir * handleCon.trigger * speed * delta + + pos += boardDir * handleCon.device.trigger * Time.Elapsedf; + yy += handleCon.device.stick.x * 90 * Time.Elapsedf; + ori = Quat.FromAngles(0f, yy, 0f); // stick.x -> twist z + + + Vec3 boardPos = pos + Vec3.Up * -1.35f; // rig.Head().position.X0Z + Mesh.Cube.Draw(Material.Default, Matrix.TRS(boardPos, boardRot, new Vec3(0.18f, 0.06f, 0.6f))); + + // having a board underneath my feet and a virtual handlebar in my hand + // did a lot to improve the quality of the experience (+immersion -sickness) + + // don't do more just yet! + // these are all important, but lets start small and scrappy + it's 9AM + // twist turning + // handleCon + // tighter boardDir + // lean turning (head moving in relation to hand, doesn't that happen a little already?) // ------------------------------------------------- diff --git a/app/MonoNet.cs b/app/MonoNet.cs index 6dc58cb..f1f54e0 100644 --- a/app/MonoNet.cs +++ b/app/MonoNet.cs @@ -360,13 +360,13 @@ public class Peer { PullRequest.BlockOut(Matrix.TRS(headset.position + Input.Head.Forward * -0.15f, headset.orientation, Vec3.One * 0.3f), color); } - Bezier.Draw( - mono.rGlove.virtualGlove.position, - mono.rig.rCon.pos, - mono.rig.lCon.pos, - mono.lGlove.virtualGlove.position, - new Color(1, 1, 1, 0.1f) - ); + // Bezier.Draw( + // mono.rGlove.virtualGlove.position, + // mono.rig.rCon.pos, + // mono.rig.lCon.pos, + // mono.lGlove.virtualGlove.position, + // new Color(1, 1, 1, 0.1f) + // ); for (int i = 0; i < blocks.Length; i++) { NetBlock block = blocks[i]; diff --git a/app/Rig/Rig.cs b/app/Rig/Rig.cs index 4ebd80b..f1375d9 100644 --- a/app/Rig/Rig.cs +++ b/app/Rig/Rig.cs @@ -10,6 +10,16 @@ public class Rig { public Con rCon = new Con(), lCon = new Con(); public Con Con(bool chirality) { return chirality ? rCon : lCon; } + bool handleChirality = false; + public Con HandleCon() { + return Con(handleChirality); + } + + public Pose Head() { + Pose pose = Input.Head; + pose.position += pose.orientation * Vec3.Forward * -0.1f; + return pose; + } public Pose rShoulder, lShoulder; public Pose Shoulder(bool chirality) { return chirality ? rShoulder : lShoulder; } @@ -22,8 +32,11 @@ public class Rig { rCon.Step(true); lCon.Step(false); + if (rCon.gripBtn.frameDown) { handleChirality = true; } + if (lCon.gripBtn.frameDown) { handleChirality = false; } + // Shoulders - Vec3 headPos = Input.Head.position + Input.Head.Forward * -0.15f; + Vec3 headPos = Input.Head.position + Input.Head.Forward * -0.15f; // Input.Head -> Head() ? Vec3 shoulderDir = ( (lCon.pos.X0Z - headPos.X0Z).Normalized + (rCon.pos.X0Z - headPos.X0Z).Normalized diff --git a/app/Scene.cs b/app/Scene.cs index aeaccf9..aa00e44 100644 --- a/app/Scene.cs +++ b/app/Scene.cs @@ -47,6 +47,25 @@ public class Scene { Oriel oriel = Mono.inst.oriel; data.matrix = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix); data.dimensions = oriel.bounds.dimensions; + + + + + + + + + data.dimensions = Vec3.Zero; + + + + + + + + + + buffer.Set(data);