void TestScene::setup() { logger.normalf("Creating image tracer %d x %d, %d frames, %d rays per pixel", image_width, image_height, anim_frames, rays_per_pixel); logger.normalf("Output directory: %s", output_dir.c_str()); tracer = new ImageTracer( image_width, image_height, anim_frames, rays_per_pixel ); #if 0 // Create a subdirectory in the output directory named with the test name, and put standard // output files in there tracer->artifacts.output_path = output_dir + "/" + name; mkdir(tracer->artifacts.output_path.c_str(), 0777); tracer->artifacts.file_prefix = ""; #else // Prefix each output file with the test name and put them in the output directory tracer->artifacts.output_path = output_dir; tracer->artifacts.file_prefix = name + "_"; #endif tracer->shader = new BasicDiffuseSpecularShader(); tracer->setCameraTransform( compose( // move up a bit makeTranslation( 0.0, 0.5, 0.0 ), // rotate so we are looking down makeRotation( -0.2, Vector4(1, 0, 0) ), // back away from the origin makeTranslation( 0.0, 0.0, 10.0 ) ) ); }
void addBunny( std::shared_ptr<Container> container ) { AssetLoader loader; std::string modelPath = "models"; // bunnies std::string bunnyPath = modelPath + "/stanford/bunny/reconstruction"; auto mesh = loader.load( bunnyPath + "/bun_zipper_res2.ply" ); //auto mesh = loader.load( bunnyPath + "/bun_zipper_res4.ply" ); if( !mesh ) { fprintf( stderr, "Error loading mesh\n" ); return; } //mesh->material = std::make_shared<DiffuseMaterial>( 0.0f, 0.66, 0.42f ); // emerald green mesh->material = std::make_shared<MirrorMaterial>(); printf("Building octree\n"); auto mesh_octree = new TMOctreeAccelerator( *std::dynamic_pointer_cast<TriangleMesh>(mesh) ); mesh_octree->build(); mesh->accelerator = mesh_octree; mesh->transform = std::make_shared<Transform>(); *mesh->transform = makeTranslation( Vector4( 0.0, 0.2, -0.5 ) ); container->add( mesh ); }
void addTransformedCubes( std::shared_ptr<Container> container ) { // Offset cubes for testing AO float cube_size = 0.2; auto cube1 = std::make_shared<AxisAlignedSlab>( 0.0, 0.0, 0.0, cube_size ); auto cube2 = std::make_shared<AxisAlignedSlab>( 0.0, 0.0, 0.0, cube_size ); auto cube3 = std::make_shared<AxisAlignedSlab>( 0.0, 0.0, 0.0, cube_size ); cube1->material = std::make_shared<DiffuseMaterial>( 1.0, 0.0, 0.0 ); cube2->material = std::make_shared<DiffuseMaterial>( 0.0, 0.0, 1.0 ); cube3->material = std::make_shared<DiffuseMaterial>( 0.0, 1.0, 0.0 ); cube1->transform = std::make_shared<Transform>(); *cube1->transform = makeTranslation( Vector4( 0.1, 0.5, -1.0 ) ); cube2->transform = std::make_shared<Transform>(); *cube2->transform = compose( makeTranslation( Vector4( 0.0, 0.15, -1.0 ) ), compose( makeRotation( M_PI / 4.0, Vector4( 0.0, 1.0, 0.0 ) ), makeRotation( M_PI / 4.0, Vector4( 0.0, 0.0, 1.0 ) ) ) ); cube3->transform = std::make_shared<Transform>(); *cube3->transform = compose( makeTranslation( Vector4( -0.3, 0.0, -1.0 ) ), makeScaling( 0.2, 3.0, 2.0 ) ); container->add( cube1 ); container->add( cube2 ); container->add( cube3 ); addSphereLight( container, Vector4( 3.0, 3.0, -1.0 ), 0.5, RGBColor( 1.0, 1.0, 1.0 ), 200.0 ); addGroundPlane( container ); }
void TestScene::setup() { tracer = new ImageTracer( image_width, image_height, anim_frames, rays_per_pixel ); tracer->artifacts.output_path = output_dir; tracer->artifacts.file_prefix = name + "_"; tracer->shader = new BasicDiffuseSpecularShader(); tracer->setCameraTransform( compose( // move up a bit makeTranslation( 0.0, 0.5, 0.0 ), // rotate so we are looking down makeRotation( -0.2, Vector4(1, 0, 0) ), // back away from the origin makeTranslation( 0.0, 0.0, 10.0 ) ) ); }