esp::assets::ResourceManager class

Singleton class responsible for loading and managing common simulator assets such as meshes, textures, and materials.

Public types

using DrawableGroup = gfx::DrawableGroup
Stores references to a set of drawable elements.
using Importer = Magnum::Trade::AbstractImporter
Convenience typedef for Importer class.

Public static variables

static char NO_LIGHT_KEY constexpr
The ShaderManager key for LightInfo which has no lights.
static char DEFAULT_LIGHTING_KEY constexpr
The ShaderManager key for the default LightInfo.
static char DEFAULT_MATERIAL_KEY constexpr
The ShaderManager key for the default MaterialInfo.
static char PER_VERTEX_OBJECT_ID_MATERIAL_KEY constexpr
The ShaderManager key for MaterialInfo with per-vertex object ID.

Constructors, destructors, conversion operators

ResourceManager() explicit
Constructor.
~ResourceManager()
Destructor.

Public functions

void compressTextures(bool newVal)
Set whether textures should be compressed.
auto loadScene(const AssetInfo& info, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{NO_LIGHT_KEY}, bool splitSemanticMesh = true) -> bool
Load a scene mesh and add it to the specified DrawableGroup as a child of the specified scene::SceneNode.
auto loadScene(const AssetInfo& info, std::shared_ptr<physics::PhysicsManager>& _physicsManager, PhysicsManagerAttributes::ptr physicsManagerAttributes, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{ NO_LIGHT_KEY}) -> bool
Load and instantiate a scene including physics simulation.
auto loadScene(const AssetInfo& info, std::shared_ptr<physics::PhysicsManager>& _physicsManager, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{NO_LIGHT_KEY}, std::string physicsFilename = ESP_DEFAULT_PHYS_SCENE_CONFIG) -> bool
Load and instantiate a scene including physics simulation.
auto loadPhysicsConfig(std::string physicsFilename = ESP_DEFAULT_PHYS_SCENE_CONFIG) -> PhysicsManagerAttributes::ptr
Parses global physics simulation parameters (such as timestep, gravity, simulator implementation) from the specified configuration file.
auto getObjectConfigPaths(std::string path) -> std::vector<std::string>
Get all "*.phys_properties.json" files from the provided file or directory path.
void addObjectToDrawables(int objTemplateLibID, scene::SceneNode* parent, DrawableGroup* drawables, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{DEFAULT_LIGHTING_KEY})
Add an object from a spcified configuration file to the specified DrawableGroup as a child of the specified scene::SceneNode if provided.
auto parseAndLoadPhysObjTemplate(const std::string& objPhysConfigFilename) -> int
Load and parse a physics object template config file and generates a PhysicsObjectAttributes object, adding it to the physicsObjTemplateLibrary_.
auto loadObjectTemplate(PhysicsObjectAttributes::ptr objectTemplate, const std::string objectTemplateHandle) -> int
Add a PhysicsObjectAttributes object to the physicsObjTemplateLibrary_.
auto getCollisionMesh(const std::string configFile) -> const std::vector<assets::CollisionMeshData>&
Getter for all assets::CollisionMeshData associated with the particular asset referenced by the key, configFile.
auto getCollisionMesh(const int objectTemplateID) -> const std::vector<assets::CollisionMeshData>&
Getter for all assets::CollisionMeshData associated with the particular asset referenced by the index, objectTemplateID, in physicsObjTemplateLibrary_.
auto getObjectTemplateID(const std::string& configFile) -> int
Get the index in physicsObjTemplateLibrary_ for the object template asset identified by the key, configFile.
auto getObjectConfig(const int objectTemplateID) -> std::string
Get the key in physicsObjTemplateLibrary_ for the object template asset index.
auto getPhysicsObjectAttributes(const std::string& configFile) -> PhysicsObjectAttributes::ptr
Get a reference to the physics object template for the asset identified by the key, configFile. physicsObjTemplateLibrary_.
auto getPhysicsObjectAttributes(const int objectTemplateID) -> PhysicsObjectAttributes::ptr
Get a reference to the physics object template for the asset identified by the objectTemplateID.
auto getNumLibraryObjects() -> int
Gets the number of object templates stored in the physicsObjTemplateLibrary_.
auto getMeshTransformation(const size_t meshIndex) -> const Magnum::Matrix4&
Retrieve the composition of all transforms applied to a mesh since it was loaded.
auto getMeshMetaData(const std::string& filename) const -> const MeshMetaData&
Retrieve the meta data for a particular asset.
auto createJoinedCollisionMesh(const std::string& filename) -> std::unique_ptr<MeshData>
Construct a unified MeshData from a loaded asset's collision meshes.
void addPrimitiveToDrawables(int primitiveID, scene::SceneNode& node, DrawableGroup* drawables)
Create a new drawable primitive attached to the desired scene::SceneNode.
void setLightSetup(gfx::LightSetup setup, const Magnum::ResourceKey& key = Magnum::ResourceKey{ DEFAULT_LIGHTING_KEY})
Set a named LightSetup.
auto getLightSetup(const Magnum::ResourceKey& key = Magnum::ResourceKey{ DEFAULT_LIGHTING_KEY}) -> Magnum::Resource<gfx::LightSetup>
Get a named LightSetup.
auto loadNavMeshVisualization(esp::nav::PathFinder& pathFinder, scene::SceneNode* parent, DrawableGroup* drawables) -> int
generate a new primitive mesh asset for the NavMesh loaded in the provided PathFinder object.

Protected types

struct LoadedAssetData
Data for a loaded asset.
struct StaticDrawableInfo

Protected functions

void addComponent(const MeshMetaData& metaData, scene::SceneNode& parent, const Magnum::ResourceKey& lightSetup, DrawableGroup* drawables, const MeshTransformNode& meshTransformNode)
Recursive contruction of scene nodes for an asset.
void loadTextures(Importer& importer, LoadedAssetData& loadedAssetData)
Load textures from importer into assets, and update metaData for an asset to link textures to that asset.
void loadMeshes(Importer& importer, LoadedAssetData& loadedAssetData)
Load meshes from importer into assets.
void loadMeshHierarchy(Importer& importer, MeshTransformNode& parent, int componentID)
Recursively parse the mesh component transformation heirarchy for the imported asset.
void joinHeirarchy(MeshData& mesh, const MeshMetaData& metaData, const MeshTransformNode& node, const Magnum::Matrix4& transformFromParentToWorld)
Recursively build a unified MeshData from loaded assets via a tree of MeshTransformNode.
void loadMaterials(Importer& importer, LoadedAssetData& loadedAssetData)
Load materials from importer into assets, and update metaData for an asset to link materials to that asset.
auto getFlatShadedMaterialData(const Magnum::Trade::PhongMaterialData& material, int textureBaseIndex) -> gfx::PhongMaterialData::uptr
Get a PhongMaterialData for use with flat shading.
auto getPhongShadedMaterialData(const Magnum::Trade::PhongMaterialData& material, int textureBaseIndex) -> gfx::PhongMaterialData::uptr
Get a PhongMaterialData for use with phong shading.
auto loadPTexMeshData(const AssetInfo& info, scene::SceneNode* parent, DrawableGroup* drawables) -> bool
Load a PTex mesh into assets from a file and add it to the scene graph for rendering.
auto loadInstanceMeshData(const AssetInfo& info, scene::SceneNode* parent, DrawableGroup* drawables, bool splitSemanticMesh = true) -> bool
Load an instance mesh (e.g. Matterport reconstruction) into assets from a file and add it to the scene graph for rendering.
auto loadGeneralMeshData(const AssetInfo& info, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{NO_LIGHT_KEY}) -> bool
Load a mesh (e.g. gltf) into assets from a file.
auto loadSUNCGHouseFile(const AssetInfo& info, scene::SceneNode* parent, DrawableGroup* drawables) -> bool
Load a SUNCG mesh into assets from a file. !Deprecated! TODO: remove?
void initDefaultLightSetups()
initialize default lighting setups in the current ShaderManager
void initDefaultMaterials()
initialize default material setups in the current ShaderManager
auto isLightSetupCompatible(const LoadedAssetData& loadedAssetData, const Magnum::ResourceKey& lightSetup) const -> bool
Checks if light setup is compatible with loaded asset.
void translateMesh(BaseMesh* meshDataGL, Magnum::Vector3 translation)
Apply a translation to the vertices of a mesh asset and store that transformation in BaseMesh::meshTransform_.
auto computeMeshBB(BaseMesh* meshDataGL) -> Magnum::Range3D
Compute and return the axis aligned bounding box of a mesh in mesh local space.
void computeGeneralMeshAbsoluteAABBs()
Compute the absolute AABBs for drawables in PTex mesh in world space.
void computeInstanceMeshAbsoluteAABBs()
Compute the absolute AABBs for drawables in semantic mesh in world space.
auto computeAbsoluteTransformations() -> std::vector<Magnum::Matrix4>
Compute absolute transformations of all drwables stored in staticDrawableInfo_.
void addMeshToDrawables(const MeshMetaData& metaData, scene::SceneNode& node, const Magnum::ResourceKey& lightSetup, DrawableGroup* drawables, int objectID, int meshIDLocal, int materialIDLocal)
Creates a new gfx::Drawable for a mesh and adds it to the scene graph scene::SceneNode.
void createGenericDrawable(Magnum::GL::Mesh& mesh, scene::SceneNode& node, const Magnum::ResourceKey& lightSetup, const Magnum::ResourceKey& material, DrawableGroup* group = nullptr, int objectId = ID_UNDEFINED)
Create a gfx::Drawable for the specified mesh, node, and ShaderType.

Protected variables

std::vector<StaticDrawableInfo> staticDrawableInfo_
this helper vector contains information of the drawables on which we will compute the absolute AABB pair
bool computeAbsoluteAABBs_
std::vector<std::shared_ptr<BaseMesh>> meshes_
The mesh data for loaded assets.
std::vector<std::shared_ptr<Magnum::GL::Texture2D>> textures_
The texture data for loaded assets.
int nextMaterialID_
The next available unique ID for loaded materials.
Magnum::GL::Mesh* instance_mesh_
A pointer to render mesh data for the most recently loaded instance mesh. //TODO: remove? doesn't seem to be used anywhere.
std::map<std::string, LoadedAssetData> resourceDict_
Asset metadata linking meshes, textures, materials, and the component transformation heirarchy for loaded assets.
gfx::ShaderManager shaderManager_
The ShaderManager used to store shader information for drawables created by this ResourceManager.
std::map<std::string, PhysicsObjectAttributes::ptr> physicsObjTemplateLibrary_
Maps string keys (typically property filenames) to physical object templates.
std::map<std::string, PhysicsSceneAttributes::ptr> physicsSceneLibrary_
Maps string keys (typically property filenames) to physical scene templates.
std::map<std::string, PhysicsManagerAttributes::ptr> physicsManagerLibrary_
Library of physics scene attributes for initializing/resetting/switching physics world contexts.
std::vector<std::unique_ptr<Magnum::GL::Mesh>> primitive_meshes_
Primitive meshes available for instancing via addPrimitiveToDrawables for debugging or visualization purposes.
std::map<std::string, std::vector<CollisionMeshData>> collisionMeshGroups_
Maps string keys (typically property filenames) to CollisionMeshData for all components of a loaded asset.
std::map<int, std::string> physicsObjTmpltLibByID_
Maps object template ID to object template file names.
bool compressTextures_
Flag to denote the desire to compress textures. TODO: unused?

Function documentation

void esp::assets::ResourceManager::compressTextures(bool newVal)

Set whether textures should be compressed.

Parameters
newVal New texture compression setting.

bool esp::assets::ResourceManager::loadScene(const AssetInfo& info, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{NO_LIGHT_KEY}, bool splitSemanticMesh = true)

Load a scene mesh and add it to the specified DrawableGroup as a child of the specified scene::SceneNode.

Parameters
info The loaded AssetInfo for the scene mesh.
parent The scene::SceneNode of which the scene mesh will be added as a child. Typically near the root of the scene. Expected to be static.
drawables The DrawableGroup with which the scene mesh will be rendered.
lightSetup The LightSetup used for scene lighting
splitSemanticMesh Split the semantic mesh by objectID, used for A/B testing
Returns Whether or not the scene load succeeded.

If parent and drawables are not specified, the assets are loaded, but no new gfx::Drawable is added for the scene (i.e. it will not be rendered).

bool esp::assets::ResourceManager::loadScene(const AssetInfo& info, std::shared_ptr<physics::PhysicsManager>& _physicsManager, PhysicsManagerAttributes::ptr physicsManagerAttributes, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{ NO_LIGHT_KEY})

Load and instantiate a scene including physics simulation.

Parameters
info The loaded AssetInfo for the scene mesh.
_physicsManager The currently defined physics::PhysicsManager. Will be reseated to the configured physics implementation.
physicsManagerAttributes A smart pointer to meta data structure storing configured physics simulation parameters.
parent The scene::SceneNode of which the scene mesh will be added as a child. Typically near the root of the scene. Expected to be static.
drawables The DrawableGroup with which the scene mesh will be rendered.
lightSetup
Returns Whether or not the scene load succeeded.

Loads a physics simulator for the world from the parameters defined in the PhysicsManagerAttributes and reseats the physics::PhysicsManager based on the configured simulator implementation. Loads the scene mesh and adds it to the specified DrawableGroup as a child of the specified scene::SceneNode. If these are not specified, the assets are loaded, but no new gfx::Drawable is added for the scene (i.e. it will not be rendered).

bool esp::assets::ResourceManager::loadScene(const AssetInfo& info, std::shared_ptr<physics::PhysicsManager>& _physicsManager, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{NO_LIGHT_KEY}, std::string physicsFilename = ESP_DEFAULT_PHYS_SCENE_CONFIG)

Load and instantiate a scene including physics simulation.

Parameters
info The loaded AssetInfo for the scene mesh.
_physicsManager The currently defined physics::PhysicsManager. Will be reseated to the configured physics implementation.
parent The scene::SceneNode of which the scene mesh will be added as a child. Typically near the root of the scene. Expected to be static.
drawables The DrawableGroup with which the scene mesh will be rendered.
lightSetup
physicsFilename The physics configuration file from which to re-instatiate the physics::PhysicsManager and parse object templates for the physicsObjTemplateLibrary_. Defaults to the file location ESP_DEFAULT_PHYS_SCENE_CONFIG set by cmake.
Returns Whether or not the scene load succeeded.

Loads a physics simulator for the world from the parameters defined in the referenced configuration file. Also attempts to parse physical objects listed in this configuration file into the physicsObjTemplateLibrary_. Reseats the physics::PhysicsManager based on the configured simulator implementation. Loads the scene mesh and adds it to the specified DrawableGroup as a child of the specified scene::SceneNode. If these are not specified, the assets are loaded, but no new gfx::Drawable is added for the scene (i.e. it will not be rendered).

PhysicsManagerAttributes::ptr esp::assets::ResourceManager::loadPhysicsConfig(std::string physicsFilename = ESP_DEFAULT_PHYS_SCENE_CONFIG)

Parses global physics simulation parameters (such as timestep, gravity, simulator implementation) from the specified configuration file.

Parameters
physicsFilename The configuration file to parse. Defaults to the file location ESP_DEFAULT_PHYS_SCENE_CONFIG set by cmake.
Returns The physics simulation meta data object parsed from the specified configuration file.

std::vector<std::string> esp::assets::ResourceManager::getObjectConfigPaths(std::string path)

Get all "*.phys_properties.json" files from the provided file or directory path.

Parameters
path A global path to a physics property file or directory
Returns A list of valid global paths to "*.phys_properties.json" files.

void esp::assets::ResourceManager::addObjectToDrawables(int objTemplateLibID, scene::SceneNode* parent, DrawableGroup* drawables, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{DEFAULT_LIGHTING_KEY})

Add an object from a spcified configuration file to the specified DrawableGroup as a child of the specified scene::SceneNode if provided.

Parameters
objTemplateLibID The ID of the configuration file to parse and load. This is expected to exist.
parent The scene::SceneNode of which the object will be a child.
drawables The DrawableGroup with which the object gfx::Drawable will be rendered.
lightSetup

If the attributes specified by objTemplateID exists in physicsObjTemplateLibrary_, and both parent and drawables are specified, than an object referenced by that key is added to the scene.

int esp::assets::ResourceManager::parseAndLoadPhysObjTemplate(const std::string& objPhysConfigFilename)

Load and parse a physics object template config file and generates a PhysicsObjectAttributes object, adding it to the physicsObjTemplateLibrary_.

Parameters
objPhysConfigFilename The configuration file to parse and load.
Returns The index in the physicsObjTemplateLibrary_ to which the key, objPhysConfigFilename, referes. Can be used to reference the object template, but can change if the physicsObjTemplateLibrary_ is modified.

int esp::assets::ResourceManager::loadObjectTemplate(PhysicsObjectAttributes::ptr objectTemplate, const std::string objectTemplateHandle)

Add a PhysicsObjectAttributes object to the physicsObjTemplateLibrary_.

Parameters
objectTemplate The object template.
objectTemplateHandle The key for referencing the template in the physicsObjTemplateLibrary_.
Returns The index in the physicsObjTemplateLibrary_ of object template.

Can modify template values based on results of load.

const std::vector<assets::CollisionMeshData>& esp::assets::ResourceManager::getCollisionMesh(const std::string configFile)

Getter for all assets::CollisionMeshData associated with the particular asset referenced by the key, configFile.

Parameters
configFile The key by which the asset is referenced in collisionMeshGroups_ and the physicsObjTemplateLibrary_.
Returns A vector reference to assets::CollisionMeshData instances for individual components of the asset.

const std::vector<assets::CollisionMeshData>& esp::assets::ResourceManager::getCollisionMesh(const int objectTemplateID)

Getter for all assets::CollisionMeshData associated with the particular asset referenced by the index, objectTemplateID, in physicsObjTemplateLibrary_.

Parameters
objectTemplateID The index of the object template in physicsObjTemplateLibrary_.
Returns A vector reference to assets::CollisionMeshData instances for individual components of the asset.

int esp::assets::ResourceManager::getObjectTemplateID(const std::string& configFile)

Get the index in physicsObjTemplateLibrary_ for the object template asset identified by the key, configFile.

Parameters
configFile The key referencing the asset in physicsObjTemplateLibrary_.
Returns The index of the object template in physicsObjTemplateLibrary_.

std::string esp::assets::ResourceManager::getObjectConfig(const int objectTemplateID)

Get the key in physicsObjTemplateLibrary_ for the object template asset index.

Parameters
objectTemplateID The index of the object template in physicsObjTemplateLibrary_.
Returns The key referencing the asset in physicsObjTemplateLibrary_.

PhysicsObjectAttributes::ptr esp::assets::ResourceManager::getPhysicsObjectAttributes(const std::string& configFile)

Get a reference to the physics object template for the asset identified by the key, configFile. physicsObjTemplateLibrary_.

Parameters
configFile The key referencing the asset in physicsObjTemplateLibrary_.
Returns A mutable reference to the object template for the asset.

Can be used to manipulate an object template before instancing new objects.

PhysicsObjectAttributes::ptr esp::assets::ResourceManager::getPhysicsObjectAttributes(const int objectTemplateID)

Get a reference to the physics object template for the asset identified by the objectTemplateID.

Returns A mutable reference to the object template for the asset.

Can be used to manipulate an object template before instancing new objects.

int esp::assets::ResourceManager::getNumLibraryObjects()

Gets the number of object templates stored in the physicsObjTemplateLibrary_.

Returns The size of the physicsObjTemplateLibrary_.

const Magnum::Matrix4& esp::assets::ResourceManager::getMeshTransformation(const size_t meshIndex)

Retrieve the composition of all transforms applied to a mesh since it was loaded.

Parameters
meshIndex Index of the mesh in meshes_.
Returns The transformation matrix mapping from the original state to its current state.

See translateMesh.

const MeshMetaData& esp::assets::ResourceManager::getMeshMetaData(const std::string& filename) const

Retrieve the meta data for a particular asset.

Parameters
filename The key identifying the asset in resourceDict_. Typically the filepath of the asset.
Returns The asset's MeshMetaData object.

This includes identifiers for meshes, textures, materials, and a component heirarchy.

std::unique_ptr<MeshData> esp::assets::ResourceManager::createJoinedCollisionMesh(const std::string& filename)

Construct a unified MeshData from a loaded asset's collision meshes.

Parameters
filename The identifying string key for the asset. See resourceDict_ and meshes_.
Returns The unified MeshData object for the asset.

See joinHeirarchy.

void esp::assets::ResourceManager::addPrimitiveToDrawables(int primitiveID, scene::SceneNode& node, DrawableGroup* drawables)

Create a new drawable primitive attached to the desired scene::SceneNode.

Parameters
primitiveID The index of the primitive in primitive_meshes_.
node The scene::SceneNode to which the primitive drawable will be attached.
drawables The DrawableGroup with which the primitive will be rendered.

See primitive_meshes_.

void esp::assets::ResourceManager::setLightSetup(gfx::LightSetup setup, const Magnum::ResourceKey& key = Magnum::ResourceKey{ DEFAULT_LIGHTING_KEY})

Set a named LightSetup.

Parameters
setup Light setup this key will now reference
key Key to identify this LightSetup

If this name already exists, the LightSetup is updated and all Drawables using this setup are updated.

int esp::assets::ResourceManager::loadNavMeshVisualization(esp::nav::PathFinder& pathFinder, scene::SceneNode* parent, DrawableGroup* drawables)

generate a new primitive mesh asset for the NavMesh loaded in the provided PathFinder object.

Parameters
pathFinder Holds the NavMesh information.
parent The new Drawable is attached to this node.
drawables The group with which the new Drawable will be rendered.
Returns The primitive ID of the new object or ID_UNDEFINED if construction failed.

If parent and drawables are provided, create the Drawable and render the NavMesh.

void esp::assets::ResourceManager::addComponent(const MeshMetaData& metaData, scene::SceneNode& parent, const Magnum::ResourceKey& lightSetup, DrawableGroup* drawables, const MeshTransformNode& meshTransformNode) protected

Recursive contruction of scene nodes for an asset.

Parameters
metaData The MeshMetaData object containing information about the meshes, textures, materials, and component heirarchy of the asset.
parent The scene::SceneNode of which the component will be a child.
lightSetup The LightSetup key that will be used for the added component.
drawables The DrawableGroup with which the component will be rendered.
meshTransformNode The MeshTransformNode for component identifying its mesh, material, transformation, and children.

Creates a drawable for the component of an asset referenced by the MeshTransformNode and adds it to the DrawableGroup as child of parent.

void esp::assets::ResourceManager::loadTextures(Importer& importer, LoadedAssetData& loadedAssetData) protected

Load textures from importer into assets, and update metaData for an asset to link textures to that asset.

Parameters
importer The importer already loaded with information for the asset.
loadedAssetData The asset's LoadedAssetData object.

void esp::assets::ResourceManager::loadMeshes(Importer& importer, LoadedAssetData& loadedAssetData) protected

Load meshes from importer into assets.

Parameters
importer The importer already loaded with information for the asset.
loadedAssetData The asset's LoadedAssetData object.

Compute bounding boxes, upload mesh data to GPU, and update metaData for an asset to link meshes to that asset.

void esp::assets::ResourceManager::loadMeshHierarchy(Importer& importer, MeshTransformNode& parent, int componentID) protected

Recursively parse the mesh component transformation heirarchy for the imported asset.

Parameters
importer The importer already loaded with information for the asset.
parent The root of the mesh transform heirarchy for the remaining sub-tree. The generated MeshTransformNode will be added as a child. Typically the MeshMetaData::root to begin recursion.
componentID The next component to add to the heirarchy. Identifies the component in the Importer.

void esp::assets::ResourceManager::joinHeirarchy(MeshData& mesh, const MeshMetaData& metaData, const MeshTransformNode& node, const Magnum::Matrix4& transformFromParentToWorld) protected

Recursively build a unified MeshData from loaded assets via a tree of MeshTransformNode.

Parameters
mesh The MeshData being constructed.
metaData The MeshMetaData for the object heirarchy being joined.
node The current MeshTransformNode in the recursion.
transformFromParentToWorld The cumulative transformation up to but not including the current MeshTransformNode.

void esp::assets::ResourceManager::loadMaterials(Importer& importer, LoadedAssetData& loadedAssetData) protected

Load materials from importer into assets, and update metaData for an asset to link materials to that asset.

Parameters
importer The importer already loaded with information for the asset.
loadedAssetData The asset's LoadedAssetData object.

gfx::PhongMaterialData::uptr esp::assets::ResourceManager::getFlatShadedMaterialData(const Magnum::Trade::PhongMaterialData& material, int textureBaseIndex) protected

Get a PhongMaterialData for use with flat shading.

Parameters
material Material data with texture IDs
textureBaseIndex Base index of the assets textures in textures_

Textures must already be loaded for the asset this material belongs to

gfx::PhongMaterialData::uptr esp::assets::ResourceManager::getPhongShadedMaterialData(const Magnum::Trade::PhongMaterialData& material, int textureBaseIndex) protected

Get a PhongMaterialData for use with phong shading.

Parameters
material Material data with texture IDs
textureBaseIndex Base index of the assets textures in textures_

Textures must already be loaded for the asset this material belongs to

bool esp::assets::ResourceManager::loadPTexMeshData(const AssetInfo& info, scene::SceneNode* parent, DrawableGroup* drawables) protected

Load a PTex mesh into assets from a file and add it to the scene graph for rendering.

Parameters
info The AssetInfo for the mesh, already parsed from a file.
parent The scene::SceneNode to which the mesh will be added as a child.
drawables The DrawableGroup with which the mesh will be rendered.

bool esp::assets::ResourceManager::loadInstanceMeshData(const AssetInfo& info, scene::SceneNode* parent, DrawableGroup* drawables, bool splitSemanticMesh = true) protected

Load an instance mesh (e.g. Matterport reconstruction) into assets from a file and add it to the scene graph for rendering.

Parameters
info The AssetInfo for the mesh, already parsed from a file.
parent The scene::SceneNode to which the mesh will be added as a child.
drawables The DrawableGroup with which the mesh will be rendered.
splitSemanticMesh

bool esp::assets::ResourceManager::loadGeneralMeshData(const AssetInfo& info, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, const Magnum::ResourceKey& lightSetup = Magnum::ResourceKey{NO_LIGHT_KEY}) protected

Load a mesh (e.g. gltf) into assets from a file.

Parameters
info The AssetInfo for the mesh, already parsed from a file.
parent The scene::SceneNode to which the mesh will be added as a child.
drawables The DrawableGroup with which the mesh will be rendered.
lightSetup

If both parent and drawables are provided, add the mesh to the scene graph for rendering.

bool esp::assets::ResourceManager::loadSUNCGHouseFile(const AssetInfo& info, scene::SceneNode* parent, DrawableGroup* drawables) protected

Load a SUNCG mesh into assets from a file. !Deprecated! TODO: remove?

Parameters
info The AssetInfo for the mesh, already parsed from a file.
parent The scene::SceneNode to which the mesh will be added as a child.
drawables The DrawableGroup with which the mesh will be rendered.

void esp::assets::ResourceManager::translateMesh(BaseMesh* meshDataGL, Magnum::Vector3 translation) protected

Apply a translation to the vertices of a mesh asset and store that transformation in BaseMesh::meshTransform_.

Parameters
meshDataGL The mesh data.
translation The translation transform to apply.

Magnum::Range3D esp::assets::ResourceManager::computeMeshBB(BaseMesh* meshDataGL) protected

Compute and return the axis aligned bounding box of a mesh in mesh local space.

Parameters
meshDataGL The mesh data.
Returns The mesh bounding box.

void esp::assets::ResourceManager::computeGeneralMeshAbsoluteAABBs() protected

Compute the absolute AABBs for drawables in PTex mesh in world space.

Compute the absolute AABBs for drawables in general mesh (e.g., MP3D) world space

void esp::assets::ResourceManager::addMeshToDrawables(const MeshMetaData& metaData, scene::SceneNode& node, const Magnum::ResourceKey& lightSetup, DrawableGroup* drawables, int objectID, int meshIDLocal, int materialIDLocal) protected

Creates a new gfx::Drawable for a mesh and adds it to the scene graph scene::SceneNode.

Parameters
metaData Object meta data for the asset this mesh is linked to.
node The scene::SceneNode which the new gfx::Drawable will be attached to.
lightSetup The LightSetup key that will be used for the added mesh.
drawables The DrawableGroup with which the new gfx::Drawable will be rendered.
objectID The object type identifier or semantic group (e.g. 1->chair, 2->table, etc..) for semantic rendering of the mesh.
meshIDLocal The index of the mesh within the mesh group linked to the asset via the MeshMetaData.
materialIDLocal The index of the material within the material group linked to the asset via the MeshMetaData.

void esp::assets::ResourceManager::createGenericDrawable(Magnum::GL::Mesh& mesh, scene::SceneNode& node, const Magnum::ResourceKey& lightSetup, const Magnum::ResourceKey& material, DrawableGroup* group = nullptr, int objectId = ID_UNDEFINED) protected

Create a gfx::Drawable for the specified mesh, node, and ShaderType.

Parameters
mesh The render mesh.
node The scene::SceneNode to which the drawable will be attached.
lightSetup The LightSetup key that will be used for the drawable.
material The MaterialData key that will be used for the drawable.
group Optional DrawableGroup with which the render the gfx::Drawable.
objectId Optional object type indentifier or semantic type for the mesh (e.g. 1->table, 2->chair, etc...).

Add this drawable to the DrawableGroup if provided.

Variable documentation

std::map<std::string, LoadedAssetData> esp::assets::ResourceManager::resourceDict_ protected

Asset metadata linking meshes, textures, materials, and the component transformation heirarchy for loaded assets.

Maps absolute path keys to metadata.

std::map<std::string, PhysicsObjectAttributes::ptr> esp::assets::ResourceManager::physicsObjTemplateLibrary_ protected

Maps string keys (typically property filenames) to physical object templates.

Templates are used by physics::PhysicsManager to instance new objects with common parameters. For example: "data/objects/cheezit.phys_properties.json" -> physicalMetaData

std::map<std::string, PhysicsSceneAttributes::ptr> esp::assets::ResourceManager::physicsSceneLibrary_ protected

Maps string keys (typically property filenames) to physical scene templates.

Templates are used by physics::PhysicsManager to initialize, reset scenes or switch contexts.

std::map<int, std::string> esp::assets::ResourceManager::physicsObjTmpltLibByID_ protected

Maps object template ID to object template file names.

See physicsObjTemplateLibrary_, collisionMeshGroups_. NOTE: can't get keys from the map (easily), so store them for iteration. TODO: remove this. Unnecessary: use an iterator to get the keys.