aboutsummaryrefslogtreecommitdiff
path: root/apps/openmb/renderer/Model.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'apps/openmb/renderer/Model.hpp')
-rw-r--r--apps/openmb/renderer/Model.hpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/apps/openmb/renderer/Model.hpp b/apps/openmb/renderer/Model.hpp
new file mode 100644
index 0000000..e20c523
--- /dev/null
+++ b/apps/openmb/renderer/Model.hpp
@@ -0,0 +1,51 @@
+#pragma once
+
+#include "Mesh.hpp"
+#include "Shader.hpp"
+#include "Texture.hpp"
+
+#include <assimp/scene.h>
+#include <glm/glm.hpp>
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace renderer
+{
+ class Model
+ {
+ public:
+ Model();
+ ~Model() = default;
+
+ bool loadFromFile( const std::string &path );
+
+ size_t meshCount() const { return mMeshes.size(); }
+
+ const glm::vec3 &getBoundsMin() const { return mBoundsMin; }
+ const glm::vec3 &getBoundsMax() const { return mBoundsMax; }
+
+ const std::vector< std::unique_ptr< Mesh > > &getMeshes() const { return mMeshes; }
+ const std::vector< Texture > &getTextures() const { return mTextures; }
+ const std::vector< Texture > &getNormalTextures() const { return mNormalTextures; }
+ const std::vector< int > &getMeshTextureIndex() const { return mMeshToTex; }
+ const std::vector< int > &getMeshNormalIndex() const { return mMeshToNormal; }
+
+ private:
+ bool processNode( aiNode *node, const aiScene *scene, const std::string &baseDir );
+ bool processMesh( aiMesh *mesh, const aiScene *scene, const std::string &baseDir, int &outTexIndex,
+ int &outNormalIndex );
+
+ std::vector< std::unique_ptr< Mesh > > mMeshes;
+ std::vector< Texture > mTextures;
+ std::vector< Texture > mNormalTextures;
+
+ std::vector< int > mMeshToTex;
+ std::vector< int > mMeshToNormal;
+ int mFallbackAlbedoIndex;
+ int mFallbackNormalIndex;
+ glm::vec3 mBoundsMin;
+ glm::vec3 mBoundsMax;
+ };
+
+} // namespace renderer