BImage acc; int compteur,compteur2,incr; float xc, yc, zc; boolean grandCycle; float tempo; DoubleTriedre triedre; void setup() { size(600, 500); xc= width/2.0f; yc=height/2.0f; zc=347; noStroke();//background(125); background(75,27,79); triedre= new DoubleTriedre(500.0f); ellipseMode(CENTER_DIAMETER); acc=loadImage("tete.jpg"); compteur=4;compteur2=8;incr=-1; } void loop() { clear(); translate(xc, yc, zc); rotateY(0.01f * (mouseX - width/2)); rotateZ(0.01f * (mouseY - height/2)); scale(55.0f/compteur); tempo += 0.1f; triedre.calculer(tempo,PI/compteur2); grandCycle=true; triedre.dessinerCycle(grandCycle); } void mousePressed(){incremente();println(compteur); } void incremente(){ if(compteur==15||compteur==2) incr*=-1; compteur=compteur+incr; compteur2=2*compteur; } class DoubleTriedre{ Vecteur ab,cd,ac; Vecteur[] v,w; float cote; public DoubleTriedre(float lacote){ v=new Vecteur[8]; w=new Vecteur[8]; cote=lacote; } public void calculer(float t,float alph){ ab=new Vecteur(cos(t),0.0f,sin(t)); float norm=1.0f/sqrt(1.0f+sq(sin(t)*tan(alph))); cd=new Vecteur(norm*sin(t),norm*sin(t)*tan(alph),-norm*cos(t)); ac=ab.cross(cd); Vecteur cc=new Vecteur(ac.y/tan(alph),ac.y,ac.z); Vecteur aa=new Vecteur(cc.x-ac.x,0,0); v[0]=aa;//A v[1]=aa.ajouter(ab,1);//B v[2]=ac.ajouter(v[1],1);//E v[3]=cc;//C v[4]=cc.ajouter(cd,1);//D v[5]=aa.ajouter(cd,1);//F v[6]=v[2].ajouter(cd,1);//G v[7]=v[1].ajouter(cd,1);//H Vecteur norplan=new Vecteur(-sin(alph),cos(alph),0); for(int i=0;i<8;i++){ w[i]=v[i].symetrique(norplan);} } public void dessiner(){ fill(55,255,0); noStroke(); fill(255,255,255); beginShape(QUADS); texture(acc); vertex(v[0].x,v[0].y,v[0].z,0,0); vertex(v[1].x,v[1].y,v[1].z, acc.width,0); vertex(v[2].x,v[2].y,v[2].z, acc.width,acc.height); vertex(v[3].x,v[3].y,v[3].z,0, acc.height); endShape(); fill(255,200,100); beginShape(QUADS); texture(acc); vertex(v[2].x,v[2].y,v[2].z, acc.width,acc.height); vertex(v[3].x,v[3].y,v[3].z,0, acc.height); vertex(v[4].x,v[4].y,v[4].z,0,0); vertex(v[6].x,v[6].y,v[6].z,acc.width, 0); endShape(); fill(255,150,150); beginShape(QUADS); texture(acc); vertex(v[4].x,v[4].y,v[4].z,0,0); vertex(v[6].x,v[6].y,v[6].z,acc.width, 0); vertex(v[7].x,v[7].y,v[7].z, acc.width, acc.height); vertex(v[5].x,v[5].y,v[5].z,0, acc.height); endShape(); fill(255,50,50); beginShape(QUADS); texture(acc); vertex(v[7].x,v[7].y,v[7].z, acc.width, acc.height); vertex(v[5].x,v[5].y,v[5].z,0, acc.height); vertex(v[0].x,v[0].y,v[0].z,0,0); vertex(v[1].x,v[1].y,v[1].z,acc.width, 0); endShape(); ///////////////////////////////// fill(255); beginShape(QUADS); texture(acc); vertex(w[0].x,w[0].y,w[0].z,0,0); vertex(w[1].x,w[1].y,w[1].z, acc.width,0); vertex(w[2].x,w[2].y,w[2].z, acc.width,acc.height); vertex(w[3].x,w[3].y,w[3].z,0, acc.height); endShape(); fill(255,200,200); beginShape(QUADS); texture(acc); vertex(w[2].x,w[2].y,w[2].z, acc.width,acc.height); vertex(w[3].x,w[3].y,w[3].z,0, acc.height); vertex(w[4].x,w[4].y,w[4].z,0,0); vertex(w[6].x,w[6].y,w[6].z,acc.width, 0); endShape(); fill(255,155,195); beginShape(QUADS); texture(acc); vertex(w[4].x,w[4].y,w[4].z,0,0); vertex(w[6].x,w[6].y,w[6].z,acc.width, 0); vertex(w[7].x,w[7].y,w[7].z, acc.width, acc.height); vertex(w[5].x,w[5].y,w[5].z,0, acc.height); endShape(); fill(255,205,155); beginShape(QUADS); texture(acc); vertex(w[7].x,w[7].y,w[7].z, acc.width, acc.height); vertex(w[5].x,w[5].y,w[5].z,0, acc.height); vertex(w[0].x,w[0].y,w[0].z,0,0); vertex(w[1].x,w[1].y,w[1].z,acc.width, 0); endShape(); } public void dessinerCycle(boolean bool){ for(int i=0;i