Camera zoom + package gui

This commit is contained in:
Antoine
2021-06-04 17:29:17 +02:00
parent ab6939466d
commit db073106cd
5 changed files with 74 additions and 20 deletions

View File

@ -0,0 +1,47 @@
package engine.gui;
import engine.Engine;
import engine.math.Vector3f;
import engine.object.ObjectGl;
import java.util.ArrayList;
import java.util.List;
public class UIElement {
private List<ObjectGl> objs;
private Engine engine;
private Vector3f transformation;
public UIElement(List<ObjectGl> objs, Engine engine){
this.objs = new ArrayList<>();
this.objs.addAll(objs);
this.engine = engine;
this.transformation = new Vector3f();
}
public void addObj(ObjectGl obj){
obj.translate(this.transformation);
this.objs.add(obj);
}
public void addObj(List<ObjectGl> objs){
for (ObjectGl obj : objs){
obj.translate(this.transformation);
this.objs.add(obj);
}
}
public void removeObj(ObjectGl obj){
this.objs.remove(obj);
}
public void update(){
Vector3f translationViewPoint = new Vector3f(-engine.transformationView.x, engine.transformationView.y);
this.transformation = this.transformation.addXYZ(translationViewPoint);
for (ObjectGl obj : this.objs){
obj.translate(translationViewPoint); // Tous les elmts font le même déplacement que la caméra
}
}
}

View File

@ -0,0 +1,13 @@
package engine.gui;
import engine.Engine;
import engine.gui.UIElement;
import engine.object.ObjectGl;
import java.util.List;
public class UIElementText extends UIElement {
public UIElementText(List<ObjectGl> objs, Engine engine) {
super(objs, engine);
}
}