[FEAT] Add strip pattern to material

This commit is contained in:
NADAL Jean-Baptiste
2024-02-29 13:56:39 +01:00
parent a8cf2d984f
commit 5e540a995b
7 changed files with 210 additions and 5 deletions

View File

@@ -123,3 +123,55 @@ SCENARIO("A stripe pattern alternates in x", "[features/patterns.feature]")
}
}
}
/* ------------------------------------------------------------------------- */
SCENARIO("Lightning with a pattern applied", "[features/materials.feature]")
{
Material m;
GIVEN("m.pattern <- strip_pattern(color(1, 1, 1), color(0, 0, 0))")
{
m.set_pattern(new StripePattern(Color(1, 1, 1), Color(0, 0, 0)));
AND_GIVEN("m.ambient <- 1")
{
m.set_ambient(1);
AND_GIVEN("m.diffuse <- 0")
{
m.set_diffuse(0);
AND_GIVEN("m.specular <- 0")
{
m.set_specular(0);
AND_GIVEN("eyev <- vector(0, 0, -1)")
{
Tuple eyev = Tuple::Vector(0, 0, -1);
AND_GIVEN("normalv <- vector(0, 0, -1)")
{
Tuple normalv = Tuple::Vector(0, 0, -1);
AND_GIVEN("light <- point_light(point(0, 0, -10), color(1, 1, 1))")
{
PointLight light = PointLight(Tuple::Point(0, 0, -10), Color(1, 1, 1));
WHEN("c1 <- lighting(m, light, point(0.9, 0, 0), eyev, normalv, false)")
{
Color c1 = m.lighting(light, Tuple::Point(0.9, 0, 0), eyev, normalv, false);
AND_WHEN("c2 <- lighting(m, light, point(1.1, 0, 0), eyev, normalv, false)")
{
Color c2 = m.lighting(light, Tuple::Point(1.1, 0, 0), eyev, normalv, false);
THEN("c1 = color(1, 1, 1)")
{
REQUIRE(c1 == Color(1, 1, 1));
}
AND_THEN("c2 = color(0, 0, 0)")
{
REQUIRE(c2 == Color(0, 0, 0));
}
}
}
}
}
}
}
}
}
}
}