[FEAT] Add skeleton for final image of chap13

This commit is contained in:
NADAL Jean-Baptiste
2024-03-19 10:32:03 +01:00
parent cff3d78450
commit d34ad6a60b
3 changed files with 158 additions and 3 deletions

View File

@@ -47,7 +47,9 @@ int main(void)
Camera the_camera;
Canvas the_canvas;
Plane *the_floor;
Cylinder *the_cylinder;
Cylinder *the_cylinder, *the_glass_cylinder;
Cylinder *the_concentric_cylinder1, *the_concentric_cylinder2, *the_concentric_cylinder3, *the_concentric_cylinder4;
Cylinder *the_decorative_cylinder1, *the_decorative_cylinder2, *the_decorative_cylinder3, *the_decorative_cylinder4;
chrono::time_point<chrono::high_resolution_clock> the_start, the_end;
printf("Chapter 13 example.\n");
@@ -77,6 +79,134 @@ int main(void)
the_cylinder_material.set_reflective(0.9);
the_world.add_object(the_cylinder);
// Concentric Cylinder 1
the_concentric_cylinder1 = new Cylinder();
the_concentric_cylinder1->set_minimum(0);
the_concentric_cylinder1->set_maximum(0.2);
the_concentric_cylinder1->set_transform(Matrix::translation(1, 0, 0) *
Matrix::scaling(0.8, 1, 0.8));
Material &the_concentric_cylinder1_material = the_concentric_cylinder1->material();
the_concentric_cylinder1_material.set_color(Color(1, 1, 0.3));
the_concentric_cylinder1_material.set_ambient(0.1);
the_concentric_cylinder1_material.set_diffuse(0.8);
the_concentric_cylinder1_material.set_specular(0.9);
the_concentric_cylinder1_material.set_shininess(300);
the_world.add_object(the_concentric_cylinder1);
// Concentric Cylinder 2
the_concentric_cylinder2 = new Cylinder();
the_concentric_cylinder2->set_minimum(0);
the_concentric_cylinder2->set_maximum(0.3);
the_concentric_cylinder2->set_transform(Matrix::translation(1, 0, 0) *
Matrix::scaling(0.6, 1, 0.6));
Material &the_concentric_cylinder2_material = the_concentric_cylinder2->material();
the_concentric_cylinder2_material.set_color(Color(1, 0.9, 0.4));
the_concentric_cylinder2_material.set_ambient(0.1);
the_concentric_cylinder2_material.set_diffuse(0.8);
the_concentric_cylinder2_material.set_specular(0.9);
the_concentric_cylinder2_material.set_shininess(300);
the_world.add_object(the_concentric_cylinder2);
// Concentric Cylinder 3
the_concentric_cylinder3 = new Cylinder();
the_concentric_cylinder3->set_minimum(0);
the_concentric_cylinder3->set_maximum(0.4);
the_concentric_cylinder3->set_transform(Matrix::translation(1, 0, 0) *
Matrix::scaling(0.4, 1, 0.4));
Material &the_concentric_cylinder3_material = the_concentric_cylinder3->material();
the_concentric_cylinder3_material.set_color(Color(1, 0.8, 0.5));
the_concentric_cylinder3_material.set_ambient(0.1);
the_concentric_cylinder3_material.set_diffuse(0.8);
the_concentric_cylinder3_material.set_specular(0.9);
the_concentric_cylinder3_material.set_shininess(300);
the_world.add_object(the_concentric_cylinder3);
// Concentric Cylinder 4
the_concentric_cylinder4 = new Cylinder();
the_concentric_cylinder4->set_minimum(0);
the_concentric_cylinder4->set_maximum(0.5);
the_concentric_cylinder4->set_transform(Matrix::translation(1, 0, 0) *
Matrix::scaling(0.2, 1, 0.2));
Material &the_concentric_cylinder4_material = the_concentric_cylinder4->material();
the_concentric_cylinder4_material.set_color(Color(1, 0.7, 0.6));
the_concentric_cylinder4_material.set_ambient(0.1);
the_concentric_cylinder4_material.set_diffuse(0.8);
the_concentric_cylinder4_material.set_specular(0.9);
the_concentric_cylinder4_material.set_shininess(300);
the_world.add_object(the_concentric_cylinder4);
// Decorative Cylinder 1
the_decorative_cylinder1 = new Cylinder();
the_decorative_cylinder1->set_minimum(0);
the_decorative_cylinder1->set_maximum(0.3);
the_decorative_cylinder1->set_transform(Matrix::translation(0, 0, -0.75) *
Matrix::scaling(0.05, 1, 0.05));
Material &the_decorative_cylinder1_material = the_decorative_cylinder1->material();
the_decorative_cylinder1_material.set_color(Color::Red());
the_decorative_cylinder1_material.set_ambient(0.1);
the_decorative_cylinder1_material.set_diffuse(0.9);
the_decorative_cylinder1_material.set_specular(0.9);
the_decorative_cylinder1_material.set_shininess(300);
the_world.add_object(the_decorative_cylinder1);
// Decorative Cylinder 2
the_decorative_cylinder2 = new Cylinder();
the_decorative_cylinder2->set_minimum(0);
the_decorative_cylinder2->set_maximum(0.3);
the_decorative_cylinder2->set_transform(Matrix::translation(0, 0, -2.25) * Matrix::rotation_y(-0.15) *
Matrix::translation(0, 0, 1.5) * Matrix::scaling(0.05, 1, 0.05));
Material &the_decorative_cylinder2_material = the_decorative_cylinder2->material();
the_decorative_cylinder2_material.set_color(Color::Yellow());
the_decorative_cylinder2_material.set_ambient(0.1);
the_decorative_cylinder2_material.set_diffuse(0.9);
the_decorative_cylinder2_material.set_specular(0.9);
the_decorative_cylinder2_material.set_shininess(300);
the_world.add_object(the_decorative_cylinder2);
// Decorative Cylinder 3
the_decorative_cylinder3 = new Cylinder();
the_decorative_cylinder3->set_minimum(0);
the_decorative_cylinder3->set_maximum(0.3);
the_decorative_cylinder3->set_transform(Matrix::translation(0, 0, -2.25) * Matrix::rotation_y(-0.3) *
Matrix::translation(0, 0, 1.5) * Matrix::scaling(0.05, 1, 0.05));
Material &the_decorative_cylinder3_material = the_decorative_cylinder3->material();
the_decorative_cylinder3_material.set_color(Color::Green());
the_decorative_cylinder3_material.set_ambient(0.1);
the_decorative_cylinder3_material.set_diffuse(0.9);
the_decorative_cylinder3_material.set_specular(0.9);
the_decorative_cylinder3_material.set_shininess(300);
the_world.add_object(the_decorative_cylinder3);
// Decorative Cylinder 4
the_decorative_cylinder4 = new Cylinder();
the_decorative_cylinder4->set_minimum(0);
the_decorative_cylinder4->set_maximum(0.3);
the_decorative_cylinder4->set_transform(Matrix::translation(0, 0, -2.25) * Matrix::rotation_y(-0.45) *
Matrix::translation(0, 0, 1.5) * Matrix::scaling(0.05, 1, 0.05));
Material &the_decorative_cylinder4_material = the_decorative_cylinder4->material();
the_decorative_cylinder4_material.set_color(Color::Cyan());
the_decorative_cylinder4_material.set_ambient(0.1);
the_decorative_cylinder4_material.set_diffuse(0.9);
the_decorative_cylinder4_material.set_specular(0.9);
the_decorative_cylinder4_material.set_shininess(300);
the_world.add_object(the_decorative_cylinder4);
// Glass Cylinder
the_glass_cylinder = new Cylinder();
the_glass_cylinder->set_minimum(0.0001);
the_glass_cylinder->set_maximum(0.5);
the_glass_cylinder->set_transform(Matrix::translation(0, 0, -1.5) *
Matrix::scaling(0.33, 1, 0.33));
Material &the_glass_cylinder_material = the_glass_cylinder->material();
the_glass_cylinder_material.set_color(Color(0.25, 0, 0));
the_glass_cylinder_material.set_ambient(0.1);
the_glass_cylinder_material.set_specular(0.9);
the_glass_cylinder_material.set_shininess(300);
the_glass_cylinder_material.set_reflective(0.9);
the_glass_cylinder_material.set_transparency(0.9);
the_glass_cylinder_material.set_refractive_index(1.5);
the_world.add_object(the_glass_cylinder);
// The Light source is white, shining from above and to the left
the_world.set_light(PointLight(Tuple::Point(1, 6.9, -4.9), Color(1, 1, 1)));