Commit 3bd7bbc1 authored by Emeric Verschuur's avatar Emeric Verschuur

--no commit message

--no commit message
parent 18aa9f9f
......@@ -3,6 +3,7 @@
#endif
#include "LrSceneRayTracing.h"
#include "LrEntityElementary.h"
#include "LrEntityComposed.h"
#include "LrCameraPlane.h"
#include "LrCameraSpheric.h"
#include "LrCameraSpheric.h"
......@@ -39,97 +40,60 @@ int main(int argc, char** argv)
/*##################### LES OBJETS de LA SCENE #############################*/
/* Entite A : Sphere */
LrMatrix A_Mat = LrMatrix::scale(2);
LrGeometrySphere A_Geo;
LrPertNormalBasic A_Pn;
LrPertNormalPerlin A_Pn2(50);
LrColor c_bois1((uint8_t)140,(uint8_t)73,(uint8_t)0);
LrColor c_bois2((uint8_t)178,(uint8_t)92,(uint8_t)0);
LrColor c_bois3((uint8_t)74,(uint8_t)38,(uint8_t)0);
LrPertColor3DPBois A_Pc(c_bois1, c_bois2, c_bois3, 1.0, 1, 1, COS, false);
LrOpticPhong A_Opt(0, 0.8, 0, 1, &A_Pc, &A_Pn2, 0);
LrEntityElementary A(A_Mat, &A_Geo, &A_Opt);
/**************************************************************************/
/* Entite B : Sphere */
LrMatrix B_Mat = 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(LrColor::WHITE);
//LrPertNormalPerlin B_Pn(0.5);
LrPertNormalBasic B_Pn;
LrPertColor3DPTurbulence B_Pc(c_2, c_3, c_3, 1, 6, 1, COS, false);
LrOpticPhong B_Opt(0.5, 0.5, 0, 1, &B_Pc, &B_Pn, 50);
LrEntityElementary B(B_Mat, &A_Geo, &B_Opt);
/**************************************************************************/
/* Entite C : Sphere */
LrMatrix C_Mat = LrMatrix::scale(2);
LrPertColor3DPMarbre C_Pc(LrColor::BLACK, LrColor::WHITE, LrColor::GREY, 1, 4, 1, LIN, false);
LrOpticPhong C_Opt(0.4, 0.6, 0, 1, &C_Pc, &A_Pn, 50);
LrEntityElementary C(C_Mat, &A_Geo, &C_Opt);
/**************************************************************************/
/* Entite D : Cube*/
LrMatrix D_Mat = LrMatrix::translate(LrVector(0, 0, -2)) * LrMatrix::scale(2);;
LrGeometryCube D_Geo(false);
//LrPertColorBasic D_Pc(LrColor::YELLOW);
LrColor cb_bois1((uint8_t)140,(uint8_t)73,(uint8_t)0);
LrColor cb_bois2((uint8_t)178,(uint8_t)92,(uint8_t)0);
LrColor cb_bois3((uint8_t)74,(uint8_t)38,(uint8_t)0);
LrPertColor3DPBois D_Pc(cb_bois3, cb_bois1, cb_bois2, 1, 1, 1, COS, false);
LrOpticPhong D_Opt(0, 0.5, 0, 1, &D_Pc, &A_Pn, 25);
LrEntityElementary D(D_Mat, &D_Geo, &D_Opt);
/**************************************************************************/
LrScene::LrEntityList entLst;
LrMatrix matA/* = LrMatrix::translate(LrVector(-.75,-3.,.25))
* LrMatrix::scale(2)
* LrMatrix::rotateY(-M_PI/6)
* LrMatrix::rotateZ(-M_PI/6)
* LrMatrix::rotateX(-M_PI/6)*/;
LrMatrix matB = LrMatrix::translate(LrVector(0.,0.,0.))
* LrMatrix::scale(0.9);
LrMatrix matC = LrMatrix::translate(LrVector(-1.,0.,-1.))
* LrMatrix::scale(0.9);
LrMatrix matD = LrMatrix::translate(LrVector(-1.,0.,0.))
* LrMatrix::scale(0.9);
LrGeometryCube geoCube;
LrPertNormalBasic perfN;
LrPertColorTexture perfCB1(fopen("earth.ppm","rw"));
LrPertColorTxtPrc3DPerlin perfCB2();
LrPertColorTwoLayers perfCB(&perfCB1,&perfCB2,0.5);
LrPertColorTexture perfCC(fopen("moon.ppm","rw"));
LrPertColorTexture perfCD(fopen("sun.ppm","rw"));
LrOpticPhong optB(0.,1.,0,0,&perfCB,&perfN,10);
LrOpticPhong optC(0.,1.,0,0,&perfCC,&perfN,10);
LrOpticPhong optD(0.,1.,0,0,&perfCD,&perfN,10);
LrEntityElementary B(matB,&geoCube,&optB);
LrEntityElementary C(matC,&geoCube,&optC);
LrEntityElementary D(matD,&geoCube,&optD);
entLst.clear();
entLst.push_back(&B);
entLst.push_back(&C);
entLst.push_back(&D);
LrEntityComposed A(matA,entLst);
entLst.clear();
entLst.push_back(&A);
/*Entite E : Plan*/
LrMatrix E_Mat = LrMatrix::translate(LrVector(0, 0, -2));
LrVector normaleP1(0, 0, 1);
LrGeometryPlan E_Geo(normaleP1);
LrPertColor3DDamier E_Pc(LrColor::WHITE, LrColor::BLACK, 1.0f);
LrOpticPhong E_Opt(0.5, 0.3, 0, 1, &E_Pc, &A_Pn, 50);
LrEntityElementary E(E_Mat, &E_Geo, &E_Opt);
LrMatrix ciel_Mat = LrMatrix::translate(LrVector(0, 0, 100));
LrVector normaleP2(0, 0, -1);
LrGeometryPlan ciel_Geo(normaleP2);
LrColor c_ciel((uint8_t)0,(uint8_t)125,(uint8_t)100);
LrPertColor3DPTurbulence ciel_Pc(c_ciel, LrColor::WHITE, LrColor::WHITE, 1, 6, 0.01, COS, true);
LrOpticPhong ciel_Opt(0.0, 0.5, 0, 1, &ciel_Pc, &A_Pn, 0);
LrEntityElementary ciel(ciel_Mat, &ciel_Geo, &ciel_Opt);
LrMatrix ciel_Mat2 = LrMatrix::translate(LrVector(0, 100, 0));
LrVector normaleP3(0, -1, 0);
LrGeometryPlan ciel_Geo2(normaleP3);
LrColor c_ciel2((uint8_t)0,(uint8_t)125,(uint8_t)100);
LrPertColor3DPTurbulence ciel_Pc2(c_ciel, LrColor::WHITE, LrColor::WHITE, 1, 6, 0.005, COS, false);
LrOpticPhong ciel_Opt2(0.0, 0.5, 0, 1, &ciel_Pc2, &A_Pn, 0);
LrEntityElementary ciel2(ciel_Mat2, &ciel_Geo2, &ciel_Opt2);
/**************************************************************************/
/*############################################################################*/
/*##################### LES LUMIERES de LA SCENE ###########################*/
//Entite X
LrMatrix X_Mat = LrMatrix::translate(LrVector(-50, 0, 50));
LrMatrix X_Mat = LrMatrix::translate(LrVector(0, -20, 0));
// LrLightPoint X(X_Mat, LrColor(0.4f,0.4f,0.4f));
LrLightPlane X(X_Mat, LrColor(0.6f,0.6f,0.6f),10);
/**************************************************************************/
//Entite Y
LrMatrix Y_Mat = LrMatrix::translate(LrVector(0, 0, 20));
// LrLightPoint Y(Y_Mat, LrColor(0.6f,0.6f,0.6f));
LrLightPlane Y(Y_Mat, LrColor(0.6f,0.6f,0.6f),10);
/**************************************************************************/
//Entite Z
LrMatrix Z_Mat = LrMatrix::translate(LrVector(50, 0, 50));
// LrLightPoint Z(Z_Mat, LrColor(0.4f,0.4f,0.4f));
LrLightPlane Z(Z_Mat, LrColor(0.6f,0.6f,0.6f),10);
LrLightPoint Y(Y_Mat, LrColor(0.6f,0.6f,0.6f));
// LrLightPlane Y(Y_Mat, LrColor(0.6f,0.6f,0.6f),10);
/**************************************************************************/
/*############################################################################*/
......@@ -141,19 +105,10 @@ int main(int argc, char** argv)
//entites-lumieres dans cette liste
LrScene::LrLightList list_lights;
list_lights.push_back(&X);
//list_lights.push_back(&Y);
list_lights.push_back(&Z);
// list_lights.push_back(&Y);
/**************************************************************************/
//Creation de la Liste des entites et ajout des entites dans cette liste
LrScene::LrEntityList list_entities;
//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);
list_entities.push_back(&ciel2);
list_entities.push_back(&ciel);
/**************************************************************************/
......@@ -164,13 +119,13 @@ int main(int argc, char** argv)
/*########### STRUCTURE ACCELERATRICE, IMAGE, CAMERA, SCENE #################*/
//La structure acceleratrice
LrBinderSimple binder(list_entities);
LrBinderSimple binder(entLst);
//Image
LrImage image(600,600);
//Camera
LrPoint position_camera(0, -12, 0);
LrPoint position_camera(0, -10, 0);
LrCameraPlane camera(position_camera,LrVector::K,LrVector::J,M_PI/4,M_PI/4);
//AntiAliasing
......@@ -182,17 +137,11 @@ int main(int argc, char** argv)
// LrAntiAliasingRandom aa(4);
//La SCENE
LrSceneRayTracing scene(list_entities, list_lights,&binder, &image, &camera, &aa, 2);
LrSceneRayTracing scene(entLst, list_lights,&binder, &image, &camera, &aa, 2);
cout<<"RayTracing Start..."<< endl;
//Lancement de l'algorithme de lancer de rayons (parametre : nb de threads)
scene.generateImage(2);
//scene.generateImagePart(0,600);
//Sauvegarde de l'image
//file = fopen("./testTurbulenceLin.ppm","wb");
//file = fopen("./testTurbulenceCos.ppm","wb");
//file = fopen("./testPerlinLin.ppm","wb");
//file = fopen("./testPerlinCos.ppm","wb");
file = fopen("./test01.ppm","wb");
image.savePPM(file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment