diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /apps/openmb/renderer/Model.hpp | |
Diffstat (limited to 'apps/openmb/renderer/Model.hpp')
| -rw-r--r-- | apps/openmb/renderer/Model.hpp | 51 |
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 |