Initial support of parsing vertex color(extension format)

This commit is contained in:
Syoyo Fujita
2017-10-12 19:04:38 +09:00
parent 3a9483ca6f
commit 88ad575f62
4 changed files with 118 additions and 1 deletions

View File

@@ -625,6 +625,39 @@ TEST_CASE("g_ignored", "[Issue138]") {
}
TEST_CASE("vertex-col-ext", "[Issue144]") {
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string err;
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, "../models/cube-vertexcol.obj", gMtlBasePath);
if (!err.empty()) {
std::cerr << err << std::endl;
}
PrintInfo(attrib, shapes, materials);
REQUIRE(true == ret);
REQUIRE((8 * 3) == attrib.colors.size());
REQUIRE(0 == Approx(attrib.colors[3 * 0 + 0]));
REQUIRE(0 == Approx(attrib.colors[3 * 0 + 1]));
REQUIRE(0 == Approx(attrib.colors[3 * 0 + 2]));
REQUIRE(0 == Approx(attrib.colors[3 * 1 + 0]));
REQUIRE(0 == Approx(attrib.colors[3 * 1 + 1]));
REQUIRE(1 == Approx(attrib.colors[3 * 1 + 2]));
REQUIRE(1 == Approx(attrib.colors[3 * 4 + 0]));
REQUIRE(1 == Approx(attrib.colors[3 * 7 + 0]));
REQUIRE(1 == Approx(attrib.colors[3 * 7 + 1]));
REQUIRE(1 == Approx(attrib.colors[3 * 7 + 2]));
}
#if 0
int
main(