|
Dear all,
I use Softimage to design game worlds. My Softimage scene contains Scene Models representing Game Objects. I have to assign unique ID to every Softimage Scene Model, so it can be later identified within the game.
To crawl Softimage Scene Tree, I use:
SIObject::GetNestedObjects()
This is recommended approach according to Softimage SDK.
When I build a recursive function(you can see it below) to traverse the scene tree, the same Scene Models are returned by the fucntion more times than once(usually three times). This represents problem for me: As I programatically assign unique ID to every Scene Model, I need to vist every scene model only once.
Is there a mechanism how to crawl Softimage scene tree, and be informed about every scene object only once, please?
The recursive function that is supposed to return each Scene Model only once:
void ResetGPNestedObjects_Recursive( SIObject &mySIObjectParam, CRef& in_ctxt, LONG nIndent ) {
Application app;
// traverse only Models but skip SceneRoot
if ( (mySIObjectParam.IsA(siModelID)) && (mySIObjectParam != app.GetActiveSceneRoot()) )
{
ResetGP(mySIObjectParam, in_ctxt, false);
}
LogNestedObject(mySIObjectParam, nIndent);
CRefArray mySIObjects = mySIObjectParam.GetNestedObjects();
for ( int nSIObject = 0; nSIObject < mySIObjects.GetCount(); nSIObject++)
{
SIObject mySIObject = mySIObjects[nSIObject];
ResetGPNestedObjects_Recursive( mySIObject, in_ctxt, nIndent + 1 );
}
}
I use C++ SDK and Softimage 2012.
|