FBX C++ API Reference
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FbxCloneManager Class Reference

#include <fbxclonemanager.h>

Class Description

The clone manager is a utility for cloning entire networks of FbxObject.

Options are available for specifying how the clones inherit the connections of the original.

Networks of FbxObject (inter-connected objects by OO, OP, PO or PP connections) can be cloned. How the connections of clones are handled depends on mSrcPolicy and mExternalDstPolicy.

To clone FbxObject instances and their dependents, put them into a CloneSet and pass the CloneSet to this class:

FbxCloneManager cloneManager;
cloneSet.Insert(someObject, defaultCloneOptions);
cloneManager.AddDependents(cloneSet, someObject, defaultCloneOptions);
cloneManager.Clone(cloneSet, scene)
Remarks
If cloning occurs on the same scene as the original objects, the system will contain duplicated names. Although this is acceptable in FBX, some applications may not behave correctly with duplicated names. It is the responsability of the caller to resolve any conflicts.
See also
FbxCloneManager::CloneSetElement
FbxCloneManager::CloneSet

Definition at line 50 of file fbxclonemanager.h.

Classes

struct  CloneSetElement
 This represents an element in FbxCloneManager::CloneSet to be cloned. More...
 

Public Types

typedef FbxMap< FbxObject *, CloneSetElementCloneSet
 The CloneSet is a collection of pointers to objects that will be cloned in Clone() Attached to each object is a CloneSetElement. More...
 

Public Member Functions

 FbxCloneManager ()
 Constructor. More...
 
virtual ~FbxCloneManager ()
 Destructor. More...
 
virtual bool Clone (CloneSet &pSet, FbxObject *pContainer=((void *) 0)) const
 Clone all objects in the set using the given policies for duplication of connections. More...
 
virtual void AddDependents (CloneSet &pSet, const FbxObject *pObject, const CloneSetElement &pCloneOptions=CloneSetElement(), FbxCriteria pTypes=FbxCriteria::ObjectType(FbxObject::ClassId), int pDepth=sMaximumCloneDepth) const
 Add all dependents of the given object to the CloneSet. More...
 

Static Public Member Functions

static FbxObjectClone (const FbxObject *pObject, FbxObject *pContainer=((void *) 0))
 This function simplifies the process of cloning one object and all its depedency graph by automatically preparing the CloneSet and calling the Clone method using the code below. More...
 

Static Public Attributes

static const int sMaximumCloneDepth
 Maximum depth to clone dependents. More...
 
static const int sConnectToOriginal
 Connect to objects that are connected to original object. More...
 
static const int sConnectToClone
 Connect to clones of objects that are connected to original object. More...
 

Member Typedef Documentation

◆ CloneSet

The CloneSet is a collection of pointers to objects that will be cloned in Clone() Attached to each object is a CloneSetElement.

Its member variables dictate how the corresponding object will be cloned, and how it will inherit connections on the original object.

Definition at line 118 of file fbxclonemanager.h.

Constructor & Destructor Documentation

◆ FbxCloneManager()

Constructor.

◆ ~FbxCloneManager()

virtual ~FbxCloneManager ( )
virtual

Destructor.

Member Function Documentation

◆ Clone() [1/2]

static FbxObject* Clone ( const FbxObject pObject,
FbxObject pContainer = ((void *) 0) 
)
static

This function simplifies the process of cloning one object and all its depedency graph by automatically preparing the CloneSet and calling the Clone method using the code below.

FbxCloneManager cloneManager;
FbxObject* lReturnObj = (FbxObject*)pObject;
cloneManager.AddDependents(cloneSet, pObject, defaultCloneOptions, FbxCriteria::ObjectType(FbxObject::ClassId));
cloneSet.Insert((FbxObject*)pObject, defaultCloneOptions);
// collect all the FbxCharacters, if any (these are indirect dependencies not visible by the AddDependents recursion)
while( lIterator )
{
FbxObject* lObj = lIterator->GetKey();
cloneManager.LookForIndirectDependent(lObj, cloneSet, lExtras);
lIterator = lIterator->Successor();
}
// and add them to cloneSet
for (int i = 0, c = lExtras.GetCount(); i < c; i++)
{
FbxObject* lObj = lExtras[i];
cloneManager.AddDependents(cloneSet, lObj, defaultCloneOptions);
cloneSet.Insert(lObj, defaultCloneOptions);
}
// clone everything
if (cloneManager.Clone(cloneSet, pContainer))
{
// get the clone of pObject
CloneSet::RecordType* lIterator = cloneSet.Find((FbxObject* const)pObject);
if( lIterator )
{
lReturnObj = lIterator->GetValue().mObjectClone;
}
}
return lReturnObj;
Parameters
pObjectObject to clone.
pContainerThis object (typically a scene or document) will contain the new clones.
Returns
The clone of pObject if all its depedency graph have been cloned successfully, NULL otherwise.
Remarks
It is advised not to use an FbxNode object for pContainer to group the cloned dependency graph. Some objects of the FBX SDK are not meant to be connected to FbxNode objects and if they are, the final scene will not comply to the FBX standard and its behavior cannot be guaranteed.
If pContainer is left NULL the cloned objects only exists in the FbxSdkManager and need to be manually connected to the scene in order to be saved to disk.

Example:

FbxObject* lObj2BCloned = ...
FbxNode* myNewParent = FbxNode::Create(lNewScene, "Clone");
lNewScene->GetRootNode()->AddChild(lN);
FbxCloneManager cloneManager;
FbxNode *lClone = (FbxNode*)cloneManager.Clone(lObj2BCloned);
// make sure the cloned object is connected to the scene
lClone->ConnectDstObject(lNewScene);

◆ Clone() [2/2]

virtual bool Clone ( CloneSet pSet,
FbxObject pContainer = ((void *) 0) 
) const
virtual

Clone all objects in the set using the given policies for duplication of connections.

Each CloneSetElement in the set will have its mObjectClone pointer set to the newly created clone. The following code shows how to access the cloned objects:

if (cloneManager.Clone(cloneSet, pContainer))
{
// access the clones
while( lIterator )
{
FbxObject* lOriginalObject = lIterator->GetKey();
FbxObject* lClonedObject = lIterator->GetValue().mObjectClone;
lIterator = lIterator->Successor();
}
}
Parameters
pSetSet of objects to clone
pContainerThis object (typically a scene or document) will contain the new clones
Returns
true if all objects were cloned, false otherwise.
Remarks
It is advised not to use an FbxNode object for pContainer to group the cloned dependency graph. Some objects of the FBX SDK are not meant to be connected to FbxNode objects and if they are, the final scene will not comply to the FBX standard and its behavior cannot be guaranteed.
If pContainer is left NULL the cloned objects only exists in the FbxSdkManager and need to be manually connected to the scene in order to be saved to disk.

◆ AddDependents()

virtual void AddDependents ( CloneSet pSet,
const FbxObject pObject,
const CloneSetElement pCloneOptions = CloneSetElement(),
FbxCriteria  pTypes = FbxCriteria::ObjectType(FbxObject::ClassId),
int  pDepth = sMaximumCloneDepth 
) const
virtual

Add all dependents of the given object to the CloneSet.

Dependents of items already in the set are ignored to prevent infinite recursion on cyclic dependencies.

Parameters
pSetThe set to add items.
pObjectObject to add dependents to
pCloneOptions
pTypesTypes of dependent objects to consider
pDepthMaximum recursive depth. Valid range is [0,sMaximumCloneDepth]

The following example shows how to perform multiple calls to AddDependents() to collect several subgraphs to be cloned:

FbxObject* lRoot = ... // initialized with the root of the graph to be cloned
FbxCharacter* lCharacter = ... // points to the FbxCharacter driving the character defined by "lRoot" graph
FbxCloneManager cloneManager;
cloneManager.AddDependents(cloneSet, lRoot);
cloneSet.Insert(lRoot, defaultCloneOptions);
cloneManager.AddDependents(cloneSet, lCharacter);
cloneSet.Insert(lCharacter, defaultCloneOptions);

Member Data Documentation

◆ sMaximumCloneDepth

const int sMaximumCloneDepth
static

Maximum depth to clone dependents.

Definition at line 55 of file fbxclonemanager.h.

◆ sConnectToOriginal

const int sConnectToOriginal
static

Connect to objects that are connected to original object.

This is a flag to mSrcPolicy or mExternalDstPolicy.

Definition at line 60 of file fbxclonemanager.h.

◆ sConnectToClone

const int sConnectToClone
static

Connect to clones of objects that are connected to original object.

(only if those original objects are also in the clone set) This is a flag to mSrcPolicy.

Definition at line 66 of file fbxclonemanager.h.


The documentation for this class was generated from the following file: