/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ #include "animation.h" #include "debug.h" #include "list.h" Anim::Anim(void) { // create a new List this->keyFrameList = new tList(); // initialize a beginning KeyFrame, that will be deleted afterwards this->bHasKeys = false; this->animFunc = &Anim::random; } Anim::~Anim(void) { // delete all the KeyFrames tIterator* itKF = keyFrameList->getIterator(); AnimKeyFrame* enumKF = itKF->nextElement(); while (enumKF) { delete enumKF; enumKF = itKF->nextElement(); } delete itKF; delete this->keyFrameList; } tList* Anim::animatorList = NULL; void Anim::addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc) { if (!bHasKeys) { this->keyFrameList->remove(this->keyFrameList->firstElement()); bHasKeys = true; } AnimKeyFrame* tmpKeyFrame = new AnimKeyFrame; tmpKeyFrame->value = value; tmpKeyFrame->duration = duration; tmpKeyFrame->animFunc = animFunc; this->keyFrameList->add(tmpKeyFrame); } void Anim::setInfinity(ANIM_INFINITY preInfinity, ANIM_INFINITY postInfinity) { this->preInfinity = preInfinity; this->postInfinity = postInfinity; } void Anim::setAnimFunc(ANIM_FUNCTION animFunc) { switch (animFunc) { default: case ANIM_CONSTANT: this->animFunc = &Anim::constant; break; case ANIM_LINEAR: this->animFunc = &Anim::linear; break; case ANIM_RANDOM: this->animFunc = &Anim::random; break; case ANIM_SINE: this->animFunc = &Anim::sine; break; } } // animation functions float Anim::random(float time) { return (float)rand()/(float)RAND_MAX; } float Anim::constant(float time) { } float Anim::linear(float time) { } float Anim::sine(float time) { }