void PartKeyFrames::InsertKeyFrame(const KeyFrame &keyFrame) { for (std::list<KeyFrame>::iterator i = keyFrames.begin(); i != keyFrames.end(); ++i) { if (keyFrame.GetTime() == (*i).GetTime()) { (*i) = keyFrame; return; } else if ((*i).GetTime() > keyFrame.GetTime()) { //inserts BEFORE iterator keyFrames.insert(i, keyFrame); return; } } keyFrames.push_back(keyFrame); }
void Animation::RefreshDuration() { duration = -1.0f; for (std::list<PartKeyFrames>::iterator i = partKeyFrames.begin(); i != partKeyFrames.end(); ++i) { KeyFrame *keyFrame = (*i).GetLastKeyFrame(); if (keyFrame) { float t = keyFrame->GetTime(); if (t > duration) duration = t; } } }
void PartKeyFrames::GetKeyFrameForTime(float time, KeyFrame **prev, KeyFrame **next) { // go through all the keyframes, check time KeyFrame *lastKeyFrame = NULL; for (std::list<KeyFrame>::iterator i = keyFrames.begin(); i != keyFrames.end(); ++i) { KeyFrame *keyFrame = &(*i); if (time > keyFrame->GetTime()) { *prev = keyFrame; } else { *next = keyFrame; return; } lastKeyFrame = keyFrame; } }