// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_FORMATS_OBJPARSER_HPP #define NAZARA_FORMATS_OBJPARSER_HPP #include #include #include #include #include #include #include namespace Nz { class NAZARA_UTILITY_API OBJParser { public: struct FaceVertex { int normal; int position; int texCoord; }; struct Face { std::vector vertices; }; struct Mesh { std::vector faces; String name; unsigned int material; }; OBJParser(Stream& stream$); ~OBJParser(); const String* GetMaterials() const; unsigned int GetMaterialCount() const; const Mesh* GetMeshes() const; unsigned int GetMeshCount() const; const String& GetMtlLib() const; const Vector3f* GetNormals() const; unsigned int GetNormalCount() const; const Vector4f* GetPositions() const; unsigned int GetPositionCount() const; const Vector3f* GetTexCoords() const; unsigned int GetTexCoordCount() const; bool Parse(); private: bool Advance(bool required = true); void Error(const String& message); void Warning(const String& message); void UnrecognizedLine(bool error = false); std::vector m_meshes; std::vector m_materials; std::vector m_normals; std::vector m_positions; std::vector m_texCoords; Stream& m_stream; String m_currentLine; String m_mtlLib; bool m_keepLastLine; unsigned int m_lineCount; unsigned int m_streamFlags; }; } #endif // NAZARA_FORMATS_OBJPARSER_HPP