diff options
Diffstat (limited to 'gfx/models/obj.h')
-rw-r--r-- | gfx/models/obj.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gfx/models/obj.h b/gfx/models/obj.h new file mode 100644 index 0000000..96c5e94 --- /dev/null +++ b/gfx/models/obj.h @@ -0,0 +1,36 @@ +#ifndef OBJ_H +#define OBJ_H + +#ifndef yyFlexLexer +# define yyFlexLexer objbaseFlexLexer +# include <FlexLexer.h> +#endif +#include <filesystem> +#include <fstream> +#include <glm/glm.hpp> +#include <memory> +#include <vector> + +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()) + { + ObjParser::yylex(); + } + + int yylex() override; + + std::vector<glm::vec4> vertices; + std::vector<glm::vec3> texCoords; + std::vector<glm::vec3> normals; + using FaceElement = glm::vec<3, int>; + using Face = std::vector<FaceElement>; + std::vector<Face> faces; + glm::length_t axis {0}; +}; + +#endif |