lets goooo fp camera fixed

This commit is contained in:
EvilMuffinHa 2020-05-28 18:30:36 -04:00
parent be4a13c1d0
commit 8d8a90f29a
4 changed files with 9 additions and 6 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);