SolarSim
Loading...
Searching...
No Matches
solarsim::AssetManager Class Reference

Manages loading and caching of game assets (meshes, materials, shaders). More...

#include <asset_manager.hpp>

Public Member Functions

 AssetManager (const AssetManager &)=delete
AssetManageroperator= (const AssetManager &)=delete
std::shared_ptr< MeshLoadMesh (const std::string &meshID)
 Load or retrieve a cached mesh by ID.
std::shared_ptr< MaterialLoadMaterial (const std::string &materialID)
 Load or retrieve a cached material by ID.
std::shared_ptr< ShaderLoadShader (const std::string &shaderID)
 Load or retrieve a cached shader by ID.

Static Public Member Functions

static AssetManagerget ()
 Get the singleton AssetManager instance.

Private Member Functions

void generateSphere (std::vector< float > &vertices, std::vector< uint32_t > &indices, float radius=1.0f, int resolution=100)
 Generate sphere mesh geometry.
void generateGrid (std::vector< float > &vertices, std::vector< uint32_t > &indices, float spacing=20.0f, int extent=100)
 Generate grid mesh geometry.
 AssetManager ()
 ~AssetManager ()

Private Attributes

std::unordered_map< std::string, std::shared_ptr< Material > > loadedMaterials
std::unordered_map< std::string, std::shared_ptr< Mesh > > loadedMeshes
std::unordered_map< std::string, std::shared_ptr< Shader > > loadedShaders

Detailed Description

Manages loading and caching of game assets (meshes, materials, shaders).

Note
Singleton pattern with lazy loading and caching
Warning
All asset loading requires active OpenGL context

Constructor & Destructor Documentation

◆ AssetManager() [1/2]

solarsim::AssetManager::AssetManager ( const AssetManager & )
delete

◆ AssetManager() [2/2]

solarsim::AssetManager::AssetManager ( )
inlineprivate

◆ ~AssetManager()

solarsim::AssetManager::~AssetManager ( )
inlineprivate

Member Function Documentation

◆ generateGrid()

void solarsim::AssetManager::generateGrid ( std::vector< float > & vertices,
std::vector< uint32_t > & indices,
float spacing = 20.0f,
int extent = 100 )
private

Generate grid mesh geometry.

Parameters
verticesOutput vector for vertex data
indicesOutput vector for index data
spacingDistance between grid lines
extentNumber of lines in each direction from center

◆ generateSphere()

void solarsim::AssetManager::generateSphere ( std::vector< float > & vertices,
std::vector< uint32_t > & indices,
float radius = 1.0f,
int resolution = 100 )
private

Generate sphere mesh geometry.

Parameters
verticesOutput vector for vertex data
indicesOutput vector for index data
radiusSphere radius
resolutionTessellation resolution

◆ get()

AssetManager & solarsim::AssetManager::get ( )
static

Get the singleton AssetManager instance.

Returns
AssetManager& Reference to the asset manager

◆ LoadMaterial()

std::shared_ptr< Material > solarsim::AssetManager::LoadMaterial ( const std::string & materialID)

Load or retrieve a cached material by ID.

Parameters
materialIDUnique identifier for the material
Returns
std::shared_ptr<Material> Shared pointer to the material
Note
Currently supports predefined materials only
Warning
Undefined behavior if materialID is not recognized as of now

◆ LoadMesh()

std::shared_ptr< Mesh > solarsim::AssetManager::LoadMesh ( const std::string & meshID)

Load or retrieve a cached mesh by ID.

Parameters
meshIDUnique identifier for the mesh
Returns
std::shared_ptr<Mesh> Shared pointer to the mesh
Note
Currently supports predefined shapes: "cube", "sphere", "grid"
Warning
Undefined behavior if meshID is not recognized as of now

◆ LoadShader()

std::shared_ptr< Shader > solarsim::AssetManager::LoadShader ( const std::string & shaderID)

Load or retrieve a cached shader by ID.

Parameters
shaderIDUnique identifier for the shader
Returns
std::shared_ptr<Shader> Shared pointer to the shader
Note
Currently supports predefined shaders only
Warning
Undefined behavior if shaderID is not recognized as of now

◆ operator=()

AssetManager & solarsim::AssetManager::operator= ( const AssetManager & )
delete

Field Documentation

◆ loadedMaterials

std::unordered_map<std::string, std::shared_ptr<Material> > solarsim::AssetManager::loadedMaterials
private

Cache of loaded materials

◆ loadedMeshes

std::unordered_map<std::string, std::shared_ptr<Mesh> > solarsim::AssetManager::loadedMeshes
private

Cache of loaded meshes

◆ loadedShaders

std::unordered_map<std::string, std::shared_ptr<Shader> > solarsim::AssetManager::loadedShaders
private

Cache of loaded shader shaders


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