From 8d8a90f29af2970f2b0229f61d5992169e10af12 Mon Sep 17 00:00:00 2001 From: EvilMuffinHa Date: Thu, 28 May 2020 18:30:36 -0400 Subject: [PATCH] lets goooo fp camera fixed --- src/Test.java | 10 +++++----- src/org/hl/engine/math/lalg/Matrix4f.java | 2 +- src/org/hl/engine/objects/Camera.java | 1 + src/org/hl/engine/objects/FirstPersonCamera.java | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Test.java b/src/Test.java index 4082bca..46de1d9 100644 --- a/src/Test.java +++ b/src/Test.java @@ -19,10 +19,10 @@ public class Test extends Game { public Shader shader; public Mesh plane = new Mesh(new Vertex[] { - new Vertex(new Vector3f(-20, 20, 1), new Vector2f(0, 0)), - new Vertex(new Vector3f(-20, -20, 1), new Vector2f(0, 1)), - new Vertex(new Vector3f(20, -20, 1), new Vector2f(1, 1)), - new Vertex(new Vector3f(20, 20, 1), new Vector2f(1, 0)), + new Vertex(new Vector3f(-20, -0.5000001f, 20), new Vector2f(0, 0)), + new Vertex(new Vector3f(-20, -0.5000001f, -20), new Vector2f(0, 1)), + new Vertex(new Vector3f(20, -0.5000001f, -20), new Vector2f(1, 1)), + new Vertex(new Vector3f(20, -0.5000001f, 20), new Vector2f(1, 0)), }, new int[] { 0, 1, 3, 3, 1, 2 @@ -153,7 +153,7 @@ public class Test extends Game { renderer = new Renderer(display, shader); // Changing the background color - display.setBackgroundColor(0F, 0F, 0F); + display.setBackgroundColor(0.53f, .81f, 0.92f); // Creating / displaying the mesh mesh.create(); diff --git a/src/org/hl/engine/math/lalg/Matrix4f.java b/src/org/hl/engine/math/lalg/Matrix4f.java index c95f59f..1419e61 100644 --- a/src/org/hl/engine/math/lalg/Matrix4f.java +++ b/src/org/hl/engine/math/lalg/Matrix4f.java @@ -132,7 +132,7 @@ public class Matrix4f { Matrix4f rotationYMatrix = Matrix4f.rotate(-rotation.getY(), new Vector3f(0, 1, 0)); Matrix4f rotationZMatrix = Matrix4f.rotate(-rotation.getZ(), new Vector3f(0, 0, 1)); - Matrix4f rotMat = Matrix4f.multiply(rotationZMatrix, Matrix4f.multiply(rotationYMatrix, rotationXMatrix)); + Matrix4f rotMat = Matrix4f.multiply(rotationZMatrix, Matrix4f.multiply(rotationXMatrix, rotationYMatrix)); return Matrix4f.multiply(rotMat, translationMatrix); diff --git a/src/org/hl/engine/objects/Camera.java b/src/org/hl/engine/objects/Camera.java index dbd3a48..bc73103 100644 --- a/src/org/hl/engine/objects/Camera.java +++ b/src/org/hl/engine/objects/Camera.java @@ -37,6 +37,7 @@ public class Camera { position.setX(position.getX() + (float) Math.cos(Math.toRadians(rotation.getY())) * offsetX) ; position.setZ(position.getZ() + (float) Math.sin(Math.toRadians(rotation.getY())) * offsetX); } + position.setY(position.getY() + offsetY); } } diff --git a/src/org/hl/engine/objects/FirstPersonCamera.java b/src/org/hl/engine/objects/FirstPersonCamera.java index 81cf1c0..6714916 100644 --- a/src/org/hl/engine/objects/FirstPersonCamera.java +++ b/src/org/hl/engine/objects/FirstPersonCamera.java @@ -48,6 +48,8 @@ public class FirstPersonCamera extends Camera { if (i.isKeyDown(GLFW.GLFW_KEY_S)) movePosition(0, 0, moveSpeed); if (i.isKeyDown(GLFW.GLFW_KEY_SPACE)) movePosition(0, moveSpeed, 0); if (i.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) movePosition(0, -moveSpeed, 0); + if (i.keyPress(GLFW.GLFW_KEY_R)) moveSpeed = 4*moveSpeed; + if (i.keyReleased(GLFW.GLFW_KEY_R)) moveSpeed = moveSpeed / 4; setRotation(cameraRot); setPosition(cameraPos);