Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Public Member Functions | Friends | List of all members
Engine::ResourceManager Class Reference

This class is used to create models, load in meshes and textures. NOTE: Only the Engine is allowed to create this object. More...

#include <ResourceManager.hpp>

Public Member Functions

eastl::weak_ptr< ModelGetModel (eastl::string modelName)
 This method allows you to get a model with a specific name. More...
 
eastl::weak_ptr< ModelCreateModel (eastl::string modelName, eastl::string meshToLoad="", eastl::string skeleton="")
 This method will allow you to create a new model with the model name. More...
 
eastl::weak_ptr< SkeletonCreateSkeleton (eastl::string skeletonToLoad)
 This will load the skeleton data from the file specified. NOTe: This method will not load in the skeleton again, if it's already loaded in. More...
 
void AddAnimationsToSkeleton (eastl::string skeletonName, eastl::string animationsToLoad="", eastl::vector< eastl::string > names={})
 This method loads animations from a file, and adds them to the skeleton with the specified name. More...
 
eastl::weak_ptr< MeshCreateMesh (aiMesh *mesh, eastl::shared_ptr< Skeleton > skeleton, eastl::vector< Vertex > vertices, eastl::vector< unsigned > indices)
 This method allows you to create a new mesh. NOTE: This method will not load in the mesh again, if it's already loaded in. More...
 
eastl::weak_ptr< TextureGetTexture (eastl::string textureName)
 This method allows you to get a texture with the defined name. More...
 
eastl::weak_ptr< TextureCreateTexture (eastl::string textureName)
 This method allows you to create a new texture with the given name. More...
 
eastl::weak_ptr< TextureCreateTexture (eastl::string textureName, stbi_uc *data, int width, int height)
 Creates a new texture with the given name, using the supplied data as source. More...
 
 ~ResourceManager ()=default
 

Friends

class Engine
 
class Model
 

Detailed Description

This class is used to create models, load in meshes and textures. NOTE: Only the Engine is allowed to create this object.

Definition at line 16 of file ResourceManager.hpp.

Constructor & Destructor Documentation

Engine::ResourceManager::~ResourceManager ( )
default

Member Function Documentation

void Engine::ResourceManager::AddAnimationsToSkeleton ( eastl::string  skeletonName,
eastl::string  animationsToLoad = "",
eastl::vector< eastl::string >  names = {} 
)

This method loads animations from a file, and adds them to the skeleton with the specified name.

Parameters
skeletonNameThe model to add animations to.
animationsToLoadThe file containing the animations. NOTE: The animation file needs to be located under 'Resources/Animations/' You then give the animation file name + its extension. The file can be in a subfolder of 'Resources/Animations/'
namesA vector containing names for the animations being loaded. If animation n in the file has a name at position n in the vector that name will be used instead. Leave the name at position n blank to use the name supplied by the file instead.

Definition at line 92 of file ResourceManager.cpp.

eastl::weak_ptr< Mesh > Engine::ResourceManager::CreateMesh ( aiMesh *  mesh,
eastl::shared_ptr< Skeleton skeleton,
eastl::vector< Vertex vertices,
eastl::vector< unsigned >  indices 
)

This method allows you to create a new mesh. NOTE: This method will not load in the mesh again, if it's already loaded in.

Parameters
meshThe mesh you want to load in.
skeletonThe skeleton the mesh is bound to. Passing a nullptr will create a non-animated mesh.
verticesThe vertices of the mesh.
indicesThe indices of the mesh.
Returns
Returns a shared_ptr of the mesh you want to create.

Definition at line 106 of file ResourceManager.cpp.

eastl::weak_ptr< Model > Engine::ResourceManager::CreateModel ( eastl::string  modelName,
eastl::string  meshToLoad = "",
eastl::string  skeleton = "" 
)

This method will allow you to create a new model with the model name.

Parameters
modelNameThe model you want to create.
meshToLoadOptional parameter where you can add a mesh you want to load in. NOTE: The mesh needs to be located under 'Resources/Models/' You then give the mesh name + its extension. The mesh can be in a subfolder of 'Resources/Meshes/'
skeletonOptional parameter to load a specific skeleton with the model. If not specified the function will load the skeleton from the same file as the model. NOTE: The skeleton needs to be located under 'Resources/Models/' You then give the mesh name + its extension. The skeleton can be in a subfolder of 'Resources/Models/'
Returns
Will return a new model, optionally with an already loaded mesh and skeleton.

Definition at line 34 of file ResourceManager.cpp.

eastl::weak_ptr< Skeleton > Engine::ResourceManager::CreateSkeleton ( eastl::string  skeletonToLoad)

This will load the skeleton data from the file specified. NOTe: This method will not load in the skeleton again, if it's already loaded in.

Parameters
skeletonToLoadThe file to load the skeleton from. NOTE: The skeleton needs to be located under 'Resources/Models/' You then give the mesh name + its extension. The skeleton can be in a subfolder of 'Resources/Models/'
Returns
Will return a new skeleton.

Definition at line 65 of file ResourceManager.cpp.

eastl::weak_ptr< Texture > Engine::ResourceManager::CreateTexture ( eastl::string  textureName)

This method allows you to create a new texture with the given name.

Parameters
textureNameThe texture you want to create. NOTE: The texture needs to be located under 'Resources/Textures/'. You then give the texture name + extension. The texture can be in a subfolder of of 'Resources/Textures/'.
Returns
Returns a reference to the just created texture. Or if the texture was already created before, it'll return a reference to that texture.

Definition at line 134 of file ResourceManager.cpp.

eastl::weak_ptr< Texture > Engine::ResourceManager::CreateTexture ( eastl::string  textureName,
stbi_uc *  data,
int  width,
int  height 
)

Creates a new texture with the given name, using the supplied data as source.

Parameters
textureNameThe name for the texture you want to create.
dataThe raw data of the texture you want to create. NOTE: The data must be of RGBA8 format.
widthThe width of the texture.
heightThe height of the texture.
Returns

Definition at line 258 of file ResourceManager.cpp.

eastl::weak_ptr< Model > Engine::ResourceManager::GetModel ( eastl::string  modelName)

This method allows you to get a model with a specific name.

Parameters
modelNameThe model name you are looking for.
Returns
Returns a shared pointer to the model is it was found. Otherwise it will return a empty shared pointer.

Definition at line 21 of file ResourceManager.cpp.

eastl::weak_ptr< Texture > Engine::ResourceManager::GetTexture ( eastl::string  textureName)

This method allows you to get a texture with the defined name.

Parameters
textureNameThe texture you want to find. NOTE: The texture needs to be located under 'Resources/Textures/'. You then give the texture name + extension. The texture can be in a subfolder of 'Resources/Textures/'.
Returns
Returns a shared pointer of the texture you want to get. Will return an empty shared pointer if the texture hasn't been loaded yet.

Definition at line 124 of file ResourceManager.cpp.

Friends And Related Function Documentation

friend class Engine
friend

Definition at line 87 of file ResourceManager.hpp.

friend class Model
friend

Definition at line 93 of file ResourceManager.hpp.


The documentation for this class was generated from the following files: