void shootMulti(Terrain* const t, const QString& img, int nbShoot){ Vector3D o(-3400, 2800, -2200); Vector3D soleil(100000000,0,0); Vector3D dirCam(500,0,500); QMatrix3x3 mat; mat(0,0)=cos(2*M_PI/nbShoot); mat(0,1)=-sin(2*M_PI/nbShoot); mat(0,2)=0; mat(1,0)=sin(2*M_PI/nbShoot); mat(1,1)=cos(2*M_PI/nbShoot); mat(1,2)=0; mat(2,0)=0; mat(2,1)=0; mat(2,2)=1; QMatrix3x3 matcam; matcam(0,0)=cos(2*M_PI/nbShoot); matcam(0,1)=0; matcam(0,2)=sin(2*M_PI/nbShoot); matcam(1,0)=0; matcam(1,1)=1; matcam(1,2)=0; matcam(2,0)=-sin(2*M_PI/nbShoot); matcam(2,1)=0; matcam(2,2)=cos(2*M_PI/nbShoot); for(int i=0; i<nbShoot;++i){ Camera cam(o, dirCam, 6.92820); soleil.rotate(mat); o.rotate(matcam); QImage result = cam.printScreen(t,soleil,192*10,108*10); QString nameImage =img; nameImage+=std::to_string(i).c_str(); nameImage+=".png"; result.save(nameImage); std::cerr<<"\r"<<100.0*(i+1)/nbShoot<<"%"; } }
void shoot(Terrain* const t, const QString& img){ Vector3D o(-3400, 2800, -2200); Vector3D d(1,-1,1); Vector3D soleil(100000000,0,0); QMatrix3x3 mat1; mat1(0,0)=cos(3*M_PI/4); mat1(0,1)=-sin(3*M_PI/4); mat1(0,2)=0; mat1(1,0)=sin(3*M_PI/4); mat1(1,1)=cos(3*M_PI/4); mat1(1,2)=0; mat1(2,0)=0; mat1(2,1)=0; mat1(2,2)=1; soleil.rotate(mat1); Vector3D dirCam(500,0,500); Vector3D dist(o+d); Camera cam(o, dirCam, o.distanceToPoint(dist)*4); QImage result = cam.printScreen(t,soleil,192*10,108*10); result.save(img); }
void bliterArrierePlan(SDL_Surface *ecran, Camera camera, int largeurFenetre, int hauteurFenetre, Portion_Map world[][PROFONDEUR_MONDE], int tempsJour) { int chunkX(0), chunkY(0), blocX(0), blocY(0); SDL_Rect positionBloc; SDL_Rect positionSoleil; SDL_Surface *soleil(IMG_Load("textures/ciel/soleil.png")); SDL_Surface *lune(IMG_Load("textures/ciel/lune.png")); SDL_Surface *pierreBackGround(IMG_Load("textures/ciel/backGroundPierre.png")); SDL_Surface *terreBackGround(IMG_Load("textures/ciel/backGroundTerre.png")); positionSoleil.x = largeurFenetre / 4; positionSoleil.y = hauteurFenetre / 4; if (tempsJour >= 32400 && tempsJour <= 75600) { SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 119, 181, 254)); SDL_BlitSurface(soleil, NULL, ecran, &positionSoleil); for (int x(0); x < LARGEUR_MONDE; x++) { for (int y(0); y < PROFONDEUR_MONDE; y++) { for (int a(0); a < LARGEUR_PARTIE_MAP; a++) { for (int b(0); b < PROFONDEUR_PARTIE_MAP; b++) { world[x][y].blocs[a][b].luminosite = 15; } } } } } else { SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 4, 7, 10)); SDL_BlitSurface(lune, NULL, ecran, &positionSoleil); for (int x(0); x < LARGEUR_MONDE; x++) { for (int y(0); y < PROFONDEUR_MONDE; y++) { for (int a(0); a < LARGEUR_PARTIE_MAP; a++) { for (int b(0); b < PROFONDEUR_PARTIE_MAP; b++) { world[x][y].blocs[a][b].luminosite = 3; } } } } } for (int x(0); x < LARGEUR_MONDE * LARGEUR_PARTIE_MAP * TAILLE_BLOCK; x += TAILLE_BLOCK) { for (int y(0); y < LARGEUR_MONDE * LARGEUR_PARTIE_MAP * TAILLE_BLOCK; y += TAILLE_BLOCK) { positionBloc.x = x - camera.posCamX; positionBloc.y = y - camera.posCamY; chunkX = (x / TAILLE_BLOCK) / LARGEUR_PARTIE_MAP; chunkY = (y / TAILLE_BLOCK) / PROFONDEUR_PARTIE_MAP; blocX = (x / TAILLE_BLOCK) - (chunkX * LARGEUR_PARTIE_MAP); blocY = (y / TAILLE_BLOCK) - (chunkY * PROFONDEUR_PARTIE_MAP); if ((chunkY * PROFONDEUR_PARTIE_MAP) + blocY > 54 && (chunkY * PROFONDEUR_PARTIE_MAP) + blocY <= 64 && world[chunkX][chunkY].blocs[blocX][blocY].type == AIR) { if (x > camera.posCamX - TAILLE_BLOCK && x < (camera.posCamX + largeurFenetre) + TAILLE_BLOCK) { if (y > camera.posCamY - TAILLE_BLOCK && y < (camera.posCamY + hauteurFenetre) + TAILLE_BLOCK) { SDL_BlitSurface(terreBackGround, NULL, ecran, &positionBloc); } } } else if ((chunkY * PROFONDEUR_PARTIE_MAP) + blocY > 64 && world[chunkX][chunkY].blocs[blocX][blocY].type == AIR) { SDL_BlitSurface(pierreBackGround, NULL, ecran, &positionBloc); } } } SDL_FreeSurface(soleil); SDL_FreeSurface(lune); SDL_FreeSurface(pierreBackGround); SDL_FreeSurface(terreBackGround); }