Loading main.cpp +97 −78 Original line number Diff line number Diff line Loading @@ -38,119 +38,138 @@ int main(int argc, char** argv) { FILE *file; /*Creation d'une sphere : entite A*/ LrMatrix mat_A=LrMatrix::translate(LrVector(-1, 15, 0)) * LrMatrix::scale(3); LrGeometrySphere geo_A; /*##################### LES OBJETS de LA SCENE #############################*/ /* Entite A : Sphere */ LrMatrix A_Mat = LrMatrix::translate(LrVector(-1, 15, 0)) * LrMatrix::scale(3); LrGeometrySphere A_Geo; LrPertNormalBasic A_Pn; LrColor c_bois1((uint8_t)140,(uint8_t)73,(uint8_t)15); LrColor c_bois2((uint8_t)109,(uint8_t)60,(uint8_t)0); LrColor c_bois3((uint8_t)67,(uint8_t)40,(uint8_t)0); LrPertColorTextProcBois pcb_A(c_bois1, c_bois2, c_bois3, 1.0, 1); LrPertNormalBasic pnb_A; LrOpticPhong opt_A(0.4, 0.6, 0, &pcb_A, &pnb_A, 10); //LrOpticBasic opt_A(0,1,0,&pcb_A,&pnb_A); LrEntityElementary sphere_A(mat_A, &geo_A, &opt_A); /*Creation d'une sphere : entite B*/ LrMatrix mat_B = LrMatrix::translate(LrVector(10, 25, 5)) * LrMatrix::scale(2); LrPertColorTextProcBois A_Pc(c_bois1, c_bois2, c_bois3, 1.0, 1); LrOpticPhong A_Opt(0.4, 0.6, 0, &A_Pc, &A_Pn, 10); LrEntityElementary A(A_Mat, &A_Geo, &A_Opt); /**************************************************************************/ /* Entite B : Sphere */ LrMatrix B_Mat = LrMatrix::translate(LrVector(10, 25, 5)) * LrMatrix::scale(2); LrColor c_1((uint8_t)175,(uint8_t)17,(uint8_t)17); LrColor c_2((uint8_t)0,(uint8_t)100,(uint8_t)100); LrColor c_3((uint8_t)215,(uint8_t)21,(uint8_t)21); LrPertColorTextProcTurbulence pcb_B(c_2, LrColor::YELLOW, c_3, 1.0, 4); LrPertNormalBasic pnb_B; LrOpticPhong opt_B(0.5, 0.5, 0, &pcb_B, &pnb_B, 50); LrEntityElementary sphere_B(mat_B, &geo_A, &opt_B); /*Creation d'une sphere : entite B*/ LrMatrix mat_C = LrMatrix::translate(LrVector(-10, 15, -3)) * LrMatrix::scale(3); LrPertColorTextProcMarbre pcb_C(LrColor::BLACK, LrColor::WHITE, LrColor::GREY, 1, 4); LrPertNormalBasic pnb_C; LrOpticPhong opt_C(0.5, 0.5, 0, &pcb_C, &pnb_C, 50); LrEntityElementary sphere_C(mat_C, &geo_A, &opt_C); /*Creation d'une cube : entite C (cube)*/ LrMatrix mat_D= LrMatrix::translate(LrVector(-25, -7, -10)) * LrMatrix::scale(50); LrGeometryCube geo_C(true); LrPertColorBasic pcb_D(LrColor::WHITE); LrPertNormalBasic pnb_D; LrOpticPhong opt_D(0, 0.8, 0, &pcb_D, &pnb_D, 25); LrEntityElementary cube_D(mat_D, &geo_C, &opt_D); /* PLAN*/ LrMatrix mat_E= LrMatrix::translate(LrVector(0, 0, -6)); LrPertColorTextProcTurbulence B_Pc(c_2, LrColor::YELLOW, c_3, 1.0, 4); LrOpticPhong B_Opt(0.5, 0.5, 0, &B_Pc, &A_Pn, 50); LrEntityElementary B(B_Mat, &A_Geo, &B_Opt); /**************************************************************************/ /* Entite C : Sphere */ LrMatrix C_Mat = LrMatrix::translate(LrVector(-10, 15, -3)) * LrMatrix::scale(3); LrPertColorTextProcMarbre C_Pc(LrColor::BLACK, LrColor::WHITE, LrColor::GREY, 1, 4); LrOpticPhong C_Opt(0.5, 0.5, 0, &C_Pc, &A_Pn, 50); LrEntityElementary C(C_Mat, &A_Geo, &C_Opt); /**************************************************************************/ /* Entite D : Cube*/ LrMatrix D_Mat = LrMatrix::translate(LrVector(-25, -7, -10)) * LrMatrix::scale(50); LrGeometryCube D_Geo(true); LrPertColorBasic D_Pc(LrColor::WHITE); LrOpticPhong D_Opt(0, 0.8, 0, &D_Pc, &A_Pn, 25); LrEntityElementary D(D_Mat, &D_Geo, &D_Opt); /**************************************************************************/ /*Entite E : Plan*/ LrMatrix E_Mat = LrMatrix::translate(LrVector(0, 0, -6)); LrVector normale(0, 0, 1); LrGeometryPlan geo_E(normale); LrPertColorTextProcDamier pcb_E(LrColor::WHITE, LrColor::BLACK, 1.0f); LrGeometryPlan E_Geo(normale); LrPertColorTextProcDamier E_Pc(LrColor::WHITE, LrColor::BLACK, 1.0f); LrOpticPhong E_Opt(0.7, 0.3, 0, &E_Pc, &A_Pn, 25); LrEntityElementary E(E_Mat, &E_Geo, &E_Opt); /**************************************************************************/ /*############################################################################*/ LrPertNormalBasic pnb_E; LrOpticPhong opt_E(0.7, 0.3, 0, &pcb_E, &pnb_E, 25); LrEntityElementary plan_E(mat_E, &geo_E, &opt_E); //Creation d'une lumiere point : entite X (lumiere de droite) LrMatrix mat_lum_X = LrMatrix::translate(LrVector(-5, -8, 5)); LrEntityLightPoint lum_X(mat_lum_X, LrColor(0.8f,0.8f,0.8f)); //LrEntityLightPlane lum_X(mat_lum_X, LrColor(0.6f,0.6f,0.6f),10); /*##################### LES LUMIERES de LA SCENE ###########################*/ //Creation d'une lumiere point : entite Y (Lumiere au plafond) LrMatrix mat_lum_Y = LrMatrix::translate(LrVector(0, 0, 20)); LrEntityLightPoint lum_Y(mat_lum_Y, LrColor(0.6f,0.6f,0.6f)); //LrEntityLightPlane lum_Y(mat_lum_Y, LrColor(0.6f,0.6f,0.6f),10); //Entite X LrMatrix X_Mat = LrMatrix::translate(LrVector(-5, -8, 5)); LrEntityLightPoint X(X_Mat, LrColor(0.8f,0.8f,0.8f)); //LrEntityLightPlane X(X_Mat, LrColor(0.6f,0.6f,0.6f),10); /**************************************************************************/ //Creation d'une lumiere point : entite Z (Lumiere de gauche) LrMatrix mat_lum_Z = LrMatrix::translate(LrVector(5, 0, 5)); LrEntityLightPoint lum_Z(mat_lum_Z, LrColor(0.8f,0.8f,0.8f)); //LrEntityLightPlane lum_Z(mat_lum_Z, LrColor(0.6f,0.6f,0.6f),10); //Entite Y LrMatrix Y_Mat = LrMatrix::translate(LrVector(0, 0, 20)); LrEntityLightPoint Y(Y_Mat, LrColor(0.6f,0.6f,0.6f)); //LrEntityLightPlane Y(Y_Mat, LrColor(0.6f,0.6f,0.6f),10); /**************************************************************************/ //Creation de la Liste des entites-lumieres et ajout des entites-lumieres dans cette liste LrScene::LrEntityList list_lights; //Entite Z LrMatrix Z_Mat = LrMatrix::translate(LrVector(5, 0, 5)); LrEntityLightPoint Z(Z_Mat, LrColor(0.8f,0.8f,0.8f)); //LrEntityLightPlane Z(Z_Mat, LrColor(0.6f,0.6f,0.6f),10); /**************************************************************************/ /*############################################################################*/ list_lights.push_back(&lum_Z); list_lights.push_back(&lum_Y); list_lights.push_back(&lum_X); /*##################### LES LISTES D'OBJETS ET DE LUMIERES #################*/ //Creation de la Liste des entites-lumieres et ajout des //entites-lumieres dans cette liste LrScene::LrEntityList list_lights; list_lights.push_back(&X); list_lights.push_back(&Y); list_lights.push_back(&Z); /**************************************************************************/ //Creation de la Liste des entites et ajout des entites dans cette liste LrScene::LrEntityList list_entities; list_entities.push_back(&sphere_A); list_entities.push_back(&sphere_C); //list_entities.push_back(&cube_D); list_entities.push_back(&plan_E); list_entities.push_back(&sphere_B); list_entities.push_back(&A); list_entities.push_back(&B); list_entities.push_back(&C); //list_entities.push_back(&D); list_entities.push_back(&E); /**************************************************************************/ /*############################################################################*/ /*########### STRUCTURE ACCELERATRICE, IMAGE, CAMERA, SCENE #################*/ //La structure acceleratrice LrBinderSimple bind_A(list_entities); LrBinderSimple binder(list_entities); //Image et camera LrImage img_A(600,600); LrPoint pt_origine_cam(0, -25, 0); LrCameraPlane cam_A(pt_origine_cam,LrVector::K,LrVector::J,M_PI/4,M_PI/4); //Image LrImage image(600,600); //L'antiAliasing //Camera LrPoint position_camera(0, -25, 0); LrCameraPlane camera(position_camera,LrVector::K,LrVector::J,M_PI/4,M_PI/4); //AntiAliasing LrAntiAliasingCentre aa(1); //LrAntiAliasingRandom aa(1); //LrAntiAliasingCentre aa(2); //LrAntiAliasingRandom aa(2); //LrAntiAliasingCentre aa(4); //LrAntiAliasingRandom aa(4); //La scene avec 5 rebonds LrSceneRayTracing scene_A(list_entities, list_lights,&bind_A, &img_A, &cam_A, &aa, 10); //La SCENE LrSceneRayTracing scene(list_entities, list_lights,&binder, &image, &camera, &aa, 10); cout<<"RayTracing Start..."<< endl; //Lancement de l'algorithme de lancer de rayons (parametre : nb de threads) scene_A.generateImage(8); scene.generateImage(8); //Sauvegarde de l'image file = fopen("./test21.ppm","wb"); img_A.savePPM(file); image.savePPM(file); fclose(file); cout<<"Image generee dans le fichier"<<endl; /*############################################################################*/ } Loading
main.cpp +97 −78 Original line number Diff line number Diff line Loading @@ -38,119 +38,138 @@ int main(int argc, char** argv) { FILE *file; /*Creation d'une sphere : entite A*/ LrMatrix mat_A=LrMatrix::translate(LrVector(-1, 15, 0)) * LrMatrix::scale(3); LrGeometrySphere geo_A; /*##################### LES OBJETS de LA SCENE #############################*/ /* Entite A : Sphere */ LrMatrix A_Mat = LrMatrix::translate(LrVector(-1, 15, 0)) * LrMatrix::scale(3); LrGeometrySphere A_Geo; LrPertNormalBasic A_Pn; LrColor c_bois1((uint8_t)140,(uint8_t)73,(uint8_t)15); LrColor c_bois2((uint8_t)109,(uint8_t)60,(uint8_t)0); LrColor c_bois3((uint8_t)67,(uint8_t)40,(uint8_t)0); LrPertColorTextProcBois pcb_A(c_bois1, c_bois2, c_bois3, 1.0, 1); LrPertNormalBasic pnb_A; LrOpticPhong opt_A(0.4, 0.6, 0, &pcb_A, &pnb_A, 10); //LrOpticBasic opt_A(0,1,0,&pcb_A,&pnb_A); LrEntityElementary sphere_A(mat_A, &geo_A, &opt_A); /*Creation d'une sphere : entite B*/ LrMatrix mat_B = LrMatrix::translate(LrVector(10, 25, 5)) * LrMatrix::scale(2); LrPertColorTextProcBois A_Pc(c_bois1, c_bois2, c_bois3, 1.0, 1); LrOpticPhong A_Opt(0.4, 0.6, 0, &A_Pc, &A_Pn, 10); LrEntityElementary A(A_Mat, &A_Geo, &A_Opt); /**************************************************************************/ /* Entite B : Sphere */ LrMatrix B_Mat = LrMatrix::translate(LrVector(10, 25, 5)) * LrMatrix::scale(2); LrColor c_1((uint8_t)175,(uint8_t)17,(uint8_t)17); LrColor c_2((uint8_t)0,(uint8_t)100,(uint8_t)100); LrColor c_3((uint8_t)215,(uint8_t)21,(uint8_t)21); LrPertColorTextProcTurbulence pcb_B(c_2, LrColor::YELLOW, c_3, 1.0, 4); LrPertNormalBasic pnb_B; LrOpticPhong opt_B(0.5, 0.5, 0, &pcb_B, &pnb_B, 50); LrEntityElementary sphere_B(mat_B, &geo_A, &opt_B); /*Creation d'une sphere : entite B*/ LrMatrix mat_C = LrMatrix::translate(LrVector(-10, 15, -3)) * LrMatrix::scale(3); LrPertColorTextProcMarbre pcb_C(LrColor::BLACK, LrColor::WHITE, LrColor::GREY, 1, 4); LrPertNormalBasic pnb_C; LrOpticPhong opt_C(0.5, 0.5, 0, &pcb_C, &pnb_C, 50); LrEntityElementary sphere_C(mat_C, &geo_A, &opt_C); /*Creation d'une cube : entite C (cube)*/ LrMatrix mat_D= LrMatrix::translate(LrVector(-25, -7, -10)) * LrMatrix::scale(50); LrGeometryCube geo_C(true); LrPertColorBasic pcb_D(LrColor::WHITE); LrPertNormalBasic pnb_D; LrOpticPhong opt_D(0, 0.8, 0, &pcb_D, &pnb_D, 25); LrEntityElementary cube_D(mat_D, &geo_C, &opt_D); /* PLAN*/ LrMatrix mat_E= LrMatrix::translate(LrVector(0, 0, -6)); LrPertColorTextProcTurbulence B_Pc(c_2, LrColor::YELLOW, c_3, 1.0, 4); LrOpticPhong B_Opt(0.5, 0.5, 0, &B_Pc, &A_Pn, 50); LrEntityElementary B(B_Mat, &A_Geo, &B_Opt); /**************************************************************************/ /* Entite C : Sphere */ LrMatrix C_Mat = LrMatrix::translate(LrVector(-10, 15, -3)) * LrMatrix::scale(3); LrPertColorTextProcMarbre C_Pc(LrColor::BLACK, LrColor::WHITE, LrColor::GREY, 1, 4); LrOpticPhong C_Opt(0.5, 0.5, 0, &C_Pc, &A_Pn, 50); LrEntityElementary C(C_Mat, &A_Geo, &C_Opt); /**************************************************************************/ /* Entite D : Cube*/ LrMatrix D_Mat = LrMatrix::translate(LrVector(-25, -7, -10)) * LrMatrix::scale(50); LrGeometryCube D_Geo(true); LrPertColorBasic D_Pc(LrColor::WHITE); LrOpticPhong D_Opt(0, 0.8, 0, &D_Pc, &A_Pn, 25); LrEntityElementary D(D_Mat, &D_Geo, &D_Opt); /**************************************************************************/ /*Entite E : Plan*/ LrMatrix E_Mat = LrMatrix::translate(LrVector(0, 0, -6)); LrVector normale(0, 0, 1); LrGeometryPlan geo_E(normale); LrPertColorTextProcDamier pcb_E(LrColor::WHITE, LrColor::BLACK, 1.0f); LrGeometryPlan E_Geo(normale); LrPertColorTextProcDamier E_Pc(LrColor::WHITE, LrColor::BLACK, 1.0f); LrOpticPhong E_Opt(0.7, 0.3, 0, &E_Pc, &A_Pn, 25); LrEntityElementary E(E_Mat, &E_Geo, &E_Opt); /**************************************************************************/ /*############################################################################*/ LrPertNormalBasic pnb_E; LrOpticPhong opt_E(0.7, 0.3, 0, &pcb_E, &pnb_E, 25); LrEntityElementary plan_E(mat_E, &geo_E, &opt_E); //Creation d'une lumiere point : entite X (lumiere de droite) LrMatrix mat_lum_X = LrMatrix::translate(LrVector(-5, -8, 5)); LrEntityLightPoint lum_X(mat_lum_X, LrColor(0.8f,0.8f,0.8f)); //LrEntityLightPlane lum_X(mat_lum_X, LrColor(0.6f,0.6f,0.6f),10); /*##################### LES LUMIERES de LA SCENE ###########################*/ //Creation d'une lumiere point : entite Y (Lumiere au plafond) LrMatrix mat_lum_Y = LrMatrix::translate(LrVector(0, 0, 20)); LrEntityLightPoint lum_Y(mat_lum_Y, LrColor(0.6f,0.6f,0.6f)); //LrEntityLightPlane lum_Y(mat_lum_Y, LrColor(0.6f,0.6f,0.6f),10); //Entite X LrMatrix X_Mat = LrMatrix::translate(LrVector(-5, -8, 5)); LrEntityLightPoint X(X_Mat, LrColor(0.8f,0.8f,0.8f)); //LrEntityLightPlane X(X_Mat, LrColor(0.6f,0.6f,0.6f),10); /**************************************************************************/ //Creation d'une lumiere point : entite Z (Lumiere de gauche) LrMatrix mat_lum_Z = LrMatrix::translate(LrVector(5, 0, 5)); LrEntityLightPoint lum_Z(mat_lum_Z, LrColor(0.8f,0.8f,0.8f)); //LrEntityLightPlane lum_Z(mat_lum_Z, LrColor(0.6f,0.6f,0.6f),10); //Entite Y LrMatrix Y_Mat = LrMatrix::translate(LrVector(0, 0, 20)); LrEntityLightPoint Y(Y_Mat, LrColor(0.6f,0.6f,0.6f)); //LrEntityLightPlane Y(Y_Mat, LrColor(0.6f,0.6f,0.6f),10); /**************************************************************************/ //Creation de la Liste des entites-lumieres et ajout des entites-lumieres dans cette liste LrScene::LrEntityList list_lights; //Entite Z LrMatrix Z_Mat = LrMatrix::translate(LrVector(5, 0, 5)); LrEntityLightPoint Z(Z_Mat, LrColor(0.8f,0.8f,0.8f)); //LrEntityLightPlane Z(Z_Mat, LrColor(0.6f,0.6f,0.6f),10); /**************************************************************************/ /*############################################################################*/ list_lights.push_back(&lum_Z); list_lights.push_back(&lum_Y); list_lights.push_back(&lum_X); /*##################### LES LISTES D'OBJETS ET DE LUMIERES #################*/ //Creation de la Liste des entites-lumieres et ajout des //entites-lumieres dans cette liste LrScene::LrEntityList list_lights; list_lights.push_back(&X); list_lights.push_back(&Y); list_lights.push_back(&Z); /**************************************************************************/ //Creation de la Liste des entites et ajout des entites dans cette liste LrScene::LrEntityList list_entities; list_entities.push_back(&sphere_A); list_entities.push_back(&sphere_C); //list_entities.push_back(&cube_D); list_entities.push_back(&plan_E); list_entities.push_back(&sphere_B); list_entities.push_back(&A); list_entities.push_back(&B); list_entities.push_back(&C); //list_entities.push_back(&D); list_entities.push_back(&E); /**************************************************************************/ /*############################################################################*/ /*########### STRUCTURE ACCELERATRICE, IMAGE, CAMERA, SCENE #################*/ //La structure acceleratrice LrBinderSimple bind_A(list_entities); LrBinderSimple binder(list_entities); //Image et camera LrImage img_A(600,600); LrPoint pt_origine_cam(0, -25, 0); LrCameraPlane cam_A(pt_origine_cam,LrVector::K,LrVector::J,M_PI/4,M_PI/4); //Image LrImage image(600,600); //L'antiAliasing //Camera LrPoint position_camera(0, -25, 0); LrCameraPlane camera(position_camera,LrVector::K,LrVector::J,M_PI/4,M_PI/4); //AntiAliasing LrAntiAliasingCentre aa(1); //LrAntiAliasingRandom aa(1); //LrAntiAliasingCentre aa(2); //LrAntiAliasingRandom aa(2); //LrAntiAliasingCentre aa(4); //LrAntiAliasingRandom aa(4); //La scene avec 5 rebonds LrSceneRayTracing scene_A(list_entities, list_lights,&bind_A, &img_A, &cam_A, &aa, 10); //La SCENE LrSceneRayTracing scene(list_entities, list_lights,&binder, &image, &camera, &aa, 10); cout<<"RayTracing Start..."<< endl; //Lancement de l'algorithme de lancer de rayons (parametre : nb de threads) scene_A.generateImage(8); scene.generateImage(8); //Sauvegarde de l'image file = fopen("./test21.ppm","wb"); img_A.savePPM(file); image.savePPM(file); fclose(file); cout<<"Image generee dans le fichier"<<endl; /*############################################################################*/ }