From 92a77db8d663f07e01bdff0b14e4b011a1ff9fc8 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Tue, 30 Nov 2021 02:30:38 -0500 Subject: [PATCH] blocks! --- Program.cs | 43 +++++++++++++++++++++++++++++++++++++------ README.md | 2 +- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Program.cs b/Program.cs index 02d58db..f222e1a 100644 --- a/Program.cs +++ b/Program.cs @@ -23,8 +23,11 @@ public class Mono { public Vec3 dragStart, posStart; public float railT; + Bounds[] blocks; + Mesh ball = Default.MeshSphere; - Material ballMat = Default.Material; + Material mat = Default.Material; + Mesh cube = Default.MeshCube; public void Run() { // mic = new Mic(); @@ -32,12 +35,20 @@ public class Mono { Cursors cursors = new Cursors(this); - MonoNet net = new MonoNet(this); - net.Start(); - Oriel oriel = new Oriel(); oriel.Start(); + blocks = new Bounds[] { + new Bounds(new Vec3(-1, 0, -4), Vec3.One * 0.5f), + new Bounds(new Vec3(0, 0, -4), Vec3.One * 0.5f), + new Bounds(new Vec3(1, 0, -4), Vec3.One * 0.5f), + }; + int blockIndex = -1; + Vec3 blockOffset = Vec3.Zero; + + MonoNet net = new MonoNet(this); + net.Start(); + // ColorCube cube = new ColorCube(); // OrbitalView.strength = 4; // OrbitalView.distance = 0.4f; @@ -93,7 +104,6 @@ public class Mono { if (domCon.IsX1JustPressed) { movePress = Time.Totalf; dragStart = cursor.p0; - posStart = pos; } if (domCon.IsX1Pressed) { pos -= cursor.p0 - dragStart; @@ -103,7 +113,28 @@ public class Mono { pos = cursor.p0 - (Input.Head.position - pos); } // pos.x = (float)Math.Sin(Time.Total * 0.1f) * 0.5f; - + + // Solid solid = new Solid(Vec3.Up * -2, Quat.Identity, SolidType.Immovable); + // make some blocks you can move around with cursor.p0 + // no collision detection, just a visual example + if (domCon.grip > 0.5f) { + if (blockIndex < 0) { + for (int i = 0; i < blocks.Length; i++) { + if (blocks[i].Contains(cursor.p0)) { + blockIndex = i; + blockOffset = cursor.p0 - blocks[i].center; + break; + } + } + } else { + blocks[blockIndex].center = cursor.p0 - blockOffset; + } + } else { + blockIndex = -1; + } + for (int i = 0; i < blocks.Length; i++) { + cube.Draw(mat, Matrix.TS(blocks[i].center, blocks[i].dimensions)); + } // cursor.Step(lHand.aim, rHand.aim); cursor.DrawSelf(); // net.me.cursorA = Vec3.Up * (float)Math.Sin(Time.Total); diff --git a/README.md b/README.md index 4450212..657a5f2 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ switch between cursors with a button (quick press(b) on both hands to switch/cyc movement: - ~~fullstick~~ - ~~teleport and drag~~ -- bezier rails +- ~~bezier rails~~ blocks you can manipulate with spatial cursors (trackballer) and color them with the color cube (player colors