[FEAT] Chapter 07 is done.

This commit is contained in:
NADAL Jean-Baptiste
2024-02-26 16:55:38 +01:00
parent 2681833d1d
commit d109170ec1
11 changed files with 254 additions and 6 deletions

View File

@@ -635,3 +635,41 @@ SCENARIO("Constructing a ray when the camera is transformed", "[features/camera.
}
}
}
/* ------------------------------------------------------------------------- */
SCENARIO("Rendering a world with the camera", "[features/camera.feature]")
{
GIVEN("w <- default_world()")
{
World w = World::default_world();
AND_GIVEN("c <- camera(11, 11, pi/2)")
{
Camera c(11, 11, std::numbers::pi / 2);
AND_GIVEN("from <- point(0, 0, -5)")
{
Tuple from = Tuple::Point(0, 0, -5);
AND_GIVEN("to <- point(0, 0, 0)")
{
Tuple to = Tuple::Point(0, 0, 0);
AND_GIVEN("up <- vector(0, 1, 0)")
{
Tuple up = Tuple::Vector(0, 1, 0);
AND_GIVEN("c.transform <- view_transform(from, to, up)")
{
c.set_transform(Matrix::view_transform(from, to, up));
WHEN("image <- c.render(w)")
{
Canvas image = c.render(w);
THEN("pixel_at(image, 5, 5) = color(0.38066, 0.47583, 0.2855)")
{
REQUIRE(image.pixel_at(5, 5) == Color(0.38066, 0.47583, 0.2855));
}
}
}
}
}
}
}
}
}