/*Alcys_PoussePhoto - Il s'agit de donner du volume à une image. Un outil sphérique permet de repousser les pixels d'une photo. - Dans la troisième dimension. Cette sphère peut être déplacée dans le plan XOY de la photo par clic droit+drag. - Avant de draguer il est conseillé de placer le curseur sur la pointe du sélecteur,représenté par la flèche blanche. - Les touches '+' et '-' modifient le rayon du l'outil sphère . - Les touches "q" et "w" ou UP et DOWN permettent de déplacer l'outil suivant l'axe OZ . - Les rotations de la caméra sont contrôlées par clic gauche et drag. - Ces mouvements permettent de surveiller les déformations dans la troisième dimension. - La touche "o" modifie la transparence de la photo. - Le dessin du pointeau peut être inversé par la touche "i". Repoussor - It is a question of giving volume to an image. - A spherical tool allows to push away the pixels of a photograph in the third dimension. - This sphere can be moved in plan XOY of the photograph by clicking right and drag. - Before the dragging it is advised to place the cursor of the mouse on the point of the selector, represented by the white arrow. - Keys ' + ' and ' - ' modify the ray of the sphere. - The keys "q" and "w" or UP and DOWN make it possible to move the sphere along axis OZ. - Rotations of the camera are controlled by clicking left and drag. - These movements make it possible to see the deformations in the third dimension. - The transparency of the photograph can be modified the key "o". - The drawing of the punch can be reversed by the key "i". **/ Camera cam; float theta,phi,distanceEcranOeil,cote; Quat lequat; Vecteur camX,camY,camZ,camX0,camY0,camZ0,vectOriginMouse,vectEyeMouse,vectImpact ; int doInverse; PFont mafont; Grille lagrille; PImage photo; void setup(){ size(800,600,P3D); distanceEcranOeil=height/(2*(float)Math.tan(PI/6)); theta=1.0f; phi=1.0f; cote=40; doInverse=1; lequat=new Quat(1,0,0,0); camZ0=new Vecteur(0,0,-1); camZ=camZ0.cloner(); camY0=new Vecteur(0,1,0); camY=camY0.cloner(); camX0=new Vecteur(-1,0,0); camX=camX0.cloner(); cam=new Camera(camX0,camY0,camZ0); vectOriginMouse=new Vecteur(0,0,0); vectImpact=new Vecteur(0,0,cote); mafont=loadFont("ArialBold.vlw"); textFont(mafont,12); lagrille=new Grille(155,215,40); photo = loadImage("acc.jpg"); } void draw(){ background(0); cam.placercamera(); lagrille.dessiner(); } void repere(){ stroke(255 ,0 , 0); line(0,0,0,100,0,0); stroke(0 ,255 ,0 ); line(0,0,0,0,100,0); stroke(0 ,0 ,255 ); line(0,0,0,0,0,100); } Vecteur absolu(float x,float y,float z){ float xx=modelX(x,y,z); float yy=modelY(x,y,z); float zz=modelZ(x,y,z); return new Vecteur(xx,yy,zz); } void keyPressed(){ if(keyCode==UP ||key=='q')cote=cote+1; if(keyCode==DOWN || key=='w')cote=cote-1; vectImpact.z=cote; if(key=='i')doInverse*=-1; if(key=='+')lagrille.pointeur.rayonSphere+=2; if(key=='-'&& lagrille.pointeur.rayonSphere>4)lagrille.pointeur.rayonSphere-=2; if(key=='o'){ lagrille.alterne*=-1; lagrille.opaque=lagrille.opaque+lagrille.alterne*50;println(lagrille.opaque);} } void mouseDragged(){ if(mouseButton==LEFT){//Déplacer la caméra en calculant son nouveau repere theta=(mouseY-pmouseY)/150.0f; phi=(-mouseX+pmouseX)/150.0f; lequat=Quat.mul(new Quat(cos(theta/2),sin(theta/2),0,0),lequat); lequat=Quat.mul(new Quat(cos(phi/2),0,sin(phi/2),0),lequat); camZ=lequat.tourner(camZ0); camY=lequat.tourner(camY0); camX=lequat.tourner(camX0); } if(mouseButton==RIGHT){//déplacer le sélecteuren calculant le vecteur vectImpact vectEyeMouse=camZ.mul(distanceEcranOeil).ajouter(camY,mouseY-height/2). ajouter(camX,-mouseX+width/2); vectOriginMouse=cam.oeil.ajouter(vectEyeMouse,1); intersectionRayonPlanXY(); } } public void intersectionRayonPlanXY(){ if(vectEyeMouse.z!=0){ float lambda=(cote-cam.oeil.z)/vectEyeMouse.z; vectImpact=cam.oeil.ajouter(vectEyeMouse,lambda); } }