Remove unnecessary Z-index
This commit is contained in:
@@ -17,6 +17,6 @@ public class Camera extends Object {
|
|||||||
public Matrix4f getViewMatrix() {
|
public Matrix4f getViewMatrix() {
|
||||||
return viewMatrix
|
return viewMatrix
|
||||||
.identity()
|
.identity()
|
||||||
.translate(-position.x, -position.y, -position.z);
|
.translate(-position.x, -position.y, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.bartlomiejpluta.samplegame.core.world.object;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector2f;
|
||||||
|
|
||||||
import static java.lang.Math.toRadians;
|
import static java.lang.Math.toRadians;
|
||||||
|
|
||||||
@@ -11,78 +11,50 @@ public abstract class Object {
|
|||||||
private final Matrix4f modelMatrix = new Matrix4f();
|
private final Matrix4f modelMatrix = new Matrix4f();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
protected final Vector3f position = new Vector3f(0, 0, 0);
|
protected final Vector2f position = new Vector2f(0, 0);
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
protected final Vector3f rotation = new Vector3f(0, 0, 0);
|
@Setter
|
||||||
|
protected float rotation;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
protected float scale = 1.0f;
|
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.x = x;
|
||||||
position.y = y;
|
position.y = y;
|
||||||
position.z = z;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object setPosition(Vector3f position) {
|
public Object setPosition(Vector2f position) {
|
||||||
this.position.x = position.x;
|
this.position.x = position.x;
|
||||||
this.position.y = position.y;
|
this.position.y = position.y;
|
||||||
this.position.z = position.z;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object movePosition(float x, float y, float z) {
|
public Object movePosition(float x, float y) {
|
||||||
position.x += x;
|
position.x += x;
|
||||||
position.y += y;
|
position.y += y;
|
||||||
position.z += z;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object movePosition(Vector3f position) {
|
public Object movePosition(Vector2f position) {
|
||||||
this.position.x += position.x;
|
this.position.x += position.x;
|
||||||
this.position.y += position.y;
|
this.position.y += position.y;
|
||||||
this.position.z += position.z;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object setRotation(float x, float y, float z) {
|
public Object moveRotation(float rotation) {
|
||||||
rotation.x = x;
|
this.rotation += rotation;
|
||||||
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;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matrix4f getModelMatrix() {
|
public Matrix4f getModelMatrix() {
|
||||||
return modelMatrix
|
return modelMatrix
|
||||||
.identity()
|
.identity()
|
||||||
.translate(position)
|
.translate(position.x, position.y, 0)
|
||||||
.rotateX((float) toRadians(-rotation.x))
|
.rotateZ((float) toRadians(-rotation))
|
||||||
.rotateY((float) toRadians(-rotation.y))
|
|
||||||
.rotateZ((float) toRadians(-rotation.z))
|
|
||||||
.scale(scale);
|
.scale(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class DefaultGameLogic implements GameLogic {
|
|||||||
renderer.init();
|
renderer.init();
|
||||||
|
|
||||||
sprite = new Sprite();
|
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);
|
sprite.setScale(100);
|
||||||
scene.add(sprite);
|
scene.add(sprite);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user