diff --git a/add/skinned_test.glb b/add/skinned_test.glb new file mode 100644 index 0000000..45f209c Binary files /dev/null and b/add/skinned_test.glb differ diff --git a/app/Glove.cs b/app/Glove.cs index eb44555..56cf14a 100644 --- a/app/Glove.cs +++ b/app/Glove.cs @@ -130,6 +130,7 @@ public class Glove { // that way we can render the same way for all peers static Mesh mesh = Default.MeshCube; static Material mat = Default.Material; + static Model model = Model.FromFile("skinned_test.glb", Shader.Default); public void Render(Pose glove, Pose virtualGlove, Pose wrist, float stretch, float twist, bool chirality) { Lines.Add(pullPoint, glove.position, new Color(1, 0, 1), 0.005f); Lines.Add(glove.position, virtualGlove.position, new Color(0, 1, 1), 0.005f); @@ -140,11 +141,11 @@ public class Glove { int segments = twistAbs == 0 ? -1 : 6 + (int)(twistAbs * 10); LinePoint[] linePoints = new LinePoint[segments + 2]; linePoints[0] = new LinePoint(twistStuff, new Color(1, 1, 0), 0.005f); + for (int i = 0; i <= segments; i++) { float tw = twistAbs * Math.Min(i / (float)(segments - 1), 1); tw *= chirality ? 1 : -1; tw *= twist > 0 ? 1 : -1; - // spiral 3 float tighten = Math.Max(1 - (twistAbs / 9), 0); float radius = i == segments ? 0.06f : 0.05f * (1 - (1 - i / (float)segments) * (1 - tighten)); Vec3 nextPos = twistStuff + projection * new Vec3(SKMath.Sin(tw * SKMath.Pi), SKMath.Cos(tw * SKMath.Pi), 0) * radius; @@ -154,7 +155,27 @@ public class Glove { } Lines.Add(linePoints); - mesh.Draw(mat, glove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f) / 3)); - mesh.Draw(mat, virtualGlove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f))); + mesh.Draw(mat, glove.ToMatrix(new Vec3(0.025f, 0.025f, 0.025f) / 3)); + mesh.Draw(mat, virtualGlove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f) / 3)); + // Lines.AddAxis(glove); + // Handed handed = chirality ? Handed.Right : Handed.Left; + // Hand hand = Input.Hand(handed); + // HandJoint[] joints = hand.fingers; + // for (int i = 0; i < joints.Length; i++) { + // joints[i].position = (joints[i].position - glove.position) + virtualGlove.position; + // } + // Input.HandOverride(chirality ? Handed.Right : Handed.Left, joints); + // Input.HandClearOverride(handed); + + // model.Draw(glove.ToMatrix(Vec3.One / 4)); + // Matrix m4 = model.RootNode.Child.LocalTransform; + // Pose mPose = m4.Pose; + // mPose.orientation = Quat.FromAngles(Vec3.Right * 45); + // m4 = mPose.ToMatrix(); + // model.RootNode.Child.LocalTransform = m4; + // ? for stereo kit nick "can i directly update bone transforms on a skinned mesh" + + + } } diff --git a/app/MonoNet.cs b/app/MonoNet.cs index 18a6350..29d68b7 100644 --- a/app/MonoNet.cs +++ b/app/MonoNet.cs @@ -299,14 +299,38 @@ class Peer { // voiceInst = voice.Play(Vec3.Zero, 0.5f); } - BlockCon dBlock = new BlockCon(); - BlockCon sBlock = new BlockCon(); + BlockCon rBlock = new BlockCon(); + BlockCon lBlock = new BlockCon(); CubicCon cubicCon = new CubicCon(); - public void Step(Con rCon, Con lCon) { - dBlock.Step(rCon, lCon, cursor0, ref sBlock, ref blocks); - sBlock.Step(lCon, rCon, cursor3, ref dBlock, ref blocks); + public Vec3 vGlovePos; + + + public void Step(Monolith mono, Con rCon, Con lCon) { // CLIENT SIDE + rBlock.Step(rCon, lCon, mono.rGlove.virtualGlove.position, ref lBlock, ref blocks); + lBlock.Step(lCon, rCon, mono.lGlove.virtualGlove.position, ref rBlock, ref blocks); + + // too much in this networking class + // should contain only network related data + // and not be a weird pitstop for the game logic + // does it store a copy of the data? + // or just a reference to the data? + + // vGlovePos = mono.rGlove.virtualGlove.position; + + // for (int i = 0; i < blocks.Length; i++) { + // Pose blockPose = blocks[i].solid.GetPose(); + // Bounds bounds = new Bounds(Vec3.Zero, Vec3.One * blocks[i].size); + // if (blocks[i].active && ( + // bounds.Contains(blockPose.orientation.Inverse * (cursor - blockPose.position)) || + // bounds.Contains(blockPose.orientation.Inverse * (cursor3 - blockPose.position)) + // )) { + // blocks[i].color = new Color(0.8f, 1, 1); + // } else { + // blocks[i].color = new Color(1, 1, 1); + // } + // } cubicCon.Step(rCon, lCon, this, ref cubics); diff --git a/app/Monolith.cs b/app/Monolith.cs index 807ef08..5e919f7 100644 --- a/app/Monolith.cs +++ b/app/Monolith.cs @@ -11,7 +11,7 @@ if (!SK.Initialize(settings)) Environment.Exit(1); Input.HandSolid(Handed.Max, false); -Input.HandVisible(Handed.Max, false); +// Input.HandVisible(Handed.Max, false); // TextStyle style = Text.MakeStyle(Font.FromFile("DMMono-Regular.ttf"), 0.1f, Color.White); Monolith mono = new Monolith(); @@ -167,20 +167,6 @@ public class Monolith { // boolean over network to determine if a peers cubic flow should be drawn - for (int i = 0; i < net.me.blocks.Length; i++) { - Pose blockPose = net.me.blocks[i].solid.GetPose(); - Bounds bounds = new Bounds(Vec3.Zero, Vec3.One * net.me.blocks[i].size); - if (net.me.blocks[i].active && ( - bounds.Contains(blockPose.orientation.Inverse * (net.me.cursor0 - blockPose.position)) || - bounds.Contains(blockPose.orientation.Inverse * (net.me.cursor3 - blockPose.position)) - )) { - net.me.blocks[i].color = new Color(0.8f, 1, 1); - } else { - net.me.blocks[i].color = new Color(1, 1, 1); - } - } - - // FULLSTICK // Quat rot = Quat.FromAngles(subCon.stick.y * -90, 0, subCon.stick.x * 90); // Vec3 dir = Vec3.Up * (subCon.IsStickClicked ? -1 : 1); @@ -377,7 +363,7 @@ public class Monolith { } } - net.me.Step(rCon, lCon); + net.me.Step(this, rCon, lCon);