Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3871 in orxonox.OLD


Ignore:
Timestamp:
Apr 18, 2005, 3:41:54 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: sine/cosine reimplemented in t_animation

Location:
orxonox/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/track_manager.cc

    r3849 r3871  
    394394  // initializing the Animation for the Text.
    395395  this->textAnimation = new tAnimation<Text>(this->trackText, &Text::setBlending);
    396   this->textAnimation->addKeyFrame(1.0, 3.0, ANIM_NEG_EXP);
     396  this->textAnimation->addKeyFrame(1.0, 3.0, ANIM_COSINE);
    397397  this->textAnimation->addKeyFrame(0.0, .001);
    398398  this->textAnimation->setInfinity(ANIM_INF_CONSTANT);
  • orxonox/trunk/src/util/animation/t_animation.h

    r3868 r3871  
    2020#ifndef _T_ANIMATION_H
    2121#define _T_ANIMATION_H
    22 
    2322
    2423#include "animation.h"
     
    160159    {
    161160      tmpKeyFrame = new KeyFrameF;
     161      // when adding the second frame
    162162      if (this->currentKeyFrame == this->nextKeyFrame)
    163163        this->nextKeyFrame = tmpKeyFrame;
    164164      this->keyFrameList->add(tmpKeyFrame);
    165 
    166     }
     165    }
     166  // when adding the first frame
    167167  else
    168168    {
    169169      tmpKeyFrame = this->keyFrameList->firstElement();
    170       bHasKeys = true;
     170      this->bHasKeys = true;
    171171      this->setAnimFunc(animFunc);
    172172    }
     173
    173174  tmpKeyFrame->value = value;
    174175  tmpKeyFrame->duration = duration;
     
    196197            this->handleInfinity();
    197198          this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     199
    198200          printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
    199201          this->setAnimFunc(this->currentKeyFrame->animFunc);     
     
    264266float tAnimation<T>::linear(float timePassed) const
    265267{
    266   return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 
     268  return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value)
    267269    * (timePassed / this->currentKeyFrame->duration);
    268   //  PRINTF(0)("value is %f, %p %p\n", val, this->currentKeyFrame, this->nextKeyFrame);
    269   //  return val;
    270270}
    271271
     
    277277float tAnimation<T>::sine(float timePassed) const
    278278{
    279   float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
    280   float e = 0.5 * d * (1 - cos(M_PI * timePassed / this->currentKeyFrame->duration));
    281   return this->currentKeyFrame->value - e;
     279  if (timePassed * 2.0 < this->currentKeyFrame->duration)
     280    return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value)
     281      * sin( M_PI * timePassed / this->currentKeyFrame->duration)/2;
     282  else
     283    return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
     284      * sin( M_PI * (1.0 - timePassed / this->currentKeyFrame->duration))/2;
    282285  /*
    283   return his->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
    284     * sin(timePassed / this->currentKeyFrame->duration * M_PI);
     286  printf("::%f::::%f::\n",timePassed/this->currentKeyFrame->duration,retVal);
     287  return retVal;
    285288  */
    286289}
     
    293296float tAnimation<T>::cosine(float timePassed) const
    294297{
    295   float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
    296   float e = 0.5 * d * (sin(M_PI * timePassed / this->currentKeyFrame->duration));
    297   if( timePassed > 0.5*this->currentKeyFrame->duration) e = (d - e);
    298   return this->currentKeyFrame->value - e;
    299   /*
    300   return this->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
    301     * cos(timePassed / this->currentKeyFrame->duration * M_PI);
    302   */
     298  return ((this->nextKeyFrame->value + this->currentKeyFrame->value) +
     299    (this->currentKeyFrame->value - this->nextKeyFrame->value) *
     300    cos( M_PI * timePassed / this->currentKeyFrame->duration))/2;
    303301}
    304302
Note: See TracChangeset for help on using the changeset viewer.