class
ObjectAttributesManagersingle instance class managing templates describing physical objects
Contents
Base classes
-
template<class AttribsPtr>class AttributesManager
- Template Class defining responsibilities for managing attributes for different types of objects, such as scenes, primitive assets, physical objects, etc.
Constructors, destructors, conversion operators
-
ObjectAttributesManager(assets::
ResourceManager& resourceManager)
Public functions
- void setAssetAttributesManager(AssetAttributesManager::cptr assetAttributesMgr)
-
auto createAttributesTemplate(const std::
string& attributesTemplateHandle, bool registerTemplate = true) -> PhysicsObjectAttributes::ptr override - Creates an instance of an object template. The passed string should be either a file name or a reference to a primitive asset template that should be used in the construction of the object; any other strings will result in a new default template being created.
-
auto createDefaultAttributesTemplate(const std::
string& templateName, bool registerTemplate = false) -> PhysicsObjectAttributes::ptr override - Creates an instance of an empty object template populated with default values. Assigns the templateName as the template's handle and as the renderAssetHandle.
-
auto createPrimBasedAttributesTemplate(const std::
string& primAttrTemplateHandle, bool registerTemplate = true) -> PhysicsObjectAttributes::ptr - Creates an instance of an object template described by passed string, which should be a reference to an existing primitive asset template to be used in the construction of the object (as render and collision mesh). It returns created instance if successful, and nullptr if fails.
-
auto createFileBasedAttributesTemplate(const std::
string& filename, bool registerTemplate = true) -> PhysicsObjectAttributes::ptr - Creates an instance of a template from a JSON file using passed filename by loading and parsing the loaded JSON and generating a PhysicsObjectAttributes object. It returns created instance if successful, and nullptr if fails.
-
auto loadObjectConfigs(const std::
string& path, bool saveAsDefaults = false) -> std:: vector<int> - Load file-based object templates for all "*.phys_properties.json" files from the provided file or directory path.
-
auto loadAllFileBasedTemplates(const std::
vector<std:: string>& tmpltFilenames, bool saveAsDefaults) -> std:: vector<int> - Load all file-based object templates given string list of object template file locations.
-
auto isValidPrimitiveAttributes(const std::
string& handle) -> bool - Check if currently configured primitive asset template library has passed handle.
- auto getNumFileTemplateObjects() const -> int
- Gets the number of file-based loaded object templates stored in the physicsObjTemplateLibrary_.
-
auto getRandomFileTemplateHandle() const -> std::
string - Get a random loaded attribute handle for the loaded file-based object templates.
-
auto getFileTemplateHandlesBySubstring(const std::
string& subStr = "", bool contains = true) const -> std:: vector<std:: string> - Get a list of all file-based templates whose origin handles contain subStr, ignoring subStr's case.
- auto getNumSynthTemplateObjects() const -> int
- Gets the number of synthesized (primitive-based) template objects stored in the physicsObjTemplateLibrary_.
-
auto getRandomSynthTemplateHandle() const -> std::
string - Get a random loaded attribute handle for the loaded synthesized (primitive-based) object templates.
-
auto getSynthTemplateHandlesBySubstring(const std::
string& subStr = "", bool contains = true) const -> std:: vector<std:: string> - Get a list of all synthesized (primitive-based) object templates whose origin handles contain subStr, ignoring subStr's case.
Protected functions
- void createDefaultPrimBasedAttributesTemplates()
- Create and save default primitive asset-based object templates, saving their handles as non-deletable default handles.
-
void setDefaultFileNameBasedAttributes(PhysicsObjectAttributes::ptr attributes,
bool setFrame,
const std::
string& meshHandle, std:: function<void(int)> meshTypeSetter) override - Perform file-name-based attributes initialization. This is to take the place of the AssetInfo::fromPath functionality, and is only intended to provide default values and other help if certain mistakes are made by the user, such as specifying an asset handle in json but not specifying the asset type corresponding to that handle. These settings should not restrict anything, only provide defaults.
- auto initNewAttribsInternal(PhysicsObjectAttributes::ptr newAttributes) -> PhysicsObjectAttributes::ptr override
- Used Internally. Configure newly-created attributes with any default values, before any specific values are set.
-
void updateTemplateHandleLists(int templateID,
CORRADE_
UNUSED const std:: string& templateHandle) override - This method will perform any necessary updating that is attributesManager-specific upon template removal, such as removing a specific template handle from the list of file-based template handles in ObjectAttributesManager. This should only be called internally.
-
auto registerAttributesTemplateFinalize(PhysicsObjectAttributes::ptr attributesTemplate,
const std::
string& attributesTemplateHandle) -> int override - Add a copy of AbstractAttributes object to the templateLibrary_
. Verify that render and collision handles have been set properly. We are doing this since these values can be modified by the user. - void resetFinalize() override
- Any object-attributes-specific resetting that needs to happen on reset.
- void buildCtorFuncPtrMaps() override
- This function will assign the appropriately configured function pointer for the copy constructor as defined in AttributesManager<PhysicsObjectAttributes::ptr>
Protected variables
- AssetAttributesManager::cptr assetAttributesMgr_
- Reference to AssetAttributesManager to give access to primitive attributes for object construction.
-
std::
map<int, std:: string> physicsFileObjTmpltLibByID_ - Maps loaded object template IDs to the appropriate template handles.
-
std::
map<int, std:: string> physicsSynthObjTmpltLibByID_ - Maps synthesized, primitive-based object template IDs to the appropriate template handles.
Function documentation
PhysicsObjectAttributes::ptr esp:: assets:: managers:: ObjectAttributesManager:: createAttributesTemplate(const std:: string& attributesTemplateHandle,
bool registerTemplate = true) override
Creates an instance of an object template. The passed string should be either a file name or a reference to a primitive asset template that should be used in the construction of the object; any other strings will result in a new default template being created.
Parameters | |
---|---|
attributesTemplateHandle | the origin of the desired template to be created, either a file name or an existing primitive asset template. If this is neither a recognized file name nor the handle of an existing primitive asset, a new default template will be created. |
registerTemplate | whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to true. If specified as true, then this function returns a copy of the registered template. |
Returns | a reference to the desired template. |
If a template exists with this handle, this existing template will be overwritten with the newly created one if registerTemplate is true.
PhysicsObjectAttributes::ptr esp:: assets:: managers:: ObjectAttributesManager:: createDefaultAttributesTemplate(const std:: string& templateName,
bool registerTemplate = false) override
Creates an instance of an empty object template populated with default values. Assigns the templateName as the template's handle and as the renderAssetHandle.
Parameters | |
---|---|
templateName | The desired name for this template. |
registerTemplate | whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to false. If specified as true, then this function returns a copy of the registered template. |
Returns | a reference to the desired template, or nullptr if fails. |
If a template exists with this handle, the existing template will be overwritten with the newly created one if registerTemplate is true. This method is specifically intended to directly construct an attributes template for editing, and so defaults to false for registerTemplate.
PhysicsObjectAttributes::ptr esp:: assets:: managers:: ObjectAttributesManager:: createPrimBasedAttributesTemplate(const std:: string& primAttrTemplateHandle,
bool registerTemplate = true)
Creates an instance of an object template described by passed string, which should be a reference to an existing primitive asset template to be used in the construction of the object (as render and collision mesh). It returns created instance if successful, and nullptr if fails.
Parameters | |
---|---|
primAttrTemplateHandle | The handle to an existing primitive asset template. Fails if does not. |
registerTemplate | whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to true. |
Returns | a reference to the desired template, or nullptr if fails. |
PhysicsObjectAttributes::ptr esp:: assets:: managers:: ObjectAttributesManager:: createFileBasedAttributesTemplate(const std:: string& filename,
bool registerTemplate = true)
Creates an instance of a template from a JSON file using passed filename by loading and parsing the loaded JSON and generating a PhysicsObjectAttributes object. It returns created instance if successful, and nullptr if fails.
Parameters | |
---|---|
filename | the name of the file describing the object attributes. Assumes it exists and fails if it does not. |
registerTemplate | whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to true. |
Returns | a reference to the desired template, or nullptr if fails. |
std:: vector<int> esp:: assets:: managers:: ObjectAttributesManager:: loadObjectConfigs(const std:: string& path,
bool saveAsDefaults = false)
Load file-based object templates for all "*.phys_properties.json" files from the provided file or directory path.
Parameters | |
---|---|
path | A global path to a physics property file or directory containing such files. |
saveAsDefaults | Set the templates loaded as undeleteable default templates. |
Returns | A list of template indices for loaded valid object configs |
This will take the passed path string and either treat it as a file name or a directory, depending on what is found in the filesystem. If path does not end with ".phys_properties.json", it will append this and check to see if such a file exists, and load it. It will also check if path exists as a directory, and if so will perform a shallow search to find any files ending in "*.phys_properties.json" and load those that are found.
std:: vector<int> esp:: assets:: managers:: ObjectAttributesManager:: loadAllFileBasedTemplates(const std:: vector<std:: string>& tmpltFilenames,
bool saveAsDefaults)
Load all file-based object templates given string list of object template file locations.
Parameters | |
---|---|
tmpltFilenames | list of file names of object templates |
saveAsDefaults | Set these templates as un-deletable from library. |
Returns | vector holding IDs of templates that have been added |
This will take the list of file names currently specified in physicsManagerAttributes and load the referenced object templates.
bool esp:: assets:: managers:: ObjectAttributesManager:: isValidPrimitiveAttributes(const std:: string& handle)
Check if currently configured primitive asset template library has passed handle.
Parameters | |
---|---|
handle | String name of primitive asset attributes desired |
Returns | whether handle exists or not in asset attributes library |
int esp:: assets:: managers:: ObjectAttributesManager:: getNumFileTemplateObjects() const
Gets the number of file-based loaded object templates stored in the physicsObjTemplateLibrary_.
Returns | The number of entries in physicsObjTemplateLibrary_ that are loaded from files. |
---|
std:: string esp:: assets:: managers:: ObjectAttributesManager:: getRandomFileTemplateHandle() const
Get a random loaded attribute handle for the loaded file-based object templates.
Returns | a randomly selected handle corresponding to a file-based object attributes template, or empty string if none loaded |
---|
std:: vector<std:: string> esp:: assets:: managers:: ObjectAttributesManager:: getFileTemplateHandlesBySubstring(const std:: string& subStr = "",
bool contains = true) const
Get a list of all file-based templates whose origin handles contain subStr, ignoring subStr's case.
Parameters | |
---|---|
subStr | substring to search for within existing file-based object templates |
contains | whether to search for keys containing, or not containing, subStr |
Returns | vector of 0 or more template handles containing the passed substring |
int esp:: assets:: managers:: ObjectAttributesManager:: getNumSynthTemplateObjects() const
Gets the number of synthesized (primitive-based) template objects stored in the physicsObjTemplateLibrary_.
Returns | The number of entries in physicsObjTemplateLibrary_ that describe primitives. |
---|
std:: string esp:: assets:: managers:: ObjectAttributesManager:: getRandomSynthTemplateHandle() const
Get a random loaded attribute handle for the loaded synthesized (primitive-based) object templates.
Returns | a randomly selected handle corresponding to the a primitive attributes template, or empty string if none loaded |
---|
std:: vector<std:: string> esp:: assets:: managers:: ObjectAttributesManager:: getSynthTemplateHandlesBySubstring(const std:: string& subStr = "",
bool contains = true) const
Get a list of all synthesized (primitive-based) object templates whose origin handles contain subStr, ignoring subStr's case.
Parameters | |
---|---|
subStr | substring to search for within existing primitive object templates |
contains | whether to search for keys containing, or not containing, subStr |
Returns | vector of 0 or more template handles containing the passed substring |
void esp:: assets:: managers:: ObjectAttributesManager:: setDefaultFileNameBasedAttributes(PhysicsObjectAttributes::ptr attributes,
bool setFrame,
const std:: string& meshHandle,
std:: function<void(int)> meshTypeSetter) override protected
Perform file-name-based attributes initialization. This is to take the place of the AssetInfo::fromPath functionality, and is only intended to provide default values and other help if certain mistakes are made by the user, such as specifying an asset handle in json but not specifying the asset type corresponding to that handle. These settings should not restrict anything, only provide defaults.
Parameters | |
---|---|
attributes | The AbstractPhysicsAttributes object to be configured |
setFrame | whether the frame should be set or not (only for render assets in scenes) |
meshHandle | |
meshTypeSetter | Setter for mesh type. |
PhysicsObjectAttributes::ptr esp:: assets:: managers:: ObjectAttributesManager:: initNewAttribsInternal(PhysicsObjectAttributes::ptr newAttributes) override protected
Used Internally. Configure newly-created attributes with any default values, before any specific values are set.
Parameters | |
---|---|
newAttributes | Newly created attributes. |
void esp:: assets:: managers:: ObjectAttributesManager:: updateTemplateHandleLists(int templateID,
CORRADE_ UNUSED const std:: string& templateHandle) override protected
This method will perform any necessary updating that is attributesManager-specific upon template removal, such as removing a specific template handle from the list of file-based template handles in ObjectAttributesManager. This should only be called internally.
Parameters | |
---|---|
templateID | the ID of the template to remove |
templateHandle | the string key of the attributes desired. |
int esp:: assets:: managers:: ObjectAttributesManager:: registerAttributesTemplateFinalize(PhysicsObjectAttributes::ptr attributesTemplate,
const std:: string& attributesTemplateHandle) override protected
Add a copy of AbstractAttributes object to the templateLibrary_
Parameters | |
---|---|
attributesTemplate | The attributes template. |
attributesTemplateHandle | The key for referencing the template in the templateLibrary_ |
Returns | The index in the templateLibrary_ |