Added planar mapping

This commit is contained in:
Godzil
2020-03-04 13:35:09 +00:00
parent 5bbd036fc5
commit 107b612130
6 changed files with 105 additions and 1 deletions

View File

@@ -351,4 +351,40 @@ TEST(PatternTest, Using_a_texture_map_with_a_spherical_map)
Colour ret = tm.patternAt(testList[i]);
EXPECT_EQ(ret, testResults[i]);
}
}
TEST(PatternTest, Using_a_planar_mapping_on_a_3d_point)
{
Point testList[] = {
Point(0.25, 0.0, 0.5),
Point(0.25, 0.0, -0.25),
Point(0.25, 0.5, -0.25),
Point(1.25, 0.0, 0.5),
Point(0.25, 0.0, -1.75),
Point(1.00, 0.0, -1.0),
Point(0.00, 0.0, 0.0),
};
double testResults[][2] {
{0.25, 0.50},
{0.25, 0.75},
{0.25, 0.75},
{0.25, 0.50},
{0.25, 0.25},
{0.00, 0.00},
{0.00, 0.00},
};
int testCount = sizeof(testList)/sizeof((testList)[0]);
int i;
TextureMap tm = TextureMap(PLANAR_MAP, nullptr);
for(i = 0; i < testCount; i++)
{
double u, v;
tm.planarMap(testList[i], u, v);
ASSERT_TRUE(double_equal(u, testResults[i][0]));
ASSERT_TRUE(double_equal(v, testResults[i][1]));
}
}