void initRemap(const array<double, 6> & params1, const array<double, 3> & params2, Mat32f & mapX, Mat32f & mapY, const array<double, 3> & rot) { EnhancedCamera cam1(params1.data()); Pinhole cam2(params2[0], params2[1], params2[2]); Vector2dVec imagePoints; mapX.create(params2[1]*2, params2[0]*2); mapY.create(params2[1]*2, params2[0]*2); for (unsigned int i = 0; i < mapX.rows; i++) { for (unsigned int j = 0; j < mapX.cols; j++) { imagePoints.push_back(Vector2d(j, i)); } } Vector3dVec pointCloud; cam2.reconstructPointCloud(imagePoints, pointCloud); Transformation<double> T(0, 0, 0, rot[0], rot[1], rot[2]); T.transform(pointCloud, pointCloud); cam1.projectPointCloud(pointCloud, imagePoints); auto pointIter = imagePoints.begin(); for (unsigned int i = 0; i < mapX.rows; i++) { for (unsigned int j = 0; j < mapX.cols; j++) { mapX(i, j) = (*pointIter)[0]; mapY(i, j) = (*pointIter)[1]; ++pointIter; } } }
void setupCasadiVars(const std::vector<Matrix<X_DIM> >& X, const std::vector<Matrix<U_DIM> >& U, double* XU_arr, double* Sigma0_arr, double* params_arr, double* cam0_arr, double* cam1_arr) { int index = 0; for(int t = 0; t < T-1; ++t) { for(int i=0; i < X_DIM; ++i) { XU_arr[index++] = X[t][i]; } for(int i=0; i < U_DIM; ++i) { XU_arr[index++] = U[t][i]; } } for(int i=0; i < X_DIM; ++i) { XU_arr[index++] = X[T-1][i]; } Matrix<X_DIM,X_DIM> Sigma0 = SqrtSigma0*SqrtSigma0; index = 0; for(int i=0; i < X_DIM; ++i) { for(int j=0; j < X_DIM; ++j) { Sigma0_arr[index++] = Sigma0(i,j); } } params_arr[0] = alpha_belief; params_arr[1] = alpha_control; params_arr[2] = alpha_final_belief; cam0_arr[0] = cam0(0,0); cam0_arr[1] = cam0(1,0); cam0_arr[2] = cam0(2,0); cam1_arr[0] = cam1(0,0); cam1_arr[1] = cam1(1,0); cam1_arr[2] = cam1(2,0); }
int main() { auto devices = aa::camera::get_devices(); auto camera1_device = *devices.begin(); auto camera2_device = *(++devices.begin()); auto camera_format = *aa::camera::get_supported_formats(camera1_device).begin(); aa::camera cam1(camera1_device, camera_format); aa::camera cam2(camera2_device, camera_format); auto texture1 = std::shared_ptr<aa::texture>(new aa::texture(aa::egl::get_instance()->create_texture(camera_format.width, camera_format.height))); auto texture2 = std::shared_ptr<aa::texture>(new aa::texture(aa::egl::get_instance()->create_texture(camera_format.width, camera_format.height))); aa::texture_window wnd1(texture1, "aa1", 0, 0, 400, 400); aa::texture_window wnd2(texture2, "aa2", 0, 0, 400, 400); aa::application::get_instance()->set_file_descriptor(wnd1); aa::application::get_instance()->set_file_descriptor(wnd2); aa::application::get_instance()->set_file_descriptor(cam1); aa::application::get_instance()->set_file_descriptor(cam2); cam1.connect_process_frame([&](const void *data, unsigned int size) { texture1->bind(); texture1->set(data); wnd1.expose(); }); cam2.connect_process_frame([&](const void *data, unsigned int size) { texture2->bind(); texture2->set(data); wnd2.expose(); }); wnd1.connect_delete_window([&]() { cam1.stop_capturing(); }); wnd2.connect_delete_window([&]() { cam2.stop_capturing(); }); cam1.start_capturing(); cam2.start_capturing(); aa::application::get_instance()->run(); }
int main(int argc, char** argv) { ifstream paramFile(argv[1]); if (not paramFile.is_open()) { cout << argv[1] << " : ERROR, file is not found" << endl; return 0; } array<double, 6> params1; array<double, 6> params2; cout << "First EU Camera model parameters :" << endl; for (auto & p: params1) { paramFile >> p; cout << setw(10) << p; } cout << endl; paramFile.ignore(); cout << "Second EU Camera model parameters :" << endl; for (auto & p: params2) { paramFile >> p; cout << setw(10) << p; } cout << endl; paramFile.ignore(); array<double, 6> cameraPose; cout << "Camera pose wrt the robot :" << endl; for (auto & e: cameraPose) { paramFile >> e; cout << setw(10) << e; } cout << endl; paramFile.ignore(); Transformation<double> TbaseCamera(cameraPose.data()); array<double, 6> robotPose1, robotPose2; cout << "First robot's pose :" << endl; for (auto & e: robotPose1) { paramFile >> e; cout << setw(10) << e; } cout << endl; cout << "Second robot's pose :" << endl; for (auto & e: robotPose2) { paramFile >> e; cout << setw(10) << e; } cout << endl; paramFile.ignore(); Transformation<double> T01(robotPose1.data()), T02(robotPose2.data()); Transformation<double> TleftRight = T01.compose(TbaseCamera).inverseCompose(T02.compose(TbaseCamera)); EnhancedCamera cam1(params1.data()), cam2(params2.data()); EnhancedEpipolar epipolar(&cam1, &cam2, TleftRight, 2000); string fileName1, fileName2; getline(paramFile, fileName1); //to SGM parameters const int LENGTH = 5; //TODO fix the constructor to avoid NULL EpipolarDescriptor epipolarDescriptor(LENGTH, 3, {1, 2, 3, 5, 7, 9}); StereoEpipoles epipoles(&cam1, &cam2, TleftRight); while(getline(paramFile, fileName1)) { getline(paramFile, fileName2); img1 = imread(fileName1, 0); img2 = imread(fileName2, 0); Mat8u descStepMat(img1.size()); for (int v = 0; v < img1.rows; v++) { for (int u = 0; u < img1.cols; u++) { Vector3d X; cam1.reconstructPoint(Vector2d(u, v), X); CurveRasterizer<int, Polynomial2> raster(Vector2i(u, v), epipoles.getFirstPx(), epipolar.getFirst(X)); if (epipoles.firstIsInverted()) raster.setStep(-1); vector<uint8_t> descriptor; const int step = epipolarDescriptor.compute(img1, raster, descriptor); if (step > 0) descStepMat(v, u) = (10 - step) * 25; else descStepMat(v, u) = 0; } } imshow("out1", img1); imshow("out2", img2); imshow("descStep", descStepMat); waitKey(); } return 0; }
void assigment4_1_and_2() { Image img(800, 600); img.addRef(); //Set up the scene GeometryGroup scene; LWObject cow; cow.read("models/cow.obj", true); cow.addReferencesToScene(scene.primitives); scene.rebuildIndex(); BumpMirrorPhongShader sh4; sh4.diffuseCoef = float4(0.2f, 0.2f, 0, 0); sh4.ambientCoef = sh4.diffuseCoef; sh4.specularCoef = float4::rep(0.8f); sh4.specularExponent = 10000.f; sh4.reflCoef = 0.4f; sh4.addRef(); cow.materials[cow.materialMap["Floor"]].shader = &sh4; //Enable bi-linear filtering on the walls ((TexturedPhongShader*)cow.materials[cow.materialMap["Stones"]].shader.data())->diffTexture->filterMode = Texture::TFM_Bilinear; ((TexturedPhongShader*)cow.materials[cow.materialMap["Stones"]].shader.data())->amibientTexture->filterMode = Texture::TFM_Bilinear; //Set up the cameras PerspectiveCamera cam1(Point(-9.398149f, -6.266083f, 5.348377f), Point(-6.324413f, -2.961229f, 4.203216f), Vector(0, 0, 1), 30, std::make_pair(img.width(), img.height())); PerspectiveCamera cam2(Point(2.699700f, 6.437226f, 0.878297f), Point(4.337114f, 8.457443f,- 0.019007f), Vector(0, 0, 1), 30, std::make_pair(img.width(), img.height())); cam1.addRef(); cam2.addRef(); //Set up the integrator IntegratorImpl integrator; integrator.addRef(); integrator.scene = &scene; PointLightSource pls; pls.falloff = float4(0, 0, 1, 0); pls.intensity = float4::rep(0.9f); pls.position = Point(-2.473637f, 3.119330f, 9.571486f); integrator.lightSources.push_back(pls); integrator.ambientLight = float4::rep(0.1f); DefaultSampler samp; samp.addRef(); //Render Renderer r; r.integrator = &integrator; r.target = &img; r.sampler = &samp; r.camera = &cam1; r.render(); img.writePNG("result_cam1.png"); //For seeing the difference in texture filtering r.camera = &cam2; r.render(); img.writePNG("result_cam2.png"); }
void setup_and_render() { Image img(WIDTH, HEIGHT); img.addRef(); //Set up the scene GeometryGroup scene; // load scene LWObject objects; objects.read("models/cube.obj", true); objects.addReferencesToScene(scene.primitives); scene.rebuildIndex(); //apply custom shaders BumpTexturePhongShader as; as.addRef(); Image grass; grass.addRef(); grass.readPNG("models/mat.png"); Texture textureGrass; textureGrass.addRef(); textureGrass.image = &grass; as.diffTexture = &textureGrass; as.amibientTexture = &textureGrass; as.specularCoef = float4::rep(0); as.specularExponent = 10000.f; as.transparency = float4::rep(0.9); FractalLandscape f(Point(-4419,-8000,-569), Point(3581,0, -569),9, 0.1, &as, 5.0f); f.addReferencesToScene(scene.primitives); scene.rebuildIndex(); // my phong RRPhongShader glass; glass.n1 = 1.0f; glass.n2 = 1.5f; glass.diffuseCoef = float4(0.1, 0.1, 0.1, 0); glass.ambientCoef = glass.diffuseCoef; glass.specularCoef = float4::rep(0.9); glass.specularExponent = 10000; glass.transparency = float4::rep(0.9); glass.addRef(); Sphere sphere(Point(-78,1318,40), 25, &glass);; scene.primitives.push_back(&sphere); scene.rebuildIndex(); objects.materials[objects.materialMap["Glass"]].shader = &glass; //sample shader for noise ProceduralPhongShader skyShader; skyShader.addRef(); CloudTexture nt; nt.addRef(); skyShader.amibientNoiseTexture = &nt; skyShader.diffuseCoef = float4::rep(0.0f); skyShader.specularCoef = float4::rep(0.0f); // float w = skyShader.amibientNoiseTexture->perlin->width; objects.materials[objects.materialMap["Sky"]].shader = &skyShader; //Set up the cameras PerspectiveCamera cam1(Point(-23, 1483, 30 ), forwardForCamera((0.0)*PI/180.0), Vector(0, 0, 1), 45, std::make_pair(img.width(), img.height())); cam1.addRef(); //Set up the integrator IntegratorImpl integrator; integrator.addRef(); integrator.scene = &scene; PointLightSource pls3; pls3.falloff = float4(0, 0, 1, 0); pls3.intensity = float4::rep(0.9f); pls3.position = Point(299.5, 99, 518); integrator.lightSources.push_back(pls3); // PointLightSource pls4; // // pls4.falloff = float4(0, 0, 1, 0); // // pls4.intensity = float4::rep(0.9f); // pls4.position = Point(1289.5, 99, 518); // integrator.lightSources.push_back(pls4); areaLightSource(integrator, 0.9, 2, Point(-1180, -3860, -1718), 1000); integrator.ambientLight = float4::rep(0.1f); StratifiedSampler samp; samp.addRef(); samp.samplesX = 3; samp.samplesY = 3; //Render Renderer r; r.integrator = &integrator; r.target = &img; r.sampler = &samp; r.camera = &cam1; r.render(); img.writePNG("result.png"); }
void TutorialLevel::setup(){ INFO("Generating Tutorial Level..."); readFile(); initalizeGrid(); createRenders(); createLevel(); waterSurfaceManager = WaterSurfaceManagerPtr(new WaterSurfaceManager()); addGameObject(waterSurfaceManager); INFO("Removal String so less of make"); INFO("Setting up the cameras for the Test Level..."); CameraPtr cam3(new Camera(glm::vec3(25, 30, 0), glm::vec3(10, 20, 6), glm::vec3(0, 1, 0))); cam3->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); addCamera("CinematicCamera", cam3); setMainCamera("CinematicCamera"); setCullingCamera("CinematicCamera"); CameraPtr cam1(new Camera(glm::vec3(4, 10, -5), glm::vec3(4, 4, -10), glm::vec3(0, 1, 0))); cam1->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); addCamera("Camera1", cam1); CameraPtr cam2(new Camera(glm::vec3(0, 1, 0), glm::vec3(-6, -3, 6), glm::vec3(0, 1, 0))); cam2->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); l1 = LightPtr(new Light(glm::vec3(1), 30.0f, glm::vec3(0, 30, 0))); l1->setPosition(l1->getDirection()); Uniform3DGridPtr<int> typeGrid = getTypeGrid(); gridCenter = glm::vec3((typeGrid->getMaxX() - typeGrid->getMinX())/2.0f, (typeGrid->getMaxY() - typeGrid->getMinY())/2.0f, (typeGrid->getMinZ() - typeGrid->getMaxZ())/2.0f); l1->setViewMatrix(glm::lookAt( l1->getPosition(), gridCenter, glm::vec3(0, 1, 0))); l1->setProjectionMatrix(glm::ortho<float>(-30,30,-30,30,-70,70)); addLight("Sun", l1); INFO("Setting up the player for the Test Level..."); cinematicPlayer = CinematicPlayerPtr(new CinematicPlayer(cam3)); cinematicPlayer->setup(); addGameObject("cinematicPlayer", cinematicPlayer); player = PlayerPtr(new Player(cam1, 2)); player->setup(); addGameObject("player" , player); CollisionManager::addCollisionObjectToList(player); debugPlayer = DebugPlayerPtr(new DebugPlayer(cam2)); debugPlayer->setup(); addGameObject("debugPlayer" , debugPlayer); //Text addCamera("DebugCamera", cam2); sky = ObjectPtr(new Object( LoadManager::getMesh("sphere.obj"), MaterialManager::getMaterial("None"))); sky->applyTexture(LoadManager::getTexture("Sky")); sky->enableTexture(); sky->scale(glm::vec3(-90.0f,-90.0f,-90.0f)); sky->translate(Director::getScene()->getCamera()->getEye()); RenderEngine::getRenderElement("textured")->addObject(sky); ExclamationPtr exclamation = ExclamationPtr(new Exclamation(glm::vec3(30, 26, -48))); exclamation->setup(); addGameObject("exclamation", exclamation); }
void TunnelLevel::setup(){ INFO("Generating Test Level..."); readFile(); initalizeGrid(); createRenders(); createLevel(); INFO("Removal String so less of make"); waterSurfaceManager = WaterSurfaceManagerPtr(new WaterSurfaceManager()); addGameObject(waterSurfaceManager); CameraPtr cam3(new Camera(glm::vec3(30, 45, 0), glm::vec3(30, 15, 6), glm::vec3(0, 1, 0))); cam3->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); addCamera("CinematicCamera", cam3); setMainCamera("CinematicCamera"); setCullingCamera("CinematicCamera"); INFO("Setting up the cameras for the Test Level..."); CameraPtr cam1(new Camera(glm::vec3(32.0f, 12.0f, -24.0f), glm::vec3(4, 4, -10), glm::vec3(0, 1, 0))); cam1->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); addCamera("Camera1", cam1); setMainCamera("Camera1"); setCullingCamera("Camera1"); CameraPtr cam2(new Camera(glm::vec3(0, 1, 0), glm::vec3(-6, -3, 6), glm::vec3(0, 1, 0))); cam2->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); l1 = LightPtr(new Light(glm::vec3(1), 30.0f, glm::vec3(32, 30, -20))); l1->setPosition(l1->getDirection()); Uniform3DGridPtr<int> typeGrid = getTypeGrid(); gridCenter = glm::vec3((typeGrid->getMaxX() - typeGrid->getMinX())/2.0f, (typeGrid->getMaxY() - typeGrid->getMinY())/2.0f, (typeGrid->getMinZ() - typeGrid->getMaxZ())/2.0f); l1->setViewMatrix(glm::lookAt( l1->getPosition(), gridCenter, glm::vec3(0, 1, 0))); l1->setProjectionMatrix(glm::ortho<float>(-30,30,-30,30,-70,70)); addLight("Sun", l1); cinematicPlayer = CinematicPlayerPtr(new CinematicPlayer(cam3)); cinematicPlayer->setup(); addGameObject("cinematicPlayer", cinematicPlayer); INFO("Setting up the player for the Test Level..."); player = PlayerPtr(new Player(cam1, 2)); player->setup(); addGameObject("player" , player); CollisionManager::addCollisionObjectToList(player); debugPlayer = DebugPlayerPtr(new DebugPlayer(cam2)); debugPlayer->setup(); addGameObject("debugPlayer" , debugPlayer); addCamera("DebugCamera", cam2); INFO("Creating Switch for the Test Level..."); SwitchPtr s1(new Switch(glm::vec3(0.9f, 0.1f, 0.1f), glm::vec3(33.7f, 11.0f, -27.0f), glm::vec3(0,0,1), -20.0f, 1)); s1->setup(); addGameObject("s1", s1); CollisionManager::addCollisionObjectToGrid(s1); std::list<SolidCubePtr> solidCubes; // INFO("Creating Active Terrain for the Test Level..."); for(int i = 11; i < 36; i+=2) { for(int j = -27; j < -20; j+=2) { SolidCubePtr at1(new SolidCube(glm::vec3(29, i, j))); at1->setup(); RenderEngine::getRenderGrid()->removeObject(at1->getObject()); solidCubes.push_back(at1); } } ActiveTerrainPtr a1(new ActiveTerrain(s1, glm::vec3(), glm::vec3(), 50.0f)); a1->setup(); a1->setCubes(solidCubes); addGameObject("a1", a1); sky = ObjectPtr(new Object( LoadManager::getMesh("sphere.obj"), MaterialManager::getMaterial("None"))); sky->applyTexture(LoadManager::getTexture("Sky")); sky->enableTexture(); sky->scale(glm::vec3(-50.0f,-50.0f,-50.0f)); sky->translate(Director::getScene()->getCamera()->getEye()); RenderEngine::getRenderElement("textured")->addObject(sky); ExclamationPtr exclamation = ExclamationPtr(new Exclamation(glm::vec3(60, 5, -23))); exclamation->setup(); addGameObject("exclamation", exclamation); PTR_CAST(SolidCube, (*grid)(7, 20, 11))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(7, 20, 12))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(7, 20, 11))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); PTR_CAST(SolidCube, (*grid)(7, 20, 12))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); shearRegion(8, 10, 21, 21, 11, 12, 1, 0, 0.0f); shearRegion(11, 13, 20, 20, 11, 12, 1, 0, 0.5f); PTR_CAST(SolidCube, (*grid)(16, 12, 0))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(17, 12, 0))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(16, 12, 0))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); PTR_CAST(SolidCube, (*grid)(17, 12, 0))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); shearRegion(16, 17, 13, 13, 1, 4, 0, 1, 0.0f); shearRegion(16, 17, 12, 12, 5, 8, 0, 1, 0.5f); PTR_CAST(SolidCube, (*grid)(16, 12, 23))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(17, 12, 23))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(16, 12, 23))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); PTR_CAST(SolidCube, (*grid)(17, 12, 23))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); shearRegion(16, 17, 13, 13, 19, 22, 0, -1, 0.0f); shearRegion(16, 17, 12, 12, 15, 18, 0, -1, 0.5f); PTR_CAST(SolidCube, (*grid)(26, 12, 15))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(26, 12, 8))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(26, 12, 15))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); PTR_CAST(SolidCube, (*grid)(26, 12, 8))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); }
void doit() { //Image img(600, 400); Image img(1280, 960); img.addRef(); //Set up the scene GeometryGroup scene(ACC_STRUCT); LWObject cow; //cow.read("models/cow.obj", true); cow.read("models/untitled.obj", true); //cow.read("models/house_obj.obj", true); //cow.read("models/3spheretest.obj", true); //cow.read("models/TheDragon.obj", true); cow.addReferencesToScene(scene.primitives); /* ((TexturedPhongShader*)cow.materials[cow.materialMap["Material.001"]].shader.data())->diffTexture->filterMode = Texture::TFM_Bilinear; ((TexturedPhongShader*)cow.materials[cow.materialMap["Material.001"]].shader.data())->ambientTexture->filterMode = Texture::TFM_Bilinear; ((TexturedBumpPhongShader*)cow.materials[cow.materialMap["Material.001"]].shader.data())->bumpTexture->filterMode = Texture::TFM_Bilinear; */ /* SmartPtr<Image> imag; imag->readPNG("models/tiles.png"); SmartPtr<Texture> tiles; tiles->image = imag; ((TexturedBumpPhongShader*)cow.materials[cow.materialMap["Material.001"]].shader.data())->diffTexture = tiles; */ MirrorPhongShader sh77; sh77.diffuseCoef = float4(220.f/255, 193.f/255, 42.f/255, 0); sh77.ambientCoef = sh77.diffuseCoef; sh77.specularCoef = float4::rep(0.0f); sh77.specularExponent = 10000.f; sh77.reflCoef = 0.6f; sh77.addRef(); CheckBoard3DShader check; check.scale = float4::rep(1); check.addRef(); float4 woodenBrownDark = float4(103.f/255,53.f/255,3.f/255,0); float4 woodenBrownLight = float4(167.f/255,86.f/255,7.f/255,0); float4 kBraun = float4(181.f/255,58.f/255,4.f/255,0); float4 dBraun = float4(119.f/255,15.f/255,0.f/255,0); float4 marmorDunkel = float4(0.6,0.6,0.6,0); float4 marmorHell = float4(0.4,0.4,0.4,0); SmartPtr<ProceduralTexture> woodTex = new ProceduralWoodTexture(woodenBrownDark, woodenBrownLight, 0.1f, 0.8f); SmartPtr<ProceduralTexture> marbleTex = new ProceduralMarbleTexture(kBraun,dBraun, 0.8f, 0.8f); SmartPtr<ProceduralTexture> planetTex = new ProceduralPlanetTexture(); SmartPtr<ProceduralTexture> waterTex = new ProceduralWaterTexture(0.5f, 0.9f); SmartPtr<ProceduralTexture> floorMarbleTex = new ProceduralMarbleTexture(marmorHell,marmorDunkel, 0.4f, 0.3f); RefractivePhongShader shader; shader.refractionIndex = 1.6f; shader.diffuseCoef = float4(0.2f, 0.2f, 0, 0); shader.ambientCoef = shader.diffuseCoef; shader.specularCoef = float4::rep(0.8f); shader.specularExponent = 10000.f; shader.transparency = float4::rep(0.7f); shader.addRef(); cow.materials[cow.materialMap["glass"]].shader = &shader; RefractivePhongShader diamondShader; diamondShader.refractionIndex = 2.6f; diamondShader.diffuseCoef = float4(0.2f, 0.2f, 0, 0); diamondShader.ambientCoef = diamondShader.diffuseCoef; diamondShader.specularCoef = float4::rep(0.8f); diamondShader.specularExponent = 10000.f; diamondShader.transparency = float4::rep(0.7f); diamondShader.addRef(); cow.materials[cow.materialMap["diamant"]].shader = &diamondShader; ProceduralBumpShader procBumpShader(marbleTex); procBumpShader.diffuseCoef = float4(110.f/255,54.f/255,9.f/255,0.f); procBumpShader.ambientCoef = procBumpShader.diffuseCoef; procBumpShader.specularCoef = float4::rep(0.3f); procBumpShader.specularExponent = 10000.f; ProceduralBumpShader floor(floorMarbleTex); floor.diffuseCoef = float4(0.5,0.5,0.5,0); floor.ambientCoef = floor.diffuseCoef; floor.specularCoef = float4::rep(0.3f); floor.specularExponent = 10000.f; ProceduralBumpShader planet(planetTex); planet.diffuseCoef = float4(110.f/255,54.f/255,9.f/255,0.f); planet.ambientCoef = planet.diffuseCoef; planet.specularCoef = float4::rep(0.3f); planet.specularExponent = 10000.f; ProceduralBumpShader procBumpShader2(woodTex); procBumpShader2.diffuseCoef = float4(110.f/255,54.f/255,9.f/255,0.f); procBumpShader2.ambientCoef = procBumpShader2.diffuseCoef; procBumpShader2.specularCoef = float4::rep(0.3f); procBumpShader2.specularExponent = 10000.f; ProceduralRefractiveBumpShader water(waterTex); water.refractionIndex = 1.4f; water.diffuseCoef = float4(0.6,0.6,0.8,0.f); water.ambientCoef = water.diffuseCoef; water.specularCoef = float4::rep(0.3f); water.transparency = float4::rep(0.7f); water.specularExponent = 10000.f; water.addRef(); cow.materials[cow.materialMap["water"]].shader = &water; cow.materials[cow.materialMap["dragonskin"]].shader = &procBumpShader; cow.materials[cow.materialMap["podest"]].shader = &procBumpShader2; cow.materials[cow.materialMap["Material.001_stones_diffuse.png"]].shader = &floor; DefaultPhongShader defaultPhong; defaultPhong.diffuseCoef = float4(0.3f,0.3f,0.3f, 0); defaultPhong.ambientCoef = defaultPhong.diffuseCoef; defaultPhong.specularCoef = float4::rep(0.0f); defaultPhong.specularExponent = 10000.f; defaultPhong.addRef(); //cow.materials[cow.materialMap["Gold"]].shader = &sh77; //cow.materials[cow.materialMap["glass"]].shader = &procBumpShader; InfinitePlane p2(Point(-5.f, 0.f, 0.f), Vector(1, 0, 0), &defaultPhong); InfinitePlane p1(Point(0, -2.f, 0), Vector(0, 1, 0), &defaultPhong); //scene.primitives.push_back(&p1); //scene.primitives.push_back(&p2); // sphere test purpose Sphere s2(Point(0.1, 2.0f, 11), 2.0f, &planet); Sphere s3(Point(6.1, 1.0f, 10), 1.0f, &shader); Sphere s4(Point(1.1, 1.5f, 14.5f), 1.5f, &shader); scene.primitives.push_back(&s2); scene.primitives.push_back(&s3); scene.primitives.push_back(&s4); //InfinitePlane plane(Point(0,0.f,0),Vector(0,1,0), &check); PerspectiveCamera cam1(Point(-10.398149f, -7.266083f, 6.348377f), Point(-6.324413f, -2.961229f, 4.203216f), Vector(0, 0, 1), 30, std::make_pair(img.width(), img.height())); //cam1.addRef(); //PerspectiveLensCamera cam3(Point(-10.398149f, -7.266083f, 6.348377f), Point(-6.324413f, -2.961229f, 4.203216f), Vector(0, 0, 1), 30, // std::make_pair(img.width(), img.height()),0.9f,0.0f,1.f,4,false); PerspectiveLensCamera cam4(Point(30.f, 6.f, 0), Point(4,2.f,0), Vector(0, 1, 0), 50, std::make_pair(img.width(), img.height()),0.9f,0.3f,1.f,16,true); //PerspectiveLensCamera cam1(Point(30.f, 0.f, 0.f), Point(0, 0, 0), Vector(0, 1, 0), 60, // std::make_pair(img.width(), img.height()),0.9f,0.0f,1.f,4,true); //cam1.addRef(); PerspectiveCamera cam2(Point(6.f, 1.f, 0.f), Point(0, -1, 0), Vector(0, 1, 0), 60, std::make_pair(img.width(), img.height())); //cam2.addRef(); // index scene scene.rebuildIndex(); //Set up the integrator PhotonMap_Integrator integrator; //IntegratorImpl integrator; integrator.addRef(); integrator.scene = &scene; PointLightSource pls; pls.falloff = float4(0, 0, 1, 0); pls.intensity = float4::rep(0.6f); pls.position = Point(7.f, 3.f, 0.f); integrator.lightSources.push_back(pls); PointLightSource pls2; pls2.falloff = float4(0, 0, 1, 0); pls2.intensity = float4::rep(0.7f); pls2.position = Point(30.f, 6.f, 0.f); integrator.lightSources.push_back(pls2); PointLightSource pls3; pls3.falloff = float4(0, 0, 1, 0); pls3.intensity = float4(0.3f,0.1f,0.1f,0); pls3.position = Point(7.f, 3.f, -8.f); integrator.lightSources.push_back(pls3); integrator.ambientLight = float4::rep(0.1f); integrator.start_photonmapping(); DefaultSampler samp; samp.addRef(); HaltonSampleGenerator halton; halton.sampleCount = 4; //Render Renderer r; r.integrator = &integrator; r.target = &img; r.sampler = &halton; r.camera = &cam4; r.render(32,23); img.writePNG("frey_leonhardt_rc.png"); }