Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3832 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Apr 14, 2005, 1:16:31 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: animation class functions implemented, list enhanced

Location:
orxonox/trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/animation.h

    r3831 r3832  
    2929#include "list.h"
    3030// FORWARD DEFINITION
     31
     32#define DELTA_X 0.05  //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta
    3133
    3234typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
     
    146148
    147149 private:
     150  float expFactor;
    148151  T* object;
    149152  void (T::*funcToAnim)(float);
     
    258261                break;
    259262              }
    260           this->currentKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     263          //this->currentKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     264          this->currentKeyFrame = this->nextKeyFrame;
    261265          this->nextKeyFrame = this->keyFrameList->nextElement(this->nextKeyFrame);
    262266          printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
     
    291295      break;
    292296    case ANIM_NEG_EXP:
    293       this->animFunc = &tAnim<T>::negExp;
    294       break;
     297      {
     298        this->animFunc = &tAnim<T>::negExp;
     299        float d = fabs(this->currentKeyFrame->value - this->nextKeyFrame->value);
     300        expFactor =  - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X);
     301        break;
     302      }
    295303    case ANIM_QUADRATIC:
    296304      this->animFunc = &tAnim<T>::quadratic;
     
    319327float tAnim<T>::linear(float timePassed) const
    320328{
    321   return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
     329  return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value)
    322330    * (timePassed / this->currentKeyFrame->duration);
    323331  //  PRINTF(0)("value is %f, %p %p\n", val, this->currentKeyFrame, this->nextKeyFrame);
     
    330338  float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
    331339  float e = 0.5 * d * (1 - cos(M_PI * timePassed / this->currentKeyFrame->duration));
    332   //printf("d=%f, t=%f, T=%f\n", d, timePassed, this->currentKeyFrame->duration);
     340  return this->currentKeyFrame->value - e;
     341  /*
     342  return his->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
     343    * sin(timePassed / this->currentKeyFrame->duration * M_PI);
     344  */
     345}
     346
     347template<class T>
     348float tAnim<T>::cosine(float timePassed) const
     349{
     350  float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
     351  float e = 0.5 * d * (sin(M_PI * timePassed / this->currentKeyFrame->duration));
     352  if( timePassed > 0.5*this->currentKeyFrame->duration) e = (d - e);
    333353  return this->currentKeyFrame->value - e;
    334354  /*
    335355  return this->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
    336     * sin(timePassed / this->currentKeyFrame->duration * M_PI);
     356    * cos(timePassed / this->currentKeyFrame->duration * M_PI);
    337357  */
    338358}
    339359
    340360template<class T>
    341 float tAnim<T>::cosine(float timePassed) const
    342 {
    343   return this->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
    344     * cos(timePassed / this->currentKeyFrame->duration * M_PI);
    345 }
    346 
    347 template<class T>
    348361float tAnim<T>::exp(float timePassed) const
    349362{
    350 
    351363}
    352364
     
    354366float tAnim<T>::negExp(float timePassed) const
    355367{
    356 
     368  float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
     369  float e = d * (1.0 - expf(- timePassed * expFactor));
     370  return  this->currentKeyFrame->value - e;
    357371}
    358372
  • orxonox/trunk/src/lib/coord/p_node.cc

    r3813 r3832  
    522522{
    523523  //this->tick (dt);
     524  /*
    524525  PNode* pn = this->children->enumerate();
    525526  while( pn != NULL)
     
    528529      pn = this->children->nextElement();
    529530    }
     531  */
    530532}
    531533
  • orxonox/trunk/src/lib/util/list.h

    r3831 r3832  
    110110  bool isEmpty();
    111111  int getSize();
    112   T* enumerate();
     112  //T* enumerate();
    113113  tIterator<T>* getIterator();
    114114  T* nextElement();
     
    170170inline void tList<T>::remove(T* entity)
    171171{
    172   //__UNLIKELY( entity == NULL) return;
    173172  this->currentEl = this->first;
    174173  listElement<T>* te;
    175174  while( this->currentEl != NULL)
    176175    {
    177       if( this->currentEl->curr == entity)
     176      __UNLIKELY_IF( this->currentEl->curr == entity)
    178177        {
    179           if( this->currentEl->prev  == NULL ) this->first = this->currentEl->next;
     178          __UNLIKELY_IF( this->currentEl->prev  == NULL ) this->first = this->currentEl->next;
    180179          else this->currentEl->prev->next = this->currentEl->next;
    181180
    182           if( this->currentEl->next == NULL) this->last = this->currentEl->prev;
     181          __UNLIKELY_IF( this->currentEl->next == NULL) this->last = this->currentEl->prev;
    183182          else this->currentEl->next->prev = this->currentEl->prev;
    184183
    185           //te = this->currentEl->next;  // for what am i doing this?
    186184          delete this->currentEl;
    187           //this->currentEl = te;
    188           this->currentEl = NULL;
    189185          this->size--;
    190186          return;
     
    218214}
    219215
     216
    220217template<class T>
    221218inline T* tList<T>::lastElement()
     
    240237
    241238/* deprecated */
     239/*
    242240template<class T>
    243241T* tList<T>::enumerate()
     
    248246  return this->currentEl->curr;
    249247}
    250 
     248*/
    251249
    252250template<class T>
  • orxonox/trunk/src/simple_animation.cc

    r3755 r3832  
    355355            case NEG_EXP:
    356356              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
    357               *anim->tmpVect = *anim->tmpVect * (1 - exp(- anim->localTime * anim->deltaT));     
     357              *anim->tmpVect = *anim->tmpVect * (1 - expf(- anim->localTime * anim->deltaT));     
    358358              anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect);
    359359              *anim->lastPosition = *anim->tmpVect;
  • orxonox/trunk/src/story_entities/campaign.cc

    r3629 r3832  
    212212
    213213
    214 
    215   StoryEntity* entity = this->entities->enumerate();
     214  tIterator<StoryEntity>* iterator = this->entities->getIterator();
     215  StoryEntity* entity = iterator->nextElement();
    216216  while( entity != NULL)
    217217    {
     
    223223          return entity;
    224224        }
    225       entity = this->entities->nextElement();
    226     }
    227 
     225      entity = iterator->nextElement();
     226    }
     227  delete iterator;
    228228
    229229
  • orxonox/trunk/src/story_entities/world.cc

    r3831 r3832  
    374374
    375375            this->testText = TextEngine::getInstance()->createText("fonts/earth.ttf", 30, TEXT_DYNAMIC, 0, 255, 0);
    376             testText->setText("TEXT  rocks");
     376            testText->setText("We've got Hostiles!");
    377377            testText->setBlending(1.0);
    378378            testText->setBindNode(tn);
    379379
    380             aTest* test = new aTest();
    381             tAnim<aTest>* testAnim = new tAnim<aTest>(test, &aTest::littleDebug);
     380            //aTest* test = new aTest();
     381            //tAnim<aTest>* testAnim = new tAnim<aTest>(test, &aTest::littleDebug);
     382            tAnim<Text>* testAnim = new tAnim<Text>(testText, &Text::setBlending);
     383           
     384            testAnim->addKeyFrame(0.0, 1.0, ANIM_LINEAR);
     385            testAnim->addKeyFrame(0.0, 1.0, ANIM_LINEAR);
     386            testAnim->addKeyFrame(1.0, 1.0, ANIM_LINEAR);
     387           
     388            testAnim->addKeyFrame(0.0, 1.0, ANIM_COSINE);
     389            testAnim->addKeyFrame(1.0, 1.0, ANIM_COSINE);         
     390           
    382391            testAnim->addKeyFrame(0.0, 1.0, ANIM_SINE);
    383             testAnim->addKeyFrame(3.5, 1.0, ANIM_SINE);
    384             //testAnim->addKeyFrame(0.0, 1.0, ANIM_LINEAR);
    385             //testAnim->addKeyFrame(1.0, 1.0, ANIM_LINEAR);
     392            testAnim->addKeyFrame(1.0, 1.0, ANIM_SINE);
     393                    testAnim->addKeyFrame(0.0, 1.0, ANIM_NEG_EXP);
     394            testAnim->addKeyFrame(1.0, 1.0, ANIM_NEG_EXP);
     395           
    386396            testAnim->setInfinity(ANIM_INF_REWIND);
    387397            break;
  • orxonox/trunk/src/track_manager.cc

    r3809 r3832  
    149149    childCount = this->childCount;
    150150 
    151   TrackElement* enumElem = this->children->enumerate();
     151  //  TrackElement* enumElem = this->children->enumerate();
     152  tIterator<TrackElement>* iterator = this->children->getIterator();
     153  TrackElement* enumElem = iterator->nextElement();
    152154  for (int i = 0; i < childCount; i++)
    153     enumElem = this->children->nextElement();
     155    enumElem = iterator->nextElement();
     156  delete iterator;
    154157  return enumElem;
    155158}
     
    200203    {
    201204      PRINT(0)("   has %d children: ", this->childCount);
    202       TrackElement* enumElem = this->children->enumerate();
     205      //TrackElement* enumElem = this->children->enumerate();
     206      tIterator<TrackElement>* iterator = this->children->getIterator();
     207      TrackElement* enumElem = iterator->nextElement();
    203208      while (enumElem)
    204209        {
    205210          PRINT(0)("=%d= ", enumElem->ID);
    206           enumElem = this->children->nextElement();
     211          enumElem = iterator->nextElement();
    207212        }
     213      delete iterator;
    208214      PRINT(0)("\n");
    209215    }
     
    294300  int i = 0;
    295301
    296   TrackElement* enumElem = this->children->enumerate();
     302  //TrackElement* enumElem = this->children->enumerate();
     303  tIterator<TrackElement>* iterator = this->children->getIterator();
     304  TrackElement* enumElem = iterator->nextElement();
    297305  while (enumElem)
    298306    {
     
    304312        }
    305313      i++;
    306       enumElem = this->children->nextElement();
    307     }
     314      enumElem = iterator->nextElement();
     315    }
     316  delete iterator;
    308317
    309318  PRINTF(4)("PathDecision with nearest algorithm: %d\n", childNumber);
     
    692701  if(firstJoint->childCount > 0)
    693702    {
    694       TrackElement* enumElem = firstJoint->children->enumerate();
     703      //TrackElement* enumElem = firstJoint->children->enumerate();
     704      tIterator<TrackElement>* iterator = firstJoint->children->getIterator();
     705      TrackElement* enumElem = iterator->nextElement();
    695706      while (enumElem)
    696707        {
     
    699710          enumElem->endTime = tmpLatestTime + enumElem->duration;
    700711         
    701           enumElem = firstJoint->children->nextElement();
     712          enumElem = iterator->nextElement();
    702713        }
     714      delete iterator;
    703715    }
    704716  // returning to the TrackElement we were working on.
     
    716728    {
    717729      TrackElement* tmpElem = findTrackElementByID(i);
    718       if (tmpElem->childCount > 0 && tmpElem->mainJoin)
     730      if( tmpElem->childCount > 0 && tmpElem->mainJoin)
    719731        {
    720 
    721           TrackElement* enumElem = tmpElem->children->enumerate();
     732          tIterator<TrackElement>* iterator = tmpElem->children->getIterator();
     733          TrackElement* enumElem = iterator->nextElement();
     734          //TrackElement* enumElem = tmpElem->children->enumerate();
    722735          while (enumElem)
    723736            {
     
    740753                     enumElem->curve->calcAcc(0).x, enumElem->curve->calcAcc(0).y, enumElem->curve->calcAcc(0).z);
    741754             
    742               enumElem = tmpElem->children->nextElement();
     755              enumElem = iterator->nextElement();
    743756            }
     757          delete iterator;
    744758        }
    745759    }
  • orxonox/trunk/src/world_entities/world_entity.cc

    r3803 r3832  
    104104void WorldEntity::processDraw ()
    105105{
    106   this->draw ();
    107   PNode* pn = this->children->enumerate ();
    108   while( pn != NULL)
    109     {
    110       ((WorldEntity*)pn)->processDraw ();
    111       pn = this->children->nextElement();
    112     }
     106
    113107}
    114108
Note: See TracChangeset for help on using the changeset viewer.