38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package engine.camera;
|
|
|
|
import engine.Engine;
|
|
import engine.math.Matrix4f;
|
|
import engine.math.Vector3f;
|
|
import engine.object.ObjectGl;
|
|
|
|
public class Camera {
|
|
|
|
private float dimension;
|
|
private final Vector3f aspectRatio;
|
|
private final Engine engine;
|
|
|
|
|
|
public Camera(float dimension, Vector3f aspectRatio, Engine engine){
|
|
this.dimension = dimension;
|
|
this.aspectRatio = aspectRatio;
|
|
this.engine = engine;
|
|
float ar = aspectRatio.y / aspectRatio.x;
|
|
ObjectGl.projection = Matrix4f.orthographic(-dimension, dimension, -dimension * ar, dimension * ar, 0.1f, 1000.0f);
|
|
}
|
|
|
|
public void zoom(float zoomFactor){
|
|
engine.setUIElementZoomFactor(zoomFactor);
|
|
this.dimension *= zoomFactor;
|
|
float ar = aspectRatio.y / aspectRatio.x;
|
|
ObjectGl.projection = Matrix4f.orthographic(-dimension, dimension, -dimension * ar, dimension * ar, 0.1f, 100.0f);
|
|
}
|
|
|
|
public float getDimension(){
|
|
return this.dimension;
|
|
}
|
|
|
|
public Vector3f getAspectRatio(){
|
|
return this.aspectRatio;
|
|
}
|
|
}
|