Load the normal vectors of the primitive

Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
This commit is contained in:
Arthur Brainville 2018-02-20 01:30:15 +01:00 committed by Arthur Brainville (Ybalrid)
parent 5682cb4542
commit db5b272a1b
No known key found for this signature in database
GPG Key ID: BC05C4812A06BCF3

View File

@ -283,6 +283,32 @@ bool LoadGLTF(const std::string &filename, float scale,
if (attribute.first == "NORMAL") {
std::cout << "found normal attribute\n";
switch (attribAccessor.componentType) {
case TINYGLTF_COMPONENT_TYPE_FLOAT:
switch (attribAccessor.type) {
case TINYGLTF_TYPE_VEC3: {
std::cout << "normal vec3\n";
v3fArray normals(
arrayAdapter<v3f>(dataPtr, count, byte_stride));
for (size_t i{0}; i < indices.size(); ++i) {
const auto index{indices[i]};
const auto v = normals[index];
std::cout << '(' << v.x << ", " << v.y << ", " << v.z
<< ")\n";
}
} break;
case TINYGLTF_TYPE_VEC4:
std::cout << "normal vec4";
break;
default:
// TODO handle error
break;
}
default:
// TODO handle error
break;
}
}
}
}