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

@ -232,8 +232,12 @@ public class Engine {
this);
}
public void cameraTrackingBetweenTwoObjectGl(){
if (this.tracking == null) System.out.println("Utilisez setCameraTrackingBetweenTwoObjectGl avant cameraTrackingBetweenTwoObjectGl");
public void setCameraTrackingSF3ThirdStrike(ObjectGl obj1, ObjectGl obj2){
this.tracking = new TrackingSF3ThirdStrick(obj1, obj2, this);
}
public void cameraTracking(){
if (this.tracking == null) System.out.println("Define a tracking first");
else {
Vector3f trackingVector = this.tracking.getViewVector();
this.translateView(trackingVector);

View File

@ -59,7 +59,7 @@ public class TestEngine {
zangief2.translate(new Vector3f(1000.0f, 200.0f, 0.0f));
zangief2.flipTextureWrapH();
engine.setCameraTrackingBetweenTwoObjectGl(zangief, zangief2, 1000.0f);
engine.setCameraTrackingSF3ThirdStrike(zangief, zangief2);
//Create background
ObjectGl background = new ObjectGl(0f,1f,1f,10f, pathToBG, null);
@ -128,7 +128,7 @@ public class TestEngine {
}
// engine.cameraTrackingObjectGl(zangief, -250.0f);
engine.cameraTrackingBetweenTwoObjectGl();
engine.cameraTracking();
uiTextCoordP1.setText("X: " + zangief.getXPos() + " Y: " + zangief.getYPos());

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;
}
}

View File

@ -4,6 +4,9 @@ import engine.Engine;
import engine.math.Vector3f;
import engine.object.ObjectGl;
/**
* Pas fini et c'est de la merde
*/
public class TrackingTore implements TrackingDummy {
private float rayonExt;
@ -12,6 +15,13 @@ public class TrackingTore implements TrackingDummy {
private final ObjectGl obj2;
private final Engine engine;
/**
* Centre la camera entre les deux objets assure un niveau de zoom suffisant pour voir les deux objets //TODO ajouter une zone morte + interpolation
* @param offset
* @param obj1
* @param obj2
* @param engine
*/
public TrackingTore(float offset, ObjectGl obj1, ObjectGl obj2, Engine engine){
this.rayonExt = offset;
this.offset = offset;