TrackingTore fonctionne à peu près
This commit is contained in:
parent
9ea45e793a
commit
1d8c9b7a1e
@ -230,7 +230,6 @@ public class Engine {
|
|||||||
obj1,
|
obj1,
|
||||||
obj2,
|
obj2,
|
||||||
this);
|
this);
|
||||||
this.cameraTrackingBetweenTwoObjectGl();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cameraTrackingBetweenTwoObjectGl(){
|
public void cameraTrackingBetweenTwoObjectGl(){
|
||||||
|
@ -30,22 +30,20 @@ public class TrackingTore implements TrackingDummy {
|
|||||||
//Track his current position and other useful data
|
//Track his current position and other useful data
|
||||||
float xPos = this.engine.getViewXPos();
|
float xPos = this.engine.getViewXPos();
|
||||||
float dimension = this.engine.getCamera().getDimension();
|
float dimension = this.engine.getCamera().getDimension();
|
||||||
float distance = Math.abs(left.getXPos() - right.getXPos()) + right.getWidth() * right.getScalingFactor();
|
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;
|
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){
|
if (left.getXPos() < xPos - rayonExt){
|
||||||
// Il faut décaler à gauche + dezoom
|
// le rayonExt augmente + 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);
|
|
||||||
} else if(left.getXPos() > xPos - rayonExt + offset){
|
} else if(left.getXPos() > xPos - rayonExt + offset){
|
||||||
// this.engine.getCamera().zoom(dimension/distance);
|
// le rayonExt diminue + zoom
|
||||||
// Il faut décaler à droite + zoom
|
|
||||||
} else if(right.getXPos() > xPos + rayonExt){
|
} else if(right.getXPos() > xPos + rayonExt){
|
||||||
// Il faut décaler à droite + dezoom
|
// le rayonExt augmente + dezoom
|
||||||
} else if(right.getXPos() < xPos + rayonExt - offset){
|
} else if(right.getXPos() < xPos + rayonExt - offset){
|
||||||
// Il faut décaler à gauche + zoom
|
// le rayonExt diminue + zoom
|
||||||
}
|
}
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user