TrackingSF3ThirdStrick added, attention la crise d'epilepsie

This commit is contained in:
Antoine
2021-06-08 02:58:53 +02:00
parent 5d59f41edc
commit 3e893cd07e
4 changed files with 61 additions and 4 deletions

View File

@@ -0,0 +1,43 @@
package engine.camera;
import engine.Engine;
import engine.math.Vector3f;
import engine.object.ObjectGl;
public class TrackingSF3ThirdStrick implements TrackingDummy {
private final ObjectGl obj1;
private final ObjectGl obj2;
private final Engine engine;
/**
* Un tracking ou les personnages "pousse" la camera
*/
public TrackingSF3ThirdStrick(ObjectGl obj1, ObjectGl obj2, Engine engine){
this.obj1 = obj1;
this.obj2 = obj2;
this.engine = engine;
}
@Override
public Vector3f getViewVector() {
Vector3f vec = new Vector3f();
float viewXPos = -this.engine.getViewXPos();
float dimension = this.engine.getCamera().getDimension();
ObjectGl left = obj1.getXPos() >= obj2.getXPos() ? obj2 : obj1;
ObjectGl right = obj1.getXPos() < obj2.getXPos() ? obj2 : obj1;
System.out.println(viewXPos);
if ((right.getXPos() + right.getWidth() * right.getScalingFactor()) > viewXPos + dimension){
vec.x = - Math.abs((right.getXPos() + right.getWidth() * right.getScalingFactor()) - (viewXPos + dimension));
} else if (left.getXPos() < viewXPos - dimension){
vec.x = Math.abs(left.getXPos() - (viewXPos - dimension));
}
return vec;
}
}