THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/01/2005 at 00:53, xxxxxxxx wrote:
Yes, get the Tracks from the Object. This code is from the MorphMixer.cpp example source that comes with the SDK. It doesn't get the animation info, but it should give you an idea of how to work through the existing animation info.
static Bool CreateKey(BaseDocument *doc, BaseObject *op, const BaseTime &time;, LONG index, Real value)
{
// check if track exists
BaseTrack *track = op->FindTrack(DescLevel(index,DTYPE_REAL,0));
if (!track)
{
track = AllocValueTrack(op,DescLevel(index,DTYPE_REAL,0)); if (!track) return FALSE;
op->InsertTrackLast(track);
}
// check for sequence
BaseSequence *seq=NULL;
for (seq = track->GetFirstSequence(); seq; seq=seq->GetNext())
if (time>=seq->GetT1() && time<=seq->GetT2())
break;
if (!seq)
{
seq = track->AutoAddSequence(doc,time);
if (!seq) return FALSE;
}
BaseKey *key = BaseKey::Alloc(seq->GetType()); if (!key) return FALSE;
AnimValue *av = GetKeyValue(key); if (!av) return FALSE;
av->value = value;
key->SetTime(time);
seq->InsertKey(key);
return TRUE;
}
And here is my working print hierarchy code:
// Print Hierarchy
void PrintHierarchy(BaseDocument *doc)
{
BaseObject *obj;
if (!(obj = doc->GetFirstObject())) return;
PrintChildren(obj);
}
// Print Children recursively
void PrintChildren(BaseObject *obj)
{
for (; obj; obj = obj->GetNext())
{
GePrint(obj->GetName());
if (obj->GetDown()) PrintChildren(obj->GetDown());
}
}
One thing to mention, just to be sure: the objects MUST be in the document - added to document with doc->InsertObject(obj,...). Virtual objects (not added to any document) will not show up in a document's object hierarchy.
Robert