aboutsummaryrefslogtreecommitdiff
path: root/apps/openmb/renderer/Model.hpp
blob: e20c523095d9f3224415793b52e3618097572a91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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