void displayAxis(Camara &cam, Transformacion marco){ //Fotografía con la camara c y muestra en el marco Punto o = cam.shot(OR).transform(marco); Punto x = cam.shot(EX).transform(marco); Punto y = cam.shot(EY).transform(marco); Punto z = cam.shot(EZ).transform(marco); Flecha((x-o), Color::ROJO ).drawAt(o); Flecha((y-o), Color::VERDE).drawAt(o); Flecha((z-o), Color::AZUL ).drawAt(o); float x_color[] ={1.0,0.0,0.0,1.0}; glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,x_color); Flecha((x-o)*3,Color::ROJO).drawAt(o); float y_color[] ={0.0,1.0,0.0,1.0}; glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,y_color); Flecha((y-o)*3,Color::VERDE).drawAt(o); float z_color[] ={0.0,0.0,1.0,1.0}; glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,z_color); Flecha((z-o)*3,Color::AZUL).drawAt(o); }
void displayTeapot(Camara &cam, Transformacion marco){ //Dibuja la foto de un Cubo con la cam y la pone en t // Transformacion de la camara Transformacion rotcam; Transformacion rotationx, rotationy; Punto newAT = AT; rotationx.rotX(rotationX); rotationy.rotY(rotationY); newAT = newAT.transform(rotationx); newAT = newAT.transform(rotationy); Punto vert = Punto(0.0, 1.0, 0.0); vert.transform(rotcam); canon.at(newAT); canon.lookAt(OR); canon.setVertical(vert.asVector()); Punto newFR = FR; newFR = newFR.transform(rotationy); frontal.at(newFR); frontal.lookAt(OR); Punto newPE = PE; newPE = newPE.transform(rotationy); perfil.at(newPE); perfil.lookAt(OR); Punto newCE = CE; newCE = newCE.transform(rotationy); cenital.setVertical(newCE.asVector()); rotationx.reset(); rotationy.reset(); Transformacion t = marco * cam.getview(); //Dibujo de la tetera Transformacion rot; rot.rotX(-90); Transformacion mov; mov.translation(Real4(0.0, -1.0, 0.0)); for(int k=0;k<32;k++){ S[k].getPoints(NVERT, sb); S[k].getTangents(NVERT, tgU, tgV); S[k].getNormals(NVERT, n); for(int i=0;i<NVERT*NVERT;i++){ sb[i] = sb[i].transform(rot).transform(mov); sb[i] = cam.shot(sb[i]).transform(marco); float sup_color[] = {0.5, 0.5, 0.5, 1.0}; //Gris glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, sup_color); } if(inalambrico){ for(int i=0;i<NVERT-1;i++){ for(int j=0;j<NVERT-1;j++){ glBegin(GL_QUADS); glNormal3f(n[NVERT*i+j].x(),n[NVERT*i+j].y(),n[NVERT*i+j].z()); glVertex3f(sb[NVERT*i+j].x(),sb[NVERT*i+j].y(),sb[NVERT*i+j].z()); glNormal3f(n[NVERT*(i+1)+j].x(),n[NVERT*(i+1)+j].y(),n[NVERT*(i+1)+j].z()); glVertex3f(sb[NVERT*(i+1)+j].x(),sb[NVERT*(i+1)+j].y(),sb[NVERT*(i+1)+j].z()); glNormal3f(n[NVERT*(i+1)+(j+1)].x(),n[NVERT*(i+1)+(j+1)].y(),n[NVERT*(i+1)+(j+1)].z()); glVertex3f(sb[NVERT*(i+1)+(j+1)].x(),sb[NVERT*(i+1)+(j+1)].y(),sb[NVERT*(i+1)+(j+1)].z()); glNormal3f(n[NVERT*i+(j+1)].x(),n[NVERT*i+(j+1)].y(),n[NVERT*i+(j+1)].z()); glVertex3f(sb[NVERT*i+(j+1)].x(),sb[NVERT*i+(j+1)].y(),sb[NVERT*i+(j+1)].z()); glEnd(); }; }; } else{ for(int i=0;i<NVERT;i++){ glBegin(GL_LINE_STRIP); for(int j=0;j<NVERT;j++){ glVertex3f( (GLfloat)((sb[i*NVERT+j]).x()), (GLfloat)((sb[i*NVERT+j]).y()), (GLfloat)((sb[i*NVERT+j]).z())); } glEnd(); } for(int i=0;i<NVERT;i++){ glBegin(GL_LINE_STRIP); for(int j=0;j<NVERT;j++){ glVertex3f( (GLfloat)((sb[i+j*NVERT]).x()), (GLfloat)((sb[i+j*NVERT]).y()), (GLfloat)((sb[i+j*NVERT]).z())); } glEnd(); } } } }