THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/09/2004 at 05:30, xxxxxxxx wrote:
Something like this:
// Create KeyFrame for specified BaseDocument doc, BaseObject obj, type(id, sid) and Real value at Real frame
void CreateKeyFrame(BaseDocument *doc, BaseObject* obj, LONG id, LONG sid, Real frame, Real value)
{
BaseTime time = BaseTime::BaseTime(frame, doc->GetFps());
BaseTrack *track;
BaseSequence *seq;
BaseKey *key;
AnimValue *av;
// Add KeyFrame
if (!(track = AllocValueTrack(obj, DescID(DescLevel(id),DescLevel(sid, DTYPE_REAL, 0))))) throw ErrorException(ERROR_MEMORY, "CreateKeyFrame.track");
obj->InsertTrackLast(track);
if (!(seq = track->AutoAddSequence(doc,time))) throw ErrorException(ERROR_MEMORY, "CreateKeyFrame.seq");
if (!(key = BaseKey::Alloc(seq->GetType()))) throw ErrorException(ERROR_MEMORY, "CreateKeyFrame.key");
if (!(av = GetKeyValue(key))) throw ErrorException(ERROR_MEMORY, "CreateKeyFrame.av");
av->value = value;
key->SetTime(time);
seq->InsertKey(key);
}
id is the track ID - i.e.: ID_BASEOBJECT_POSITION (see .res files for ids for tracks).
sid is the sub ID - i.e.: VECTOR_X, VECTOR_Y, VECTOR_Z
Robert