summaryrefslogtreecommitdiff
path: root/gfx/models
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-11-16 00:07:48 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-11-16 00:07:48 +0000
commitb7fadd730a78671a0eaf55c36df24c04661ef2c3 (patch)
treea9d5bce62b3c6e42008d7e0f637665aa97b73764 /gfx/models
parentDon't write null value for pointers (diff)
downloadilt-b7fadd730a78671a0eaf55c36df24c04661ef2c3.tar.bz2
ilt-b7fadd730a78671a0eaf55c36df24c04661ef2c3.tar.xz
ilt-b7fadd730a78671a0eaf55c36df24c04661ef2c3.zip
Swap y,z axis
This was a pain... but all the coords make much more sense now and a lot of mystery negation has disappeared.
Diffstat (limited to 'gfx/models')
-rw-r--r--gfx/models/obj.h12
-rw-r--r--gfx/models/obj.impl.cpp13
2 files changed, 15 insertions, 10 deletions
diff --git a/gfx/models/obj.h b/gfx/models/obj.h
index a2d874f..9a2a30e 100644
--- a/gfx/models/obj.h
+++ b/gfx/models/obj.h
@@ -17,16 +17,8 @@ class Vertex;
class ObjParser : yyFlexLexer {
public:
- explicit ObjParser(const std::filesystem::path & fileName) : ObjParser {std::make_unique<std::ifstream>(fileName)}
- {
- }
-
- explicit ObjParser(std::unique_ptr<std::istream> in) : yyFlexLexer(in.get())
- {
- assert(in);
- ObjParser::yylex();
- assert(in->good());
- }
+ explicit ObjParser(const std::filesystem::path & fileName);
+ explicit ObjParser(std::unique_ptr<std::istream> in);
int yylex() override;
diff --git a/gfx/models/obj.impl.cpp b/gfx/models/obj.impl.cpp
index 330e851..0701d13 100644
--- a/gfx/models/obj.impl.cpp
+++ b/gfx/models/obj.impl.cpp
@@ -9,6 +9,19 @@
#include <utility>
#include <vector>
+ObjParser::ObjParser(const std::filesystem::path & fileName) : ObjParser {std::make_unique<std::ifstream>(fileName)} { }
+
+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) {
+ std::swap(v.y, v.z);
+ v.x = -v.x;
+ });
+}
+
ObjParser::NamedMeshes
ObjParser::createMeshes() const
{