world bound ^ playercon
This commit is contained in:
parent
049727873a
commit
69cd36781b
1 changed files with 27 additions and 5 deletions
|
@ -42,22 +42,33 @@ public class Rig {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gotBounds = false;
|
bool gotBounds = false;
|
||||||
|
Matrix bounds = Matrix.T(0, -1.3f, 0);
|
||||||
public void Step() {
|
public void Step() {
|
||||||
Matrix bounds = Matrix.T(0, 1.3f, 0);
|
|
||||||
if (!gotBounds && World.HasBounds) {
|
if (!gotBounds && World.HasBounds) {
|
||||||
gotBounds = true;
|
gotBounds = true;
|
||||||
bounds = World.BoundsPose.ToMatrix();
|
bounds = World.BoundsPose.ToMatrix();
|
||||||
// Renderer.CameraRoot = World.BoundsPose.ToMatrix();
|
|
||||||
}
|
}
|
||||||
|
Vec2 stickL = Input.Controller(Handed.Left).stick;
|
||||||
|
Vec2 stickR = Input.Controller(Handed.Right).stick;
|
||||||
|
Quat delta = Quat.FromAngles(
|
||||||
|
Vec3.Up * stickR.x * 120f * Time.Elapsedf
|
||||||
|
) * ori;
|
||||||
|
Vec3 headPos = Input.Head.position + Input.Head.Forward * -0.15f; // Input.Head -> Head() ?
|
||||||
|
pos -= headPos;
|
||||||
|
pos = delta * pos;
|
||||||
|
pos += headPos;
|
||||||
|
ori = delta * ori;
|
||||||
|
|
||||||
Renderer.CameraRoot = Matrix.TR(pos, ori) * bounds;
|
Vec3 move = -stickL.X0Y * Time.Elapsedf * 0.5f;
|
||||||
|
pos += (Input.Head.orientation * move).X0Z;
|
||||||
|
|
||||||
|
Renderer.CameraRoot = Matrix.TR(pos, ori) * bounds.Inverse;
|
||||||
|
|
||||||
// Controllers
|
// Controllers
|
||||||
rCon.Step(true);
|
rCon.Step(true);
|
||||||
lCon.Step(false);
|
lCon.Step(false);
|
||||||
|
|
||||||
// Shoulders
|
// Shoulders
|
||||||
Vec3 headPos = Input.Head.position + Input.Head.Forward * -0.15f; // Input.Head -> Head() ?
|
|
||||||
Vec3 shoulderDir = (
|
Vec3 shoulderDir = (
|
||||||
(lCon.pos.X0Z - headPos.X0Z).Normalized +
|
(lCon.pos.X0Z - headPos.X0Z).Normalized +
|
||||||
(rCon.pos.X0Z - headPos.X0Z).Normalized
|
(rCon.pos.X0Z - headPos.X0Z).Normalized
|
||||||
|
@ -102,9 +113,20 @@ public class Con {
|
||||||
public struct Btn {
|
public struct Btn {
|
||||||
public bool frameDown, held, frameUp;
|
public bool frameDown, held, frameUp;
|
||||||
|
|
||||||
public void Step(bool down) {
|
public void Step(bool down, bool sticky = false) {
|
||||||
|
if (held) {
|
||||||
|
down = sticky;
|
||||||
|
}
|
||||||
|
|
||||||
frameDown = down && !held;
|
frameDown = down && !held;
|
||||||
frameUp = !down && held;
|
frameUp = !down && held;
|
||||||
held = down;
|
held = down;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public void Pinch(bool neg, bool pos) {
|
||||||
|
// bool pinch = held;
|
||||||
|
// if (pinch) {
|
||||||
|
// pinch = dist < 2 * U.cm;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue