Camera zoom + package gui
This commit is contained in:
47
src/engine/gui/UIElement.java
Normal file
47
src/engine/gui/UIElement.java
Normal 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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
13
src/engine/gui/UIElementText.java
Normal file
13
src/engine/gui/UIElementText.java
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user