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 = Mn::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 WHITE_MATERIAL_KEY constexpr
The ShaderManager key for full ambient white MaterialInfo used for primitive wire-meshes.
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 buildImportersAndAttributesManagers()
This function will build the various Importers and AttributesManagers used by the system.
void initDefaultPrimAttributes()
Build default primitive attribute files and synthesize an object of each type.
void initPhysicsManager(std::shared_ptr<physics::PhysicsManager>& physicsManager, bool isEnabled, scene::SceneNode* parent, const PhysicsManagerAttributes::ptr& physicsManagerAttributes)
Instantiate, or reinstantiate, PhysicsManager defined by passed attributes.
auto loadScene(const PhysicsSceneAttributes::ptr& sceneAttributes, std::shared_ptr<physics::PhysicsManager> _physicsManager, esp::scene::SceneManager* sceneManagerPtr, std::vector<int>& activeSceneIDs, bool createSemanticMesh) -> bool
Load a scene mesh and add it to the specified DrawableGroup as a child of the specified scene::SceneNode.
template<class T>
auto buildSceneCollisionMeshGroup(const std::string& filename, std::vector<CollisionMeshData>& meshGroup) -> bool
Construct scene collision mesh group based on name and type of scene.
auto instantiateAssetsOnDemand(const std::string& objTemplateHandle) -> bool
Load/instantiate any required render and collision assets for an object, if they do not already exist in resourceDict_ or collisionMeshGroups_, respectively. Assumes valid render and collisions asset handles have been specified (This is checked/verified in registerObjectTemplate())
auto getCollisionMesh(const std::string& collisionAssetHandle) const -> const std::vector<assets::CollisionMeshData>&
Getter for all assets::CollisionMeshData associated with the particular asset.
auto getAssetAttributesManager() const -> const managers::AssetAttributesManager::ptr
Return manager for construction and access to asset attributes.
auto getObjectAttributesManager() const -> const managers::ObjectAttributesManager::ptr
Return manager for construction and access to object attributes.
auto getPhysicsAttributesManager() const -> const managers::PhysicsAttributesManager::ptr
Return manager for construction and access to physics world attributes.
auto getSceneAttributesManager() const -> const managers::SceneAttributesManager::ptr
Return manager for construction and access to scene attributes.
auto getMeshTransformation(const size_t meshIndex) const -> const Mn::Matrix4&
Retrieve the composition of all transforms applied to a mesh since it was loaded.
auto getMeshMetaData(const std::string& metaDataName) const -> const MeshMetaData&
Retrieve the meta data for a particular asset.
auto getLightSetup(const Mn::ResourceKey& key = Mn::ResourceKey{DEFAULT_LIGHTING_KEY}) -> Mn::Resource<gfx::LightSetup>
Get a named LightSetup.
void setLightSetup(gfx::LightSetup setup, const Mn::ResourceKey& key = Mn::ResourceKey{ DEFAULT_LIGHTING_KEY})
Set a named LightSetup.
auto createJoinedCollisionMesh(const std::string& filename) -> std::unique_ptr<MeshData>
Construct a unified MeshData from a loaded asset's collision meshes.
void addObjectToDrawables(int objTemplateLibID, scene::SceneNode* parent, DrawableGroup* drawables, std::vector<scene::SceneNode*>& visNodeCache, const Mn::ResourceKey& lightSetup = Mn::ResourceKey{ DEFAULT_LIGHTING_KEY})
Add an object from a specified object template handle to the specified DrawableGroup as a child of the specified scene::SceneNode if provided.
void addObjectToDrawables(const std::string& objTemplateHandle, scene::SceneNode* parent, DrawableGroup* drawables, std::vector<scene::SceneNode*>& visNodeCache, const Mn::ResourceKey& lightSetup = Mn::ResourceKey{ DEFAULT_LIGHTING_KEY})
Add an object from a specified object template handle to the specified DrawableGroup as a child of the specified scene::SceneNode if provided.
void addPrimitiveToDrawables(int primitiveID, scene::SceneNode& node, DrawableGroup* drawables)
Create a new drawable primitive attached to the desired scene::SceneNode.
void removePrimitiveMesh(int primitiveID)
Remove the specified primitive mesh.
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.
auto buildFrameFromAttributes(const AbstractPhysicsAttributes::ptr& attribs, const Magnum::Vector3& origin) -> esp::geo::CoordinateFrame
Build a configuration frame from scene or object attributes values and return it.
void compressTextures(bool newVal)
Set whether textures should be compressed.

Protected types

struct LoadedAssetData
Data for a loaded asset.
struct StaticDrawableInfo
using Map_Of_PrimTypes = std::map<std::string, std::shared_ptr<esp::assets::AbstractPrimitiveAttributes> esp::assets::ResourceManager::*(const MeshMetaData&metaData, scene::SceneNode&parent, const Mn::ResourceKey&lightSetup, DrawableGroup*drawables, const MeshTransformNode&meshTransformNode, std::vector<scene::SceneNode*>&visNodeCache, bool computeAbsoluteAABBs, std::vector<StaticDrawableInfo>&staticDrawableInfo);void loadTextures(Importer&importer, LoadedAssetData&loadedAssetData
Define a map type referencing function pointers to createPrimitiveAttributes() keyed by string names of classes being instanced, as defined in PrimitiveNames3D.

Protected functions

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 Mn::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 buildFlatShadedMaterialData(const Mn::Trade::PhongMaterialData& material, int textureBaseIndex) -> gfx::PhongMaterialData::uptr
Build a PhongMaterialData for use with flat shading.
auto buildPhongShadedMaterialData(const Mn::Trade::PhongMaterialData& material, int textureBaseIndex) -> gfx::PhongMaterialData::uptr
Build a PhongMaterialData for use with phong shading.
auto loadSceneInternal(const AssetInfo& info, std::shared_ptr<physics::PhysicsManager> _physicsManager, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, bool computeAbsoluteAABBs = false, bool splitSemanticMesh = true, const Mn::ResourceKey& lightSetup = Mn::ResourceKey{NO_LIGHT_KEY}) -> bool
Load a mesh describing some scene asset based on the passed assetInfo.
auto createSceneAssetInfosFromAttributes(const PhysicsSceneAttributes::ptr& sceneAttributes, bool createCollisionInfo, bool createSemanticInfo) -> std::map<std::string, AssetInfo>
Creates a map of appropriate asset infos for scenes. Will always create render asset info. Will create collision asset info and semantic scene asset info if requested.
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 computeAbsoluteAABBs, bool splitSemanticMesh) -> 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, bool computeAbsoluteAABBs = false, const Mn::ResourceKey& lightSetup = Mn::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 Mn::ResourceKey& lightSetup) const -> bool
Checks if light setup is compatible with loaded asset.
void translateMesh(BaseMesh* meshDataGL, Mn::Vector3 translation)
Apply a translation to the vertices of a mesh asset and store that transformation in BaseMesh::meshTransform_.
auto computeMeshBB(BaseMesh* meshDataGL) -> Mn::Range3D
Compute and return the axis aligned bounding box of a mesh in mesh local space.
void computeGeneralMeshAbsoluteAABBs(const std::vector<StaticDrawableInfo>& staticDrawableInfo)
Compute the absolute AABBs for drawables in PTex mesh in world space.
void computeInstanceMeshAbsoluteAABBs(const std::vector<StaticDrawableInfo>& staticDrawableInfo)
Compute the absolute AABBs for drawables in semantic mesh in world space.
auto computeAbsoluteTransformations(const std::vector<StaticDrawableInfo>& staticDrawableInfo) -> std::vector<Mn::Matrix4>
Compute absolute transformations of all drwables stored in staticDrawableInfo_.
void createGenericDrawable(Mn::GL::Mesh& mesh, scene::SceneNode& node, const Mn::ResourceKey& lightSetup, const Mn::ResourceKey& material, DrawableGroup* group = nullptr)
Create a gfx::Drawable for the specified mesh, node, and ShaderType.

Protected variables

std::vector<std::shared_ptr<BaseMesh>> meshes_
The mesh data for loaded assets.
std::vector<std::shared_ptr<Mn::GL::Texture2D>> textures_
The texture data for loaded assets.
int nextMaterialID_
The next available unique ID for loaded materials.
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.
Corrade::PluginManager::Manager<Importer> importerManager_
Plugin Manager used to instantiate importers which in turn are used to load asset data.
Corrade::Containers::Pointer<Importer> primitiveImporter_
Importer used to synthesize Magnum Primitives (PrimitiveImporter). This object allows for similar usage to File-based importers, but requires no file to be available/read.
Corrade::Containers::Pointer<Importer> fileImporter_
Importer used to load generic mesh files (AnySceneImporter)
managers::AssetAttributesManager::ptr assetAttributesManager_
Manages all construction and access to asset attributes.
managers::ObjectAttributesManager::ptr objectAttributesManager_
Manages all construction and access to object attributes.
managers::PhysicsAttributesManager::ptr physicsAttributesManager_
Manages all construction and access to physics world attributes.
managers::SceneAttributesManager::ptr sceneAttributesManager_
Manages all construction and access to scene attributes.
int nextPrimitiveMeshId
tracks primitive mesh ids
std::map<int, std::unique_ptr<Mn::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.
bool compressTextures_
Flag to denote the desire to compress textures. TODO: unused?

Function documentation

void esp::assets::ResourceManager::initPhysicsManager(std::shared_ptr<physics::PhysicsManager>& physicsManager, bool isEnabled, scene::SceneNode* parent, const PhysicsManagerAttributes::ptr& physicsManagerAttributes)

Instantiate, or reinstantiate, PhysicsManager defined by passed attributes.

Parameters
physicsManager The currently defined physics::PhysicsManager. Will be reseated to the specified physics implementation.
isEnabled Whether this PhysicsManager is enabled or not. Takes the place of old checks for nullptr.
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.
physicsManagerAttributes A smart pointer to meta data structure storing configured physics simulation parameters.

bool esp::assets::ResourceManager::loadScene(const PhysicsSceneAttributes::ptr& sceneAttributes, std::shared_ptr<physics::PhysicsManager> _physicsManager, esp::scene::SceneManager* sceneManagerPtr, std::vector<int>& activeSceneIDs, bool createSemanticMesh)

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

Parameters
sceneAttributes The PhysicsSceneAttributes that describes the scene
_physicsManager The currently defined physics::PhysicsManager.
sceneManagerPtr Pointer to scene manager, to fetch drawables and parent node.
activeSceneIDs
createSemanticMesh If the semantic mesh should be created, based on SimulatorConfiguration
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).

template<class T>
bool esp::assets::ResourceManager::buildSceneCollisionMeshGroup(const std::string& filename, std::vector<CollisionMeshData>& meshGroup)

Construct scene collision mesh group based on name and type of scene.

Template parameters
T type of meshdata desired based on scene type.
Parameters
filename The name of the file holding the mesh data
meshGroup The meshgroup to build
Returns whether built successfully or not

bool esp::assets::ResourceManager::instantiateAssetsOnDemand(const std::string& objTemplateHandle)

Load/instantiate any required render and collision assets for an object, if they do not already exist in resourceDict_ or collisionMeshGroups_, respectively. Assumes valid render and collisions asset handles have been specified (This is checked/verified in registerObjectTemplate())

Returns whether process succeeded or not - only currently fails if registration call fails.

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

Getter for all assets::CollisionMeshData associated with the particular asset.

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

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

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& metaDataName) const

Retrieve the meta data for a particular asset.

Parameters
metaDataName The key identifying the asset in resourceDict_. Typically the filepath of file-based assets.
Returns The asset's MeshMetaData object.

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

void esp::assets::ResourceManager::setLightSetup(gfx::LightSetup setup, const Mn::ResourceKey& key = Mn::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.

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::addObjectToDrawables(int objTemplateLibID, scene::SceneNode* parent, DrawableGroup* drawables, std::vector<scene::SceneNode*>& visNodeCache, const Mn::ResourceKey& lightSetup = Mn::ResourceKey{ DEFAULT_LIGHTING_KEY})

Add an object from a specified object template handle to the specified DrawableGroup as a child of the specified scene::SceneNode if provided.

Parameters
objTemplateLibID The ID of the object attributes in the physicsObjTemplateLibrary_. 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.
visNodeCache out Cache for pointers to all nodes created as the result of this process.
lightSetup The LightSetup key that will be used for the added component.

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.

void esp::assets::ResourceManager::addObjectToDrawables(const std::string& objTemplateHandle, scene::SceneNode* parent, DrawableGroup* drawables, std::vector<scene::SceneNode*>& visNodeCache, const Mn::ResourceKey& lightSetup = Mn::ResourceKey{ DEFAULT_LIGHTING_KEY})

Add an object from a specified object template handle to the specified DrawableGroup as a child of the specified scene::SceneNode if provided.

Parameters
objTemplateHandle The key of the attributes in the to parse and load. The attributes are expected to exist but will be created (in the case of synthesized objects) if it does not.
parent The scene::SceneNode of which the object will be a child.
drawables The DrawableGroup with which the object gfx::Drawable will be rendered.
visNodeCache out Cache for pointers to all nodes created as the result of this process.
lightSetup The LightSetup key that will be used for the added component.

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

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 key 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::removePrimitiveMesh(int primitiveID)

Remove the specified primitive mesh.

Parameters
primitiveID The key of the primitive in primitive_meshes_.

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.

esp::geo::CoordinateFrame esp::assets::ResourceManager::buildFrameFromAttributes(const AbstractPhysicsAttributes::ptr& attribs, const Magnum::Vector3& origin)

Build a configuration frame from scene or object attributes values and return it.

Parameters
attribs the attributes to query for the information.
origin Either the origin of the sceneAttributes or the COM value of the objectAttributes.
Returns the coordinate frame of the assets the passed attributes describes.

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

Set whether textures should be compressed.

Parameters
newVal New texture compression setting.

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 Mn::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::buildFlatShadedMaterialData(const Mn::Trade::PhongMaterialData& material, int textureBaseIndex) protected

Build 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::buildPhongShadedMaterialData(const Mn::Trade::PhongMaterialData& material, int textureBaseIndex) protected

Build 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::loadSceneInternal(const AssetInfo& info, std::shared_ptr<physics::PhysicsManager> _physicsManager, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, bool computeAbsoluteAABBs = false, bool splitSemanticMesh = true, const Mn::ResourceKey& lightSetup = Mn::ResourceKey{NO_LIGHT_KEY}) protected

Load a mesh describing some scene asset based on the passed assetInfo.

Parameters
info The AssetInfo for the mesh, already parsed from a file.
_physicsManager
parent The scene::SceneNode to which the mesh will be added as a child.
drawables The DrawableGroup with which the mesh will be rendered.
computeAbsoluteAABBs Whether absolute bounding boxes should be computed
splitSemanticMesh Split the semantic mesh by objectID, used for A/B testing
lightSetup The LightSetup key that will be used for the loaded asset.

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

std::map<std::string, AssetInfo> esp::assets::ResourceManager::createSceneAssetInfosFromAttributes(const PhysicsSceneAttributes::ptr& sceneAttributes, bool createCollisionInfo, bool createSemanticInfo) protected

Creates a map of appropriate asset infos for scenes. Will always create render asset info. Will create collision asset info and semantic scene asset info if requested.

Parameters
sceneAttributes The scene attributes file holding the scene's information.
createCollisionInfo Whether collision-based asset info should be created (only if physicsManager != nullptr)
createSemanticInfo Whether semantic mesh-based asset info should be created

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.
Returns true if the mesh is loaded, otherwise false

bool esp::assets::ResourceManager::loadInstanceMeshData(const AssetInfo& info, scene::SceneNode* parent, DrawableGroup* drawables, bool computeAbsoluteAABBs, bool splitSemanticMesh) 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.
computeAbsoluteAABBs Whether absolute bounding boxes should be computed
splitSemanticMesh Split the semantic mesh by objectID

bool esp::assets::ResourceManager::loadGeneralMeshData(const AssetInfo& info, scene::SceneNode* parent = nullptr, DrawableGroup* drawables = nullptr, bool computeAbsoluteAABBs = false, const Mn::ResourceKey& lightSetup = Mn::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.
computeAbsoluteAABBs Whether absolute bounding boxes should be computed
lightSetup The LightSetup key that will be used for the loaded asset.

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, Mn::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.

Mn::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(const std::vector<StaticDrawableInfo>& staticDrawableInfo) 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::createGenericDrawable(Mn::GL::Mesh& mesh, scene::SceneNode& node, const Mn::ResourceKey& lightSetup, const Mn::ResourceKey& material, DrawableGroup* group = nullptr) 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.

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.