TrackingTore fonctionne à peu près

This commit is contained in:
Antoine 2021-06-07 16:59:19 +02:00
parent 9ea45e793a
commit 1d8c9b7a1e
2 changed files with 9 additions and 12 deletions

View File

@ -230,7 +230,6 @@ public class Engine {
obj1,
obj2,
this);
this.cameraTrackingBetweenTwoObjectGl();
}
public void cameraTrackingBetweenTwoObjectGl(){

View File

@ -30,22 +30,20 @@ public class TrackingTore implements TrackingDummy {
//Track his current position and other useful data
float xPos = this.engine.getViewXPos();
float dimension = this.engine.getCamera().getDimension();
float distance = Math.abs(left.getXPos() - right.getXPos()) + right.getWidth() * right.getScalingFactor();
float middle_point = (left.getXPos() + right.getXPos() + right.getWidth() * right.getScalingFactor()) / 2;
float distance = Math.abs(left.getXPos() - (right.getXPos()) + right.getWidth() * right.getScalingFactor()) + 1500.0f; // Il faut un offset sinon si la distance est de 0 on a la camera qui zoom vers l'infini
float middle_point = (left.getXPos() + (right.getXPos() + right.getWidth() * right.getScalingFactor())) / 2;
vec.x = -middle_point - xPos;
this.engine.getCamera().zoom((distance / 2)/dimension);
if (left.getXPos() < xPos - rayonExt){
// Il faut décaler à gauche + dezoom
vec.x = - middle_point - xPos;
this.rayonExt = Math.abs(left.getXPos() - xPos);
//mtn on dezoom il faut calculer le rapport necessaire pour avoir les deux objets dans le champs
this.engine.getCamera().zoom(distance/dimension);
// le rayonExt augmente + dezoom
} else if(left.getXPos() > xPos - rayonExt + offset){
// this.engine.getCamera().zoom(dimension/distance);
// Il faut décaler à droite + zoom
// le rayonExt diminue + zoom
} else if(right.getXPos() > xPos + rayonExt){
// Il faut décaler à droite + dezoom
// le rayonExt augmente + dezoom
} else if(right.getXPos() < xPos + rayonExt - offset){
// Il faut décaler à gauche + zoom
// le rayonExt diminue + zoom
}
return vec;
}