blocked up

This commit is contained in:
spatialfree 2022-01-17 16:08:30 -05:00
parent 6788b46a10
commit 62e762a166
4 changed files with 55 additions and 24 deletions

BIN
add/skinned_test.glb Normal file

Binary file not shown.

View file

@ -130,6 +130,7 @@ public class Glove {
// that way we can render the same way for all peers // that way we can render the same way for all peers
static Mesh mesh = Default.MeshCube; static Mesh mesh = Default.MeshCube;
static Material mat = Default.Material; 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) { 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(pullPoint, glove.position, new Color(1, 0, 1), 0.005f);
Lines.Add(glove.position, virtualGlove.position, new Color(0, 1, 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); int segments = twistAbs == 0 ? -1 : 6 + (int)(twistAbs * 10);
LinePoint[] linePoints = new LinePoint[segments + 2]; LinePoint[] linePoints = new LinePoint[segments + 2];
linePoints[0] = new LinePoint(twistStuff, new Color(1, 1, 0), 0.005f); linePoints[0] = new LinePoint(twistStuff, new Color(1, 1, 0), 0.005f);
for (int i = 0; i <= segments; i++) { for (int i = 0; i <= segments; i++) {
float tw = twistAbs * Math.Min(i / (float)(segments - 1), 1); float tw = twistAbs * Math.Min(i / (float)(segments - 1), 1);
tw *= chirality ? 1 : -1; tw *= chirality ? 1 : -1;
tw *= twist > 0 ? 1 : -1; tw *= twist > 0 ? 1 : -1;
// spiral 3
float tighten = Math.Max(1 - (twistAbs / 9), 0); float tighten = Math.Max(1 - (twistAbs / 9), 0);
float radius = i == segments ? 0.06f : 0.05f * (1 - (1 - i / (float)segments) * (1 - tighten)); 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; 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); Lines.Add(linePoints);
mesh.Draw(mat, glove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f) / 3)); 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))); 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"
} }
} }

View file

@ -299,14 +299,38 @@ class Peer {
// voiceInst = voice.Play(Vec3.Zero, 0.5f); // voiceInst = voice.Play(Vec3.Zero, 0.5f);
} }
BlockCon dBlock = new BlockCon(); BlockCon rBlock = new BlockCon();
BlockCon sBlock = new BlockCon(); BlockCon lBlock = new BlockCon();
CubicCon cubicCon = new CubicCon(); CubicCon cubicCon = new CubicCon();
public void Step(Con rCon, Con lCon) { public Vec3 vGlovePos;
dBlock.Step(rCon, lCon, cursor0, ref sBlock, ref blocks);
sBlock.Step(lCon, rCon, cursor3, ref dBlock, ref blocks);
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); cubicCon.Step(rCon, lCon, this, ref cubics);

View file

@ -11,7 +11,7 @@ if (!SK.Initialize(settings))
Environment.Exit(1); Environment.Exit(1);
Input.HandSolid(Handed.Max, false); 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); // TextStyle style = Text.MakeStyle(Font.FromFile("DMMono-Regular.ttf"), 0.1f, Color.White);
Monolith mono = new Monolith(); Monolith mono = new Monolith();
@ -167,20 +167,6 @@ public class Monolith {
// boolean over network to determine if a peers cubic flow should be drawn // 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 // FULLSTICK
// Quat rot = Quat.FromAngles(subCon.stick.y * -90, 0, subCon.stick.x * 90); // Quat rot = Quat.FromAngles(subCon.stick.y * -90, 0, subCon.stick.x * 90);
// Vec3 dir = Vec3.Up * (subCon.IsStickClicked ? -1 : 1); // 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);