Remove unnecessary Z-index

This commit is contained in:
2021-01-30 14:26:58 +01:00
parent a0d46a3b82
commit bd5ad778c9
3 changed files with 14 additions and 42 deletions

View File

@@ -17,6 +17,6 @@ public class Camera extends Object {
public Matrix4f getViewMatrix() {
return viewMatrix
.identity()
.translate(-position.x, -position.y, -position.z);
.translate(-position.x, -position.y, 0);
}
}

View File

@@ -3,7 +3,7 @@ package com.bartlomiejpluta.samplegame.core.world.object;
import lombok.Getter;
import lombok.Setter;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.joml.Vector2f;
import static java.lang.Math.toRadians;
@@ -11,78 +11,50 @@ public abstract class Object {
private final Matrix4f modelMatrix = new Matrix4f();
@Getter
protected final Vector3f position = new Vector3f(0, 0, 0);
protected final Vector2f position = new Vector2f(0, 0);
@Getter
protected final Vector3f rotation = new Vector3f(0, 0, 0);
@Setter
protected float rotation;
@Getter
@Setter
protected float scale = 1.0f;
public Object setPosition(float x, float y, float z) {
public Object setPosition(float x, float y) {
position.x = x;
position.y = y;
position.z = z;
return this;
}
public Object setPosition(Vector3f position) {
public Object setPosition(Vector2f position) {
this.position.x = position.x;
this.position.y = position.y;
this.position.z = position.z;
return this;
}
public Object movePosition(float x, float y, float z) {
public Object movePosition(float x, float y) {
position.x += x;
position.y += y;
position.z += z;
return this;
}
public Object movePosition(Vector3f position) {
public Object movePosition(Vector2f position) {
this.position.x += position.x;
this.position.y += position.y;
this.position.z += position.z;
return this;
}
public Object setRotation(float x, float y, float z) {
rotation.x = x;
rotation.y = y;
rotation.z = z;
return this;
}
public Object setRotation(Vector3f rotation) {
this.rotation.x = rotation.x;
this.rotation.y = rotation.y;
this.rotation.z = rotation.z;
return this;
}
public Object moveRotation(float x, float y, float z) {
rotation.x += x;
rotation.y += y;
rotation.z += z;
return this;
}
public Object moveRotation(Vector3f rotation) {
this.rotation.x += rotation.x;
this.rotation.y += rotation.y;
this.rotation.z += rotation.z;
public Object moveRotation(float rotation) {
this.rotation += rotation;
return this;
}
public Matrix4f getModelMatrix() {
return modelMatrix
.identity()
.translate(position)
.rotateX((float) toRadians(-rotation.x))
.rotateY((float) toRadians(-rotation.y))
.rotateZ((float) toRadians(-rotation.z))
.translate(position.x, position.y, 0)
.rotateZ((float) toRadians(-rotation))
.scale(scale);
}
}

View File

@@ -28,7 +28,7 @@ public class DefaultGameLogic implements GameLogic {
renderer.init();
sprite = new Sprite();
sprite.setPosition(window.getWidth() / 2.0f, window.getHeight() / 2.0f, 0);
sprite.setPosition(window.getWidth() / 2.0f, window.getHeight() / 2.0f);
sprite.setScale(100);
scene.add(sprite);
}