Terminus
|
The ResourceManager class loads geometry, materials and shader progams during initialization and provides access to those resources. More...
#include <resourcemanager.h>
Public Member Functions | |
virtual | ~ResourceManager () |
virtual void | loadResources () |
All external resources the game might use are loaded here. More... | |
virtual std::shared_ptr< std::unique_ptr< Geometry > > | getGeometry (std::string name) |
virtual std::shared_ptr< std::unique_ptr< Material > > | getMaterial (std::string name) |
virtual std::shared_ptr< std::unique_ptr< Program > > | getProgram (std::string name) |
Static Public Member Functions | |
static ResourceManager * | getInstance () |
Returns the singelton instance of the ResourceManager class. More... | |
Protected Member Functions | |
ResourceManager () | |
virtual void | loadObj (std::string path) |
The .obj file specified by "path" will be parsed and stored in the geometry container m_geometryStorage. More... | |
virtual void | loadObjGenerateAdd (std::vector< QVector3D > &positions, std::vector< QVector3D > &texCoords, std::vector< QVector3D > &normals, std::vector< IndexTriple > &indexTriples, std::string name) |
This method is part of the loading mechanism for .obj files. More... | |
virtual void | loadMtl (std::string path) |
Loads material data from .mtl files. More... | |
virtual void | loadProgram (std::string path) |
Vertex and fragment shader files are loaded an combined into on program instance from the Program class. More... | |
virtual void | putGeometry (std::string name, Geometry *geometry) |
virtual void | putMaterial (std::string name, Material *material) |
virtual void | putProgram (std::string name, Program *program) |
Static Protected Member Functions | |
static std::string | entityName (const std::string path, const std::string name) |
Generates a unique resource identifier from the resource's file path and name. More... | |
static std::string | entityName (const std::string path) |
Generates a unique resource identifier from the resource's file path. More... | |
Protected Attributes | |
std::map< std::string, std::shared_ptr< std::unique_ptr< Geometry > > > | m_geometryStorage |
std::map< std::string, std::shared_ptr< std::unique_ptr< Material > > > | m_materialStorage |
std::map< std::string, std::shared_ptr< std::unique_ptr< Program > > > | m_programStorage |
Static Protected Attributes | |
static ResourceManager * | m_instance = nullptr |
The ResourceManager class loads geometry, materials and shader progams during initialization and provides access to those resources.
Loaded data is stored in three corresponding member variables of type "std::map<std::string, std::shared_ptr<std::unique_ptr< ... >>>". Having two pointers secures to have valid data accessable at all times. By the time data is updated during runtime, classes with references to stored data will automatically load the recent data. Implemented as a singelton, accessibility for all classes is ensured.
|
virtual |
|
protected |
|
staticprotected |
Generates a unique resource identifier from the resource's file path and name.
path | |
name |
|
staticprotected |
Generates a unique resource identifier from the resource's file path.
path |
|
virtual |
|
static |
Returns the singelton instance of the ResourceManager class.
|
virtual |
|
virtual |
|
protectedvirtual |
Loads material data from .mtl files.
path | Any number of materials encoded in one .mtl file are loaded and stored in the material container m_materialStorage. |
|
protectedvirtual |
The .obj file specified by "path" will be parsed and stored in the geometry container m_geometryStorage.
path | The file is parsed line by line, storing data for vertex position (line begins with "v"), texture coordinates (line begins with "t"), normal vectors (line begins with "n") and geometry faces (line begins with "f"). A line starting with "o" specifies the object name. The corresponding BBox is generated while parsing the data. |
|
protectedvirtual |
This method is part of the loading mechanism for .obj files.
positions | |
texCoords | |
normals | |
indexTriples | |
name | IndexTriples as specified in the .obj file are converted to a single index and a new Geometry instance is created and added to the geometry container "m_geometryStorage". |
|
protectedvirtual |
|
virtual |
All external resources the game might use are loaded here.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protected |
|
staticprotected |
|
protected |
|
protected |