IDataManager
Functions
unsigned int |
|
Detailed Description
-
class IDataManager : public RED::IREDObject
Interface managing data loaded from .red files.
@related Data Manager, class RED::IResourceManager, class RED::IREDFile, class RED::IOTools
The data manager is a singleton in REDsdk. It’s created through the RED::IResourceManager::GetDataManager method and is automatically deleted along with the resource manager.
When loading a .red file, data are stored by the data manager in one or more contexts. Those contexts are then used for all operations involving the file: registration of new items, animations or cleanup.
Data loaded through the RED::IREDFile interface are managed by the data manager and, as a consequence, should be destroyed from that interface through the appropriate release methods. The engine prevents such data to be destroyed by any other method.
Public Functions
-
SET_CID(CID_class_REDIDataManager)
-
virtual unsigned int FindContext(unsigned int iID) const = 0
Finds a context by its ID.
- Returns
The requested context on success,
0 otherwise.
-
virtual RED_RC SetContextID(unsigned int iContext, unsigned int iID) = 0
Sets a given context ID.
- Parameters
iContext – Context to be set.
iID – ID of the context.
- Returns
RED_OK on success,
RED_FAIL otherwise (invalid context).
-
virtual RED_RC GetContextID(unsigned int &oID, unsigned int iContext) const = 0
Gets a given context ID.
- Parameters
oID – reference to the returned context ID.
iContext – Context to be retrieved.
- Returns
RED_OK on success,
RED_FAIL otherwise (invalid context).
-
virtual RED_RC GetSceneRootsCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of scene roots registered for a context.
This method returns the number of scene roots that have been registered for a given animation context.
- Parameters
oCount – Reference to the returned root count.
iDataContext – Scene root’s data context.
- Returns
RED_OK on success,
RED_FAIL otherwise.
-
virtual RED_RC GetSceneRoot(RED::Object *&oRoot, unsigned int iDataContext, unsigned int iIndex, const RED::State &iState, unsigned int iFrame = 0) = 0
Gets a pointer to a scene root at a given frame.
The DAG hierarchy is updated to reflect all the registered shape modifications that apply (between the time of the first root registration and the user requested time).
The returned object implements the RED::IShape interface.
- Parameters
oRoot – Address of the returned pointer.
iDataContext – Context in which the root has to be registered.
iIndex – Number of the viewpoint to retrieve.
iState – Current transaction.
iFrame – Optional starting frame validity for the root. Default value is 0.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one the parameters is invalid,
RED_ALLOC_FAILURE on memory allocation error,
RED_FAIL otherwise.
-
virtual RED_RC GetViewpointsCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of viewpoints currently in a context.
- Parameters
oCount – Reference to the returned viewpoints count.
iDataContext – Viewpoints’ data context.
- Returns
RED_OK on success,
RED_FAIL otherwise.
-
virtual RED_RC GetViewpoint(RED::Object *&oViewpoint, unsigned int iDataContext, unsigned int iIndex, const RED::State &iState, unsigned int iFrame = 0) = 0
Gets the iIndex-th viewpoint.
The returned object implements the RED::IViewpoint interface.
See the \ref tk_accessing_to_loaded_data example for more details.
- Parameters
oViewpoint – Pointer to the returned viewpoint address.
iDataContext – Viewpoint’s data context.
iIndex – Index of the viewpoint to retrieve.
iState – Current transaction.
iFrame – Optional starting frame validity for the viewpoint. Default value is 0.
- Returns
RED_OK on success,
RED_BAD_PARAM if a parameter is not valid,
RED_FAIL otherwise.
-
virtual RED_RC GetImagesCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of images for a given context.
- Parameters
oCount – Reference to the returned images count.
iDataContext – Images’ data context.
- Returns
RED_OK on success,
RED_FAIL otherwise.
-
virtual RED_RC GetImage(RED::Object *&oImage, unsigned int iDataContext, unsigned int iIndex) = 0
Gets a registered image by its index.
The returned object implements the RED::IImage interface.
- Parameters
oImage – Pointer to the returned image adress.
iDataContext – Image’s data context.
iIndex – Index of the requested image.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one of the passed parameters is invalid,
RED_FAIL otherwise.
-
virtual RED_RC GetFontsCount(unsigned int &oCount, unsigned int iDataContext) = 0
Get the number of fonts for a given context.
- Parameters
oCount – The number of fonts we have for iDataContext.
iDataContext – The queried data context number.
- Returns
RED_OK if the method has succeeded,
RED_FAIL otherwise.
-
virtual RED_RC GetFont(RED::Object *&oFont, unsigned int iDataContext, unsigned int iIndex) = 0
Get a registered font by its index in a data context.
The returned object implements the RED::IFont interface.
- Parameters
oFont – Pointer to the returned font adress.
iDataContext – Font’s data context.
iIndex – Index of the requested font.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one of the passed parameters is invalid,
RED_FAIL otherwise.
-
virtual RED_RC GetMaterialsCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of materials for a given context.
- Parameters
oCount – Reference to the returned materials count.
iDataContext – Materials’ data context.
- Returns
RED_OK on success,
RED_FAIL otherwise.
-
virtual RED_RC GetMaterial(RED::Object *&oMaterial, unsigned int iDataContext, unsigned int iIndex) = 0
Gets a registered material by its index.
The returned object implements the RED::IMaterial interface.
- Parameters
oMaterial – Pointer to the returned material adress.
iDataContext – Material’s data context.
iIndex – Index of the requested material.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one of the passed parameters is invalid,
RED_FAIL otherwise.
-
virtual RED_RC GetAnimationClipControllersCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of animation clip controller for a given context.
- Parameters
oCount – Reference to the returned controllers count.
iDataContext – Controllers’ data context.
- Returns
RED_OK on success,
RED_FAIL otherwise.
-
virtual RED_RC GetAnimationClipController(RED::Object *&oController, unsigned int iDataContext, unsigned int iIndex) = 0
Gets a registered animation clip controller by its index.
The returned object implements the RED::IAnimationClipController interface.
- Parameters
oController – Pointer to the returned controller adress.
iDataContext – Controller’s data context.
iIndex – Index of the requested controller.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one of the passed parameters is invalid,
RED_FAIL otherwise.
-
virtual RED_RC GetSkeletalAnimationClipControllersCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of skeletal animation clip controller for a given context.
- Parameters
oCount – Reference to the returned controllers count.
iDataContext – Controllers’ data context.
- Returns
RED_OK on success,
RED_FAIL otherwise.
-
virtual RED_RC GetSkeletalAnimationClipController(RED::Object *&oController, unsigned int iDataContext, unsigned int iIndex) = 0
Gets a registered skeletal animation clip controller by its index.
The returned object implements the RED::IAnimationClipController and RED::ISkeletalAnimationController interfaces.
- Parameters
oController – Pointer to the returned controller adress.
iDataContext – Controller’s data context.
iIndex – Index of the requested controller.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one of the passed parameters is invalid,
RED_FAIL otherwise.
-
virtual RED_RC GetSkeletalAnimationBlendersCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of skeletal animation blenders for a given context.
- Parameters
oCount – Reference to the returned blenders count.
iDataContext – Blender’s data context.
- Returns
RED_OK on success,
RED_FAIL otherwise.
-
virtual RED_RC GetSkeletalAnimationBlender(RED::Object *&oBlender, unsigned int iDataContext, unsigned int iIndex) = 0
Gets a registered skeletal animation blender by its index.
The returned object implements the RED::ISkeletalAnimationBlender and RED::ISkeletalAnimationController interfaces.
- Parameters
oBlender – Pointer to the returned blender adress.
iDataContext – Blender’s data context.
iIndex – Index of the requested blender.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one of the passed parameters is invalid,
RED_FAIL otherwise.
-
virtual RED_RC GetMiscObjectsCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of miscellaneous objects for a given context.
An object is registered in this list because it was written to a file and does not belong to any other category: it’s not a shape, it’s not an image, not a material, etc…
- Parameters
oCount – Reference to the returned objects count.
iDataContext – Object’s data context.
- Returns
RED_OK on success,
RED_FAIL otherwise.
-
virtual RED_RC GetMiscObject(RED::Object *&oObject, unsigned int iDataContext, unsigned int iIndex) = 0
Gets a registered object by its index.
An object is registered in this list because it was written to a file and does not belong to any other category: it’s not a shape, it’s not an image, not a material, etc…
- Parameters
oObject – Pointer to the returned object adress.
iDataContext – Object’s data context.
iIndex – Index of the requested object.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one of the passed parameters is invalid,
RED_FAIL otherwise.
-
virtual RED_RC GetFramesCount(unsigned int &oCount, unsigned int iDataContext) = 0
Gets the number of animation frames in a given context.
- Parameters
oCount – Reference to the returned animation frames count.
iDataContext – Animation’s data context.
- Returns
RED_OK on success,
RED_BAD_PARAM if at least one of the passed parameters is invalid,
RED_FAIL otherwise.
-
virtual RED_RC GetStartFrame(unsigned int &oStart, unsigned int iDataContext) = 0
Gets the first frame of an animated context.
- Parameters
oStart – Reference to the returned frame.
iDataContext – Animation’s data context.
- Returns
Always RED_OK currently.
-
virtual RED_RC RestoreTracksHierarchy(RED::Vector<RED::Object*> &oOrphanDAGs, const RED::FileInfo &iFileInfo, const RED::Vector<unsigned int> &iContextList, const RED::Vector<unsigned int> &iContextFrame) = 0
Restores a multi-track animation DAG hierarchy.
This method restores the hierarchy that can exist between different scene graphs in different contexts in the data manager.
Each animated scene graph is stored inside a given context. An assembly may be composed of many scene graphs that are connected together. The data manager stores these scene graphs separately. To rebuild the entire scene, these different scene graphs may have to be linked together to reproduce the initial assembly. This way separate animations can be replayed asynchronously.
For a given list of contexts (usually retrieved after a file load) and a file information iFileInfo that contains the track hierarchy connection links, the method restores the entire scene(s) by linking all scene graphs together according to iFileInfo. All scene graphs that have no hierarchical relationship with other scene graphs are returned in oOrphanDAGs. These scene graphs are usually attached to cameras: they compose the roots of the loaded file(s).
The RestoreTracksHierarchy method may have to be called each frame to restore scene links if an animation track is animated and is linked to another animation track. It’s not necessary to call the method if an animated scene graph is linked as child of a static scene graph.
- Parameters
oOrphanDAGs – List of scene graph roots that are not linked to anyone among all the possible scene graphs. These ones must be linked to cameras. This link operation has to be done once, as cameras do not loose their children links, even if they are animated.
iFileInfo – The original file information with connectivity data.
iContextList – The list of data contexts in the file.
iContextFrame – The frame of animation to consider for each context.
- Returns
RED_OK if the operation has succeeded,
RED_OK if iFileInfo has no data. In this case, the method does nothing,
RED_BAD_PARAM if the method has received an invalid parameter (either iContextList has a different size than iContextFrame, or iFileInfo is not valid),
RED_ALLOC_FAILURE if a memory allocation has failed,
RED_FAIL otherwise.
-
virtual RED_RC Release(const RED::State &iState) = 0
Releases the memory used by the data manager.
Releases all data internally held by the data manager for all contexts. It releases all used memory:
Scene graphs,
Cameras,
All related animation data for all contexts.
Images,
Materials,
Miscellaneous objects.
An example of use is available in the \ref tk_accessing_to_loaded_data page.
- Parameters
iState – Current transaction.
- Returns
RED_OK on success,
RED_WORKFLOW_ERROR if a software ray-tracer image is processed at the time the call occurs,
RED_WORKFLOW_ERROR if the call occurs outside of a transaction,
RED_FAIL otherwise.
-
virtual RED_RC ReleaseContext(unsigned int iDataContext, bool iDestroyShared, const RED::State &iState) = 0
Releases a single animation context.
Releases all data internally held by the data manager for an unique context iDataContext:
The method releases all scene graphs, cameras and all related animation data for the context.
The method do NOT release images and materials that can be shared among contexts, unless iDestroyShared is set to true.
The method do NOT release misc objects that can be shared among contexts, unless iDestroyShared is set to true.
An example of use is available in the \ref tk_accessing_to_loaded_data page.
- Parameters
iDataContext – Data context number to release.
iDestroyShared – If this flag is set to true, images, materials and miscellaneous objects will be destroyed by the method. Please take all necessary precautions before turning this flag on as these data can be shared.
iState – Current transaction.
- Returns
RED_OK on success,
RED_WORKFLOW_ERROR if a software ray-tracer image is processed at the time the call occurs,
RED_WORKFLOW_ERROR if the call occurs outside of a transaction,
RED_FAIL otherwise.
-
virtual RED_RC ReleaseData(unsigned int iDataContext, RED::Object *iObject, const RED::State &iState, bool iExtract = false) = 0
Releases or extracts data managed by the RED::IDataManager instance.
Some loaded data are managed by the data manager and are therefore owned by it. They can’t be deleted using the standard REDsdk API. You have to call this method to delete them properly.
It may also be helpful to extract data outside of the data manager after loading to avoid having them under the control of the data manager contexts. In this case, this method just removes the data from the data manager and let then the caller control their life cycle. This is the purpose of the ‘iExtractData’ optional flag.
An example of use is available in the \ref tk_accessing_to_loaded_data page.
@param iDataContext: Data context. @param iObject: Pointer to the data to be deleted.
- Parameters
iState – Current transaction parameter.
iExtract – If true, iObject is not destroyed by the method. iObject is removed from the data manager and this is the caller’s responsibility to handle the life cycle of iObject afterwards. If false, iObject is destroyed by the data manager.
- Returns
RED_OK on success,
RED_BAD_PARAM if iObject is NULL,
RED_FAIL if the data does not exist in the data manager or on error.
-
SET_CID(CID_class_REDIDataManager)