[FEAT] Add PointLight & Material
This commit is contained in:
@@ -212,3 +212,103 @@ SCENARIO("Reflecting a vector off a slanted surface", "[features/tuples.feature]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("A point light has a position and intensity", "[features/lights.feature]")
|
||||
{
|
||||
GIVEN("intensity <- color(1, 1, 1)")
|
||||
{
|
||||
Color intensity(1, 1, 1);
|
||||
AND_GIVEN("position <- point(0, 0, 0)")
|
||||
{
|
||||
Tuple position = Tuple::Point(0, 0, 0);
|
||||
WHEN("light <- point_light(position(position, intensity))")
|
||||
{
|
||||
PointLight light = PointLight(position, intensity);
|
||||
THEN("light.position = position")
|
||||
{
|
||||
REQUIRE(light.position() == position);
|
||||
}
|
||||
AND_THEN("light.intensity = intensity")
|
||||
{
|
||||
REQUIRE(light.intensity() == intensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("The default material", "[features/materials.feature]")
|
||||
{
|
||||
GIVEN("m <- material()")
|
||||
{
|
||||
Material m;
|
||||
THEN("m.color = color(1,1,1)")
|
||||
{
|
||||
REQUIRE(m.color() == Color(1, 1, 1));
|
||||
}
|
||||
AND_THEN("m.ambient = 0.1")
|
||||
{
|
||||
REQUIRE(m.ambient() == 0.1);
|
||||
}
|
||||
AND_THEN("m.diffuse = 0.9")
|
||||
{
|
||||
REQUIRE(m.diffuse() == 0.9);
|
||||
}
|
||||
AND_THEN("m.specular = 0.9")
|
||||
{
|
||||
REQUIRE(m.specular() == 0.9);
|
||||
}
|
||||
AND_THEN("m.shininess = 200.0")
|
||||
{
|
||||
REQUIRE(m.shininess() == 200.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("A sphere has a default material", "[features/spheres.feature]")
|
||||
{
|
||||
GIVEN("s <- sphere()")
|
||||
{
|
||||
Sphere s;
|
||||
WHEN("m <- s.material")
|
||||
{
|
||||
Material m = s.material();
|
||||
THEN("m = material()")
|
||||
{
|
||||
REQUIRE(m == Material());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("A sphere may be assigned a material", "[features/spheres.feature]")
|
||||
{
|
||||
GIVEN("s <- sphere()")
|
||||
{
|
||||
Sphere s;
|
||||
AND_GIVEN("m <- material")
|
||||
{
|
||||
Material m;
|
||||
AND_GIVEN("m.ambient <- 1")
|
||||
{
|
||||
m.set_ambient(1);
|
||||
WHEN("s.material <- m")
|
||||
{
|
||||
s.set_material(m);
|
||||
THEN("s.material = m")
|
||||
{
|
||||
s.material() == m;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user