esp::metadata::MetadataMediator class

Constructors, destructors, conversion operators

MetadataMediator(const sim::SimulatorConfiguration& cfg) explicit
MetadataMediator()
~MetadataMediator() defaulted

Public functions

auto setSimulatorConfiguration(const sim::SimulatorConfiguration& cfg) -> bool
Set current esp::sim::SimulatorConfiguration to be used.
auto getSimulatorConfiguration() const -> const sim::SimulatorConfiguration&
Return the current esp::sim::SimulatorConfiguration this MetadataMediator is using. Used to build Simulator from existing MM.
auto createSceneDataset(const std::string& sceneDatasetName, bool overwrite = false) -> bool
Creates a dataset attributes using sceneDatasetName, and registers it. NOTE If an existing dataset attributes exists with this handle, then this will only overwrite this existing dataset if overwrite is set to true.
auto createPhysicsManagerAttributes(const std::string& _physicsManagerAttributesPath = ESP_DEFAULT_PHYSICS_CONFIG_REL_PATH) -> bool
Load a esp::metadata::attributes::PhysicsManagerAttributes defined by passed string file path.
auto createPbrAttributes(const std::string& _pbrConfigPath = ESP_DEFAULT_PBRSHADER_CONFIG_REL_PATH) -> bool
Load PBR/IBL shader configuration attributes defined by file at passed path.
auto setActiveSceneDatasetName(const std::string& sceneDatasetName) -> bool
Sets default dataset attributes, if it exists already. If it does not exist, it will attempt to load a dataset_config.json with the given name. If none exists it will create an "empty" dataset attributes and give it the passed name.
auto getActiveSceneDatasetName() const -> std::string
Returns the name of the current active dataset.
auto setCurrPhysicsAttributesHandle(const std::string& physicsManagerAttributesPath) -> bool
Sets desired esp::metadata::attributes::PhysicsManagerAttributes handle. Will load if does not exist.
auto getCurrPhysicsAttributesHandle() const -> std::string
Returns the name of the currently used esp::metadata::attributes::PhysicsManagerAttributes.
auto setCurrDefaultPbrAttributesHandle(const std::string& pbrShaderAttributesPath) -> bool
Sets the handle of the desired default esp::metadata::attributes::PbrShaderAttributes unless overridden in scene instances. Will load if does not exist.
auto getCurrDefaultPbrAttributesHandle() const -> std::string
Returns the name of the currently specified default esp::metadata::attributes::PbrShaderAttributes. This can be overridden on a per-scene instance basis.
auto getAssetAttributesManager() -> const managers::AssetAttributesManager::ptr&
Return manager for construction and access to asset attributes for current dataset.
auto getLightLayoutAttributesManager() -> const managers::LightLayoutAttributesManager::ptr&
Return manager for construction and access to object attributes for current dataset.
auto getAOAttributesManager() -> const managers::AOAttributesManager::ptr&
Return manager for construction and access to articulated object attributes for current dataset.
auto getObjectAttributesManager() -> const managers::ObjectAttributesManager::ptr&
Return manager for construction and access to object attributes for current dataset.
auto getPhysicsAttributesManager() const -> const managers::PhysicsAttributesManager::ptr&
Return manager for construction and access to physics world attributes.
auto getPbrShaderAttributesManager() const -> const managers::PbrShaderAttributesManager::ptr&
Return manager for PBR and IBL lighting configuration settings.
auto getSceneInstanceAttributesManager() -> const managers::SceneInstanceAttributesManager::ptr&
Return manager for construction and access to esp::attributes::SceneInstanceAttributes for current dataset.
auto getStageAttributesManager() -> const managers::StageAttributesManager::ptr&
Return manager for construction and access to stage attributes for current dataset.
auto getCurrentPhysicsManagerAttributes() -> attributes::PhysicsManagerAttributes::ptr
Return a copy of the current esp::metadata::attributes::PhysicsManagerAttributes.
auto getCurrentPbrConfiguration() -> attributes::PbrShaderAttributes::ptr
Return a copy of the currently specified PBR/IBL Shader configuration attributes.
auto getDefaultMaterialShaderType() -> attributes::ObjectInstanceShaderType
Retrieve the shader type to use for the various default materials.
auto getAllSceneInstanceHandles() -> std::vector<std::string>
Get a list of all scene instances available in the currently active dataset.
auto getAllStageAttributesHandles() -> std::vector<std::string>
Get a list of all stage attributes available in the currently active dataset. This is useful if current dataset does not have scene instances defined, and instead builds them on the fly for each stage.
auto getActiveNavmeshMap() -> std::map<std::string, std::string>
Return copy of map of current active dataset's navmesh handles.
auto getNavmeshPathByHandle(const std::string& navMeshHandle) -> std::string
Return the file path of the specified navmesh in the current active dataset.
auto getActiveSemanticSceneDescriptorMap() -> std::map<std::string, std::string>
Return copy of map of current active dataset's semantic scene descriptor handles.
auto getSemanticSceneDescriptorPathByHandle(const std::string& ssDescrHandle) -> std::string
Return the file path of the specified semantic scene descriptor in the current active dataset.
auto getSceneInstanceAttributesByName(const std::string& sceneName) -> attributes::SceneInstanceAttributes::ptr
Returns an appropriate esp::metadata::attributes::SceneInstanceAttributes corresponding to the passed sceneID/name. For back-compat, this function needs to manage various conditions pertaining to the passed name. It will always return a valid SceneInstanceAttributes for the current active dataset.
auto getNamedStageAttributesCopy(const std::string& stageAttrName) -> attributes::StageAttributes::ptr
Returns stage attributes corresponding to passed handle as substring. Assumes stage attributes with stageAttrName as substring exists in current dataset.
auto getNamedObjectAttributesCopy(const std::string& objAttrName) -> attributes::ObjectAttributes::ptr
Returns object attributes corresponding to passed handle as substring. Assumes object attributes with objAttrName as substring exists in current dataset.
auto getNamedLightSetup(const std::string& lightSetupName) -> esp::gfx::LightSetup
Returns a lightsetup object configured by the attributes whose handle contains the passed lightSetupName.
auto getStageAttrFullHandle(const std::string& stageAttrName) -> std::string
Returns stage attributes handle in dataset corresponding to passed name as substring. Assumes stage attributes with stageAttrName as substring exists in current dataset.
auto getObjAttrFullHandle(const std::string& objAttrName) -> std::string
Returns object attributes handle in dataset corresponding to passed name as substring. Assumes object attributes with objAttrName as substring exists in current dataset.
auto getArticulatedObjModelFullHandle(const std::string& artObjModelName) -> std::string
Returns articulated object model handle in dataset corresponding to passed name as substring. Assumes articulated object model with artObjModelName as substring exists in this dataset.
auto getArticulatedObjectModelFilenames() -> std::map<std::string, std::string>
This is to be deprecated. Provide a map of the articulated object model filenames (.urdf) that have been referenced in the Scene Dataset via paths, either .urdf or .json. To be removed in favor of directly accessing these values through the AOAttributesMaanager.
auto getLightSetupFullHandle(const std::string& lightSetupName) -> std::string
Returns the full name of the lightsetup attributes whose handle contains the passed lightSetupName.
auto removeSceneDataset(const std::string& sceneDatasetName) -> bool
Allow removal of the named esp::metadata::attributes::SceneDatasetAttributes. Will silently force removal of locked attributes. If datasetName references activeSceneDataset_ then will fail, returning false.
auto sceneDatasetExists(const std::string& sceneDatasetName) const -> bool
Checks if passed handle exists as scene dataset.
auto getCreateRenderer() const -> bool
Returns the createRenderer flag that was set in the associated esp::sim::SimulatorConfiguration.
auto getDatasetsOverview() const -> std::string
This function returns a list of all the scene datasets currently loaded, along with some key statistics for each, formatted as a comma-separated string.
auto createDatasetReport(const std::string& sceneDataset = "") const -> std::string
this function will create a report of the contents of the scene dataset with the passed name. If no name is provided, a report on the current active dataset will be returned.
auto getSceneInstanceUserConfiguration(const std::string& curSceneName) -> std::shared_ptr<esp::core::config::Configuration>
Return the root-level user defined attributes configuration for the specified scene instance.
auto getAllPbrShaderConfigs() const -> std::unordered_map<std::string, esp::metadata::attributes::PbrShaderAttributes::ptr>
Retrieve copies of all the esp::metadata::attributes::PbrShaderAttributes currently defined. These will be used to pre-load/pre-derive any BLUTs and IBL cubemaps used once on dataset load.
auto getPbrShaderConfig(const std::string& handle) const -> esp::metadata::attributes::PbrShaderAttributes::ptr
Retrieve a copy of the named esp::metadata::attributes::PbrShaderAttributes.
auto getPbrShaderConfigByRegion(const std::string& region) -> esp::metadata::attributes::PbrShaderAttributes::ptr
void setCurrScenePbrShaderRegionMap(std::map<std::string, std::string> mappings)
Set the current scene's mapping from 'region' tags to PbrShaderAttributes handles.
auto getDefaultPbrShaderConfig() const -> esp::metadata::attributes::PbrShaderAttributes::ptr
Retrieve a copy of the named esp::metadata::attributes::PbrShaderAttributes.
void setAllPbrShaderConfigIBLState(bool isIblEnabled)
This will set the IBL state for every configuration in the current pbrShaderAttributesManager_.

Protected functions

auto getFilePathForHandle(const std::string& assetHandle, const std::map<std::string, std::string>& assetMapping, const std::string& msgString) -> std::string
Return the file path corresponding to the passed handle in the current active dataset.
auto makeSceneAndReferenceStage(const attributes::SceneDatasetAttributes::ptr& datasetAttr, const attributes::StageAttributes::ptr& stageAttributes, const managers::SceneInstanceAttributesManager::ptr& dsSceneAttrMgr, const std::string& sceneName) -> attributes::SceneInstanceAttributes::ptr
This will create a new, empty esp::metadata::attributes::SceneInstanceAttributes with the passed name, and create a SceneObjectInstance for the stage also using the passed name. It is assuming that the dataset has the stage registered, and that the calling function will register the created SceneInstance with the dataset. This method will also register navmesh and scene descriptor file paths that are synthesized for newly made SceneInstanceAttributes. TODO: get rid of these fields in stageAttributes.
void buildAttributesManagers()
This function will build the esp::metadata::managers::PhysicsAttributesManager and esp::metadata::managers::SceneDatasetAttributesManager this mediator will manage. This should only be called from constructor or reset (TODO).
auto getActiveDSAttribs() -> attributes::SceneDatasetAttributes::ptr
Retrieve the current default dataset object. Currently only for internal use.

Protected variables

sim::SimulatorConfiguration simConfig_
Current Simulator Configuration. A copy (not a ref) so that it can exceed the lifespan of the source config from, for example, Simulator.
std::string activeSceneDataset_
String name of current, default dataset.
std::string currPhysicsManagerAttributes_
String name of current Physics Manager attributes.
std::string currDefaultPbrAttributesHandle_
String name of current default PBR/IBL Shader configuration attributes.
managers::SceneDatasetAttributesManager::ptr sceneDatasetAttributesManager_
Manages all construction and access to all scene dataset attributes. Users should never directly access this, or it could inadvertently get in a broken and unrecoverable state. All access to SceneDatasetAttributes should be currated/governed by MetadataMediator.
managers::PhysicsAttributesManager::ptr physicsAttributesManager_
Manages all construction and access to physics world attributes.
managers::PbrShaderAttributesManager::ptr pbrShaderAttributesManager_
Manages all PBR/IBL Shader configuration settings, independent of loaded datasets.

Function documentation

bool esp::metadata::MetadataMediator::setSimulatorConfiguration(const sim::SimulatorConfiguration& cfg)

Set current esp::sim::SimulatorConfiguration to be used.

Parameters
cfg Current configuration being used by Simulator.
Returns Whether config was set properly.

bool esp::metadata::MetadataMediator::createSceneDataset(const std::string& sceneDatasetName, bool overwrite = false)

Creates a dataset attributes using sceneDatasetName, and registers it. NOTE If an existing dataset attributes exists with this handle, then this will only overwrite this existing dataset if overwrite is set to true.

Parameters
sceneDatasetName The name of the dataset to load or create.
overwrite Whether to overwrite an existing dataset or not
Returns Whether a dataset with sceneDatasetName exists (either new or pre-existing).

bool esp::metadata::MetadataMediator::createPhysicsManagerAttributes(const std::string& _physicsManagerAttributesPath = ESP_DEFAULT_PHYSICS_CONFIG_REL_PATH)

Load a esp::metadata::attributes::PhysicsManagerAttributes defined by passed string file path.

Parameters
_physicsManagerAttributesPath The path to look for the physics config file.
Returns Whether a esp::metadata::attributes::PhysicsManagerAttributes exists based on the requested path, either new or pre-existing.

bool esp::metadata::MetadataMediator::createPbrAttributes(const std::string& _pbrConfigPath = ESP_DEFAULT_PBRSHADER_CONFIG_REL_PATH)

Load PBR/IBL shader configuration attributes defined by file at passed path.

Parameters
_pbrConfigPath The path to look for the PBR/IBL shader config file
Returns Whether successfully created a new PBR/IBL shader configuration attributes or not.

bool esp::metadata::MetadataMediator::setActiveSceneDatasetName(const std::string& sceneDatasetName)

Sets default dataset attributes, if it exists already. If it does not exist, it will attempt to load a dataset_config.json with the given name. If none exists it will create an "empty" dataset attributes and give it the passed name.

Parameters
sceneDatasetName the name of the existing dataset to use as default, or a json file describing the desired dataset attributes, or some handle to use for an empty dataset.
Returns whether successful or not

bool esp::metadata::MetadataMediator::setCurrPhysicsAttributesHandle(const std::string& physicsManagerAttributesPath)

Sets desired esp::metadata::attributes::PhysicsManagerAttributes handle. Will load if does not exist.

Parameters
physicsManagerAttributesPath The path to look for the physics config file.
Returns whether successful or not

bool esp::metadata::MetadataMediator::setCurrDefaultPbrAttributesHandle(const std::string& pbrShaderAttributesPath)

Sets the handle of the desired default esp::metadata::attributes::PbrShaderAttributes unless overridden in scene instances. Will load if does not exist.

Parameters
pbrShaderAttributesPath The path to look for the physics config file.
Returns whether successful or not

const managers::AssetAttributesManager::ptr& esp::metadata::MetadataMediator::getAssetAttributesManager()

Return manager for construction and access to asset attributes for current dataset.

Returns A shared pointer to the current dataset's esp::metadata::managers::AssetAttributesManager.

const managers::LightLayoutAttributesManager::ptr& esp::metadata::MetadataMediator::getLightLayoutAttributesManager()

Return manager for construction and access to object attributes for current dataset.

Returns A shared pointer to the current dataset's esp::metadata::managers::LightLayoutAttributesManager.

const managers::AOAttributesManager::ptr& esp::metadata::MetadataMediator::getAOAttributesManager()

Return manager for construction and access to articulated object attributes for current dataset.

Returns A shared pointer to the current dataset's esp::metadata::managers::AOAttributesManager.

const managers::ObjectAttributesManager::ptr& esp::metadata::MetadataMediator::getObjectAttributesManager()

Return manager for construction and access to object attributes for current dataset.

Returns A shared pointer to the current dataset's esp::metadata::managers::ObjectAttributesManager.

const managers::PhysicsAttributesManager::ptr& esp::metadata::MetadataMediator::getPhysicsAttributesManager() const

Return manager for construction and access to physics world attributes.

Returns A shared pointer to the current esp::metadata::managers::PhysicsAttributesManager.

const managers::SceneInstanceAttributesManager::ptr& esp::metadata::MetadataMediator::getSceneInstanceAttributesManager()

Return manager for construction and access to esp::attributes::SceneInstanceAttributes for current dataset.

Returns A shared pointer to the current dataset's managers::SceneInstanceAttributesManager or nullptr if no current dataset.

const managers::StageAttributesManager::ptr& esp::metadata::MetadataMediator::getStageAttributesManager()

Return manager for construction and access to stage attributes for current dataset.

Returns A shared pointer to the current dataset's esp::metadata::managers::StageAttributesManager

std::string esp::metadata::MetadataMediator::getNavmeshPathByHandle(const std::string& navMeshHandle)

Return the file path of the specified navmesh in the current active dataset.

Parameters
navMeshHandle The dataset library handle of the navmesh
Returns The file path of the navmesh.

std::string esp::metadata::MetadataMediator::getSemanticSceneDescriptorPathByHandle(const std::string& ssDescrHandle)

Return the file path of the specified semantic scene descriptor in the current active dataset.

Parameters
ssDescrHandle The dataset library handle of the semantic scene descriptor
Returns The file path of the semantic scene descriptor.

attributes::SceneInstanceAttributes::ptr esp::metadata::MetadataMediator::getSceneInstanceAttributesByName(const std::string& sceneName)

Returns an appropriate esp::metadata::attributes::SceneInstanceAttributes corresponding to the passed sceneID/name. For back-compat, this function needs to manage various conditions pertaining to the passed name. It will always return a valid SceneInstanceAttributes for the current active dataset.

Parameters
sceneName A string representation of the desired SceneInstanceAttributes. May only correspond to a stage on disk, in which case a new SceneInstanceAttributes will be constructed and properly populated with the appropriate data.
Returns A valid SceneInstanceAttributes - registered in current dataset, with all references also registered in current dataset.

attributes::StageAttributes::ptr esp::metadata::MetadataMediator::getNamedStageAttributesCopy(const std::string& stageAttrName)

Returns stage attributes corresponding to passed handle as substring. Assumes stage attributes with stageAttrName as substring exists in current dataset.

Parameters
stageAttrName substring to handle of stage instance attributes that exists in current active dataset. The attributes will be found via substring search, so the name is expected to be sufficiently restrictive to have exactly 1 match in dataset.
Returns smart pointer to stage attributes if exists, nullptr otherwise.

attributes::ObjectAttributes::ptr esp::metadata::MetadataMediator::getNamedObjectAttributesCopy(const std::string& objAttrName)

Returns object attributes corresponding to passed handle as substring. Assumes object attributes with objAttrName as substring exists in current dataset.

Parameters
objAttrName substring to handle of object instance attributes that exists in current active dataset. The attributes will be found via substring search, so the name is expected to be sufficiently restrictive to have exactly 1 match in dataset.
Returns smart pointer to object attributes if exists, nullptr otherwise.

esp::gfx::LightSetup esp::metadata::MetadataMediator::getNamedLightSetup(const std::string& lightSetupName)

Returns a lightsetup object configured by the attributes whose handle contains the passed lightSetupName.

Parameters
lightSetupName Name of the attributes to be used to build the lightsetup. The attributes will be found via substring search, so the name is expected to be sufficiently restrictive to have exactly 1 match in dataset.
Returns the lightsetup corresponding to lightSetupName.

std::string esp::metadata::MetadataMediator::getStageAttrFullHandle(const std::string& stageAttrName)

Returns stage attributes handle in dataset corresponding to passed name as substring. Assumes stage attributes with stageAttrName as substring exists in current dataset.

Parameters
stageAttrName substring to handle of stage instance attributes that exists in current active dataset. The attributes will be found via substring search, so the name is expected to be sufficiently restrictive to have exactly 1 match in dataset.
Returns name of stage attributes with handle containing stageAttrName , or empty string if none.

std::string esp::metadata::MetadataMediator::getObjAttrFullHandle(const std::string& objAttrName)

Returns object attributes handle in dataset corresponding to passed name as substring. Assumes object attributes with objAttrName as substring exists in current dataset.

Parameters
objAttrName substring to handle of object instance attributes that exists in current active dataset. The attributes will be found via substring search, so the name is expected to be sufficiently restrictive to have exactly 1 match in dataset.
Returns name of object attributes with handle containing objAttrName or empty string if none.

std::string esp::metadata::MetadataMediator::getArticulatedObjModelFullHandle(const std::string& artObjModelName)

Returns articulated object model handle in dataset corresponding to passed name as substring. Assumes articulated object model with artObjModelName as substring exists in this dataset.

Parameters
artObjModelName substring to handle of AO model that exists in this dataset. The actual model name will be found via substring search in the manager, so the name is expected to be sufficiently restrictive to have exactly 1 match in dataset.
Returns name of object attributes with handle containing artObjModelName or empty string if none.

std::string esp::metadata::MetadataMediator::getLightSetupFullHandle(const std::string& lightSetupName)

Returns the full name of the lightsetup attributes whose handle contains the passed lightSetupName.

Parameters
lightSetupName Name of the attributes desired. The attributes will be found via substring search, so the name is expected to be sufficiently restrictive to have exactly 1 match in dataset.
Returns name of light setup with handle containing lightSetupName or empty string if none.

bool esp::metadata::MetadataMediator::removeSceneDataset(const std::string& sceneDatasetName)

Allow removal of the named esp::metadata::attributes::SceneDatasetAttributes. Will silently force removal of locked attributes. If datasetName references activeSceneDataset_ then will fail, returning false.

Parameters
sceneDatasetName The name of the esp::metadata::attributes::SceneDatasetAttributes to remove.
Returns whether successful or not.

bool esp::metadata::MetadataMediator::sceneDatasetExists(const std::string& sceneDatasetName) const

Checks if passed handle exists as scene dataset.

Parameters
sceneDatasetName The name of the esp::metadata::attributes::SceneDatasetAttributes to check for.
Returns whether esp::metadata::attributes::SceneDatasetAttributes exists.

bool esp::metadata::MetadataMediator::getCreateRenderer() const

Returns the createRenderer flag that was set in the associated esp::sim::SimulatorConfiguration.

Returns the boolean flag.

std::string esp::metadata::MetadataMediator::getDatasetsOverview() const

This function returns a list of all the scene datasets currently loaded, along with some key statistics for each, formatted as a comma-separated string.

Returns a vector of strings holding scene dataset info.

std::string esp::metadata::MetadataMediator::createDatasetReport(const std::string& sceneDataset = "") const

this function will create a report of the contents of the scene dataset with the passed name. If no name is provided, a report on the current active dataset will be returned.

Parameters
sceneDataset The name of the scene dataset to perform the report on.
Returns Comma-separated string of data describing the desired dataset.

std::shared_ptr<esp::core::config::Configuration> esp::metadata::MetadataMediator::getSceneInstanceUserConfiguration(const std::string& curSceneName)

Return the root-level user defined attributes configuration for the specified scene instance.

Returns The scene instance user-defined configuration.

esp::metadata::attributes::PbrShaderAttributes::ptr esp::metadata::MetadataMediator::getPbrShaderConfig(const std::string& handle) const

Retrieve a copy of the named esp::metadata::attributes::PbrShaderAttributes.

Parameters
handle the name of the config we wish to retrieve, or the default if not found

std::string esp::metadata::MetadataMediator::getFilePathForHandle(const std::string& assetHandle, const std::map<std::string, std::string>& assetMapping, const std::string& msgString) protected

Return the file path corresponding to the passed handle in the current active dataset.

Parameters
assetHandle The dataset library handle of the desired asset
assetMapping The mappings to use to get the asset file path.
msgString A message string to describe any issues encountered, consisting of who called this function.
Returns The file path of the asset.

attributes::SceneInstanceAttributes::ptr esp::metadata::MetadataMediator::makeSceneAndReferenceStage(const attributes::SceneDatasetAttributes::ptr& datasetAttr, const attributes::StageAttributes::ptr& stageAttributes, const managers::SceneInstanceAttributesManager::ptr& dsSceneAttrMgr, const std::string& sceneName) protected

This will create a new, empty esp::metadata::attributes::SceneInstanceAttributes with the passed name, and create a SceneObjectInstance for the stage also using the passed name. It is assuming that the dataset has the stage registered, and that the calling function will register the created SceneInstance with the dataset. This method will also register navmesh and scene descriptor file paths that are synthesized for newly made SceneInstanceAttributes. TODO: get rid of these fields in stageAttributes.

Parameters
datasetAttr The current dataset attributes
stageAttributes Readonly version of stage to use to synthesize scene instance.
dsSceneAttrMgr The current dataset's SceneInstanceAttributesManager
sceneName The name for the scene and also the stage within the scene.
Returns The created SceneInstanceAttributes, with the stage's SceneInstanceObject to be intialized to reference the stage also named with sceneName .