diff --git a/app/Mono.cs b/app/Mono.cs index 4e22b53..1b27add 100644 --- a/app/Mono.cs +++ b/app/Mono.cs @@ -7,6 +7,7 @@ public class Mono { public PullRequest.Noise noise = new PullRequest.Noise(939949595); public Material matDev; + public Material matHolo; public Rig rig = new Rig(); public Scene scene = new Scene(); @@ -65,6 +66,11 @@ public class Mono { matDev = Material.Default.Copy(); matDev.SetTexture("diffuse", Tex.DevTex); + matHolo = Material.Default.Copy(); + matHolo.Transparency = Transparency.Add; + matHolo.DepthWrite = false; + matHolo.DepthTest = DepthTest.Less; + matHolo.SetTexture("diffuse", Tex.DevTex); } // ------------------------------------------------- @@ -95,6 +101,33 @@ public class Mono { dofs[2].Frame(); dofs[3].Frame(); + WaveCursor lwc = (WaveCursor)dofs[0]; + WaveCursor rwc = (WaveCursor)dofs[1]; + Trackballer ltb = (Trackballer)dofs[2]; + Trackballer rtb = (Trackballer)dofs[3]; + + lwc.Demo(ltb.ori); + rwc.Demo(rtb.ori); + + Mesh.Cube.Draw(Mono.inst.matHolo, + Matrix.TRS( + lwc.cursor.position, + ltb.ori, + 0.04f + ), + new Color(1, 0, 0) + ); + + Mesh.Cube.Draw(Mono.inst.matHolo, + Matrix.TRS( + rwc.cursor.position, + rtb.ori, + 0.04f + ), + new Color(1, 0, 0) + ); + + // rGlove.Step(); lGlove.Step(); @@ -137,6 +170,9 @@ public class Mono { // UI.Label("Player.y"); // UI.HSlider("Player.y", ref greenyard.height, 0.1f, 1.5f, 0.1f); + UI.Label("pos.y"); + UI.HSlider("pos.y", ref playerY, -1f, 1f, 0.1f); + UI.Label("trail.length"); UI.HSlider("trail.length", ref trailLen, 0.1f, 1f, 0.1f); @@ -147,6 +183,7 @@ public class Mono { UI.HSlider("str", ref stretchStr, 0.1f, 1f, 0.1f); + // flipIndex // flipGrip @@ -154,9 +191,10 @@ public class Mono { UI.WindowEnd(); } - public float trailLen = 0.333f; - public float trailScl = 1f; + public float trailLen = 0.5f; + public float trailScl = 0.2f; public float stretchStr = 0.333f; + public float playerY = 0; diff --git a/app/Oriel.cs b/app/Oriel.cs index 895d54c..0a61b6a 100644 --- a/app/Oriel.cs +++ b/app/Oriel.cs @@ -104,9 +104,9 @@ public class Oriel { // hand Trackballer tb = (Trackballer)Mono.inst.dofs[3]; - bool frameDown = tb.btnIn.frameDown; - bool held = tb.btnIn.held; - bool frameUp = tb.btnIn.frameUp; + bool frameDown = tb.btnOut.frameDown; + bool held = tb.btnOut.held; + bool frameUp = tb.btnOut.frameUp; WaveCursor wc = (WaveCursor)Mono.inst.dofs[1]; cursor = wc.cursor.position; @@ -309,12 +309,12 @@ public class Oriel { } } - meshCube.Draw(matClear, + meshCube.Draw(Mono.inst.matHolo, Matrix.TRS(cursor, cursorOri, new Vec3(0.02f, 0.005f, 0.02f)), cursorColor ); - meshSphere.Draw(matClear, + meshSphere.Draw(Mono.inst.matHolo, Matrix.TS(cursor, new Vec3(1f, 1f, 1f) * cursorRadius * 2), new Color(0.1f, 0.1f, 0.1f) ); diff --git a/app/Rig/Rig.cs b/app/Rig/Rig.cs index 8fb3de8..c9cf099 100644 --- a/app/Rig/Rig.cs +++ b/app/Rig/Rig.cs @@ -44,12 +44,12 @@ public class Rig { public Vec3 LocalPos(Vec3 p) { - return ori.Inverse * (p - pos); + return ori.Inverse * (p - (pos + Vec3.Up * Mono.inst.playerY)); } public void Step() { - Renderer.CameraRoot = Matrix.TR(pos, ori); + Renderer.CameraRoot = Matrix.TR((pos + Vec3.Up * Mono.inst.playerY), ori); // Controllers rCon.Step(true); diff --git a/app/dofs/stretch-cursor/wave/WaveCursor.cs b/app/dofs/stretch-cursor/wave/WaveCursor.cs index 2c15799..f245f75 100644 --- a/app/dofs/stretch-cursor/wave/WaveCursor.cs +++ b/app/dofs/stretch-cursor/wave/WaveCursor.cs @@ -28,7 +28,7 @@ class WaveCursor : dof { } - Demo(); + // Demo(); } public float deadzone = 0.1f; @@ -60,8 +60,8 @@ class WaveCursor : dof { Vec3[] yR = new Vec3[64]; Vec3[] zL = new Vec3[64]; Vec3[] zR = new Vec3[64]; - void Demo() { - Trail(mm, cursor.position); + public void Demo(Quat ori) { + Trail(mm, cursor.position + ori * new Vec3(0, 0, 0.04f)); // Trail(xL, smoothPos + cursor.orientation * new Vec3(-1, 0, 0) * 0.1f); // Trail(xR, smoothPos + cursor.orientation * new Vec3( 1, 0, 0) * 0.1f); @@ -84,12 +84,12 @@ class WaveCursor : dof { } Vec3 from = i > 0 ? points[i - 1] : nextPos; - + Quat ori = Quat.LookDir(PullRequest.Direction(points[i], from)); Mesh.Cube.Draw( - Material.Default, + Mono.inst.matHolo, Matrix.TRS( - points[i], - Quat.LookDir(PullRequest.Direction(points[i], from)), + points[i] + ori * new Vec3(0, 0, 0.01f) * Mono.inst.trailScl, + ori, new Vec3(0.01f, 0.01f, 0.02f) * Mono.inst.trailScl ), Color.HSV(i / (float)len, 1, 1) diff --git a/app/dofs/trackballer/Trackballer.cs b/app/dofs/trackballer/Trackballer.cs index adf9489..794494d 100644 --- a/app/dofs/trackballer/Trackballer.cs +++ b/app/dofs/trackballer/Trackballer.cs @@ -24,33 +24,35 @@ class Trackballer : dof { Vec3 pad = anchor.SnapToLine( thumbKnuckle, thumbTip, true, - out float t, 0, 0.9f + out float t, 0.666f, 1f ); // t = 1 - t; + // scale to 0.666f - 1f + t = (t - 0.666f) / 0.334f; t = t * t; t = 1 - t; pad += hand.Get(FingerId.Thumb, JointId.Tip).orientation * -Vec3.Up * 0.00666f * t; Vec3 localPad = mAnchorInv.Transform(pad); - Lines.Add(thumbTip, thumbKnuckle, Color.White, 0.002f); - Mesh.Sphere.Draw(Mono.inst.matDev, Matrix.TRS(pad, hand.palm.orientation, 0.004f), new Color(0, 1, 0)); + // Lines.Add(thumbTip, thumbKnuckle, Color.White, 0.002f); + Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(pad, hand.palm.orientation, 0.004f), new Color(0, 1, 0)); - Color color = Color.White; - if (btnIn.held) { + + if (btnIn.held) { btnIn.Step(localPad.Length < layer[1]); } else { btnIn.Step(localPad.Length < layer[0]); } - color = btnIn.held ? new Color(1, 0, 0) : color; + float inT = btnIn.held ? 1 : 0.333f; if (btnOut.held) { btnOut.Step(localPad.Length > layer[1]); } else { btnOut.Step(localPad.Length > layer[2]); } - color = btnOut.held ? new Color(0, 1, 0) : color; + float outT = btnOut.held ? 1 : 0.333f; - if (btnIn.held) { + if (btnIn.held) { delta = momentum = Quat.Identity; } else { if (localPad.Length < layer[1]) { @@ -66,7 +68,8 @@ class Trackballer : dof { oldLocalPad = localPad; // Draw - Mesh.Cube.Draw(Mono.inst.matDev, Matrix.TRS(anchor, ori, 0.04f), color); + Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(anchor, ori, 0.04f), new Color(inT, 0, 0)); + Mesh.Cube.Draw(Mono.inst.matHolo, Matrix.TRS(anchor, ori, 0.04f), new Color(0, outT, 0)); }