Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6168 in orxonox.OLD


Ignore:
Timestamp:
Dec 20, 2005, 12:16:31 AM (18 years ago)
Author:
hdavid
Message:

branches\avi_play: animations play with the correct framerate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/subprojects/importer/multitex.cc

    r6163 r6168  
    3737MediaContainer* movie;
    3838
    39 float counter = 0;
     39int counter = 0;
     40float timer = 0;
     41float fps;
    4042
    4143
    4244void Framework::moduleInit(int argc, char** argv)
    4345{
    44     if( argc <= 1)
    45     {
    46       printf("Wrong arguments try following notations:\n");
    47       printf("./multitex [mediaFile]\n");
    48       exit(0);
    49     }
     46  if( argc <= 1)
     47  {
     48    printf("Wrong arguments try following notations:\n");
     49    printf("./multitex [mediaFile]\n");
     50    exit(0);
     51  }
    5052
    5153  movie = new MediaContainer(argv[1]);
     54  fps = movie->getFPS();
    5255
    5356  // print information about the media file
     
    97100          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
    98101          break;
     102        // increase fps
     103        case SDLK_9:
     104          fps++;
     105          PRINTF(1)("fps: %f\n", fps);
     106          break;
     107        // decrease fps
     108        case SDLK_8:
     109          if(fps > 0)
     110            fps--;
     111          PRINTF(1)("fps: %f\n", fps);
     112          break;
    99113        }
    100114    }
     
    103117void Framework::moduleTick(float dt)
    104118{
    105   counter += 0.2;
     119  timer += dt;
    106120
    107   seq->gotoFrame((unsigned int)counter);
     121  if(counter != fps * timer)
     122  {
     123    counter = fps * timer;
     124 
     125    if (counter > seq->getFrameCount())
     126    {
     127      timer = 0;
     128      counter = 0;
     129    }
    108130
    109   if ((unsigned int)counter > seq->getFrameCount())
    110     counter = 0;
    111 
     131    seq->gotoFrame(counter);
     132  }   
    112133}
    113134
Note: See TracChangeset for help on using the changeset viewer.