1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
public void calculerMatrice(Point3D verticale) {
if (!imposerMatrice) { // Rien ne se fait si le système d'axe a été défini par l'utilisateur
if (verticale == null) // Calcul par défaut d'une verticale. Pas utilisé dans cet exemple
verticale = calculerVerticaleParDefaut(getLookat().moins(getEye()));
Matrix33 m = new Matrix33();
// Z SORT DE L4ECRAN
Point3D z= getLookat().moins(eye).norme1().mult(-1);
for (int j = 0; j < 3; j++) {
m.set(j, 2, z.get(j));
}
// X HORIZONTALE VERS LA GAUCHE
Point3D v2 = z.prodVect(verticale/* Y */).norme1().mult(-1);
for (int j = 0; j < 3; j++) {
m.set(j, 0, v2.get(j));
}
// Y VERTICALE VERS LE BAS
Point3D v3 = verticale;
for (int j = 0; j < 3; j++) {
m.set(j, 1, v3.get(j));
}
this.matrice = m;
}
}
Camera camera = new Camera(Trajectoires.sphere(3.0 * frame() / getMaxFrames(),
0, RADIUS * 3, Matrix33.I), Point3D.O0);
camera.calculerMatrice(camera.getLookat().moins(camera.getEye().mult(1)).prodVect(
Trajectoires.sphere(3.0 * frame() / getMaxFrames()*1.001,
0, RADIUS * 3, Matrix33.I).moins(
Trajectoires.sphere(3.0 * frame() / getMaxFrames(),
0, RADIUS * 3, Matrix33.I)).mult(1)));
scene().cameraActive(camera); |
Partager