summaryrefslogtreecommitdiff
path: root/gfx/models/obj.impl.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-04 19:22:32 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-04 19:22:32 +0000
commit5c8ee551d26f6d883d40b5c1a9f36b2b0eac2756 (patch)
treee6af71e2fceffb6811c1df4730c301e104adf9c9 /gfx/models/obj.impl.cpp
parentDo not unilluminate the back of objects (diff)
downloadilt-5c8ee551d26f6d883d40b5c1a9f36b2b0eac2756.tar.bz2
ilt-5c8ee551d26f6d883d40b5c1a9f36b2b0eac2756.tar.xz
ilt-5c8ee551d26f6d883d40b5c1a9f36b2b0eac2756.zip
We need to transform the model normals the same as we do the vertices
Diffstat (limited to 'gfx/models/obj.impl.cpp')
-rw-r--r--gfx/models/obj.impl.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/gfx/models/obj.impl.cpp b/gfx/models/obj.impl.cpp
index d73d82e..205abc8 100644
--- a/gfx/models/obj.impl.cpp
+++ b/gfx/models/obj.impl.cpp
@@ -19,15 +19,18 @@ ObjParser::ObjParser(std::unique_ptr<std::istream> in) : yyFlexLexer(in.get())
assert(in);
ObjParser::yylex();
assert(in->good());
- std::for_each(vertices.begin(), vertices.end(), [](auto & v) {
- constexpr const glm::mat4 obj2ilt {
- -1, 0, 0, 0, // x
- 0, 0, 1, 0, // y
- 0, 1, 0, 0, // z
- 0, 0, 0, 0, // w
- };
+ constexpr const glm::mat4 obj2ilt {
+ -1, 0, 0, 0, // x
+ 0, 0, 1, 0, // y
+ 0, 1, 0, 0, // z
+ 0, 0, 0, 0, // w
+ };
+ std::for_each(vertices.begin(), vertices.end(), [&obj2ilt](auto & v) {
v = v * obj2ilt;
});
+ std::for_each(normals.begin(), normals.end(), [&obj2ilt](auto & v) {
+ v = glm::vec4 {v, 0} * obj2ilt;
+ });
}
ObjParser::NamedMeshes