blocks and stuff

This commit is contained in:
spatialfree 2021-12-03 16:07:02 -05:00
parent 1701d05372
commit 8b797c3560
2 changed files with 29 additions and 17 deletions

View file

@ -286,6 +286,8 @@ public class MonoNet {
public Peer(int id, SolidType type, Color color) { public Peer(int id, SolidType type, Color color) {
this.id = id; this.id = id;
blocks = new Block[] { blocks = new Block[] {
new Block(type, color),
new Block(type, color),
new Block(type, color), new Block(type, color),
new Block(type, color), new Block(type, color),
new Block(type, color) new Block(type, color)
@ -382,7 +384,7 @@ public class MonoNet {
blockCon.momentum = Vec3.Lerp(blockCon.momentum, blockCon.delta, Time.Elapsedf / 0.1f); blockCon.momentum = Vec3.Lerp(blockCon.momentum, blockCon.delta, Time.Elapsedf / 0.1f);
} }
} else { } else {
if (blockCon.index > 0) { if (blockCon.index >= 0) {
blocks[blockCon.index].solid.SetAngularVelocity(blockCon.angularMomentum / Time.Elapsedf); blocks[blockCon.index].solid.SetAngularVelocity(blockCon.angularMomentum / Time.Elapsedf);
blocks[blockCon.index].solid.SetVelocity(blockCon.momentum / Time.Elapsedf); blocks[blockCon.index].solid.SetVelocity(blockCon.momentum / Time.Elapsedf);
} }

View file

@ -106,6 +106,16 @@ public class Mono {
subCursor.Calibrate(); subCursor.Calibrate();
} cursor.p1 = subCursor.p0; // override *later change all one handed cursors to be dual wielded by default* } cursor.p1 = subCursor.p0; // override *later change all one handed cursors to be dual wielded by default*
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);
if (net.me.blocks[i].active && (bounds.Contains(blockPose.orientation.Inverse * (cursor.p0 - blockPose.position)) || bounds.Contains(blockPose.orientation.Inverse * (cursor.p1 - 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);
@ -185,22 +195,22 @@ public class Mono {
// COLOR CUBE // COLOR CUBE
// reveal when palm up // reveal when palm up
float reveal = subCon.pose.Right.y * 2; // float reveal = subCon.pose.Right.y * 2;
colorCube.size = colorCube.ogSize * Math.Clamp(reveal, 0, 1); // colorCube.size = colorCube.ogSize * Math.Clamp(reveal, 0, 1);
colorCube.center = subCon.pose.position + subCon.pose.Right * 0.0666f; // colorCube.center = subCon.pose.position + subCon.pose.Right * 0.0666f;
// move with grip // // move with grip
if (reveal > colorCube.thicc) { // if (reveal > colorCube.thicc) {
if (reveal > 1f && subCon.grip > 0.5f) { // if (reveal > 1f && subCon.grip > 0.5f) {
colorCube.p0 -= (subCon.pose.position - oldSubPos) / colorCube.ogSize * 2; // colorCube.p0 -= (subCon.pose.position - oldSubPos) / colorCube.ogSize * 2;
} else { // } else {
// clamp 0 - 1 // // clamp 0 - 1
colorCube.p0.x = Math.Clamp(colorCube.p0.x, -1, 1); // colorCube.p0.x = Math.Clamp(colorCube.p0.x, -1, 1);
colorCube.p0.y = Math.Clamp(colorCube.p0.y, -1, 1); // colorCube.p0.y = Math.Clamp(colorCube.p0.y, -1, 1);
colorCube.p0.z = Math.Clamp(colorCube.p0.z, -1, 1); // colorCube.p0.z = Math.Clamp(colorCube.p0.z, -1, 1);
} // }
colorCube.Step(); // colorCube.Step();
} // }
oldSubPos = subCon.pose.position; // oldSubPos = subCon.pose.position;
// for (int i = 0; i < net.me.blocks.Length; i++) { // for (int i = 0; i < net.me.blocks.Length; i++) {
// cube.Draw(mat, net.me.blocks[i].solid.GetPose().ToMatrix(), net.me.blocks[i].color); // cube.Draw(mat, net.me.blocks[i].solid.GetPose().ToMatrix(), net.me.blocks[i].color);