Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 11, 2006, 4:01:06 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/avi_play_merge: merged the trunk, commit for testing

File:
1 edited

Legend:

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

    r5866 r6486  
    1010
    1111   ### File Specific:
    12    main-programmer: Benjamin Grauer
     12   main-programmer: David Hasenfratz
    1313   co-programmer: ...
    1414
     
    2020#include "light.h"
    2121
    22 #include "texture_sequence.h"
    2322#include "material.h"
    24 
    25 #include "objModel.h"
    26 
    2723#include "primitive_model.h"
    2824#include <stdlib.h>
    2925
    30 #include "resource_manager.h"
     26#include "media_container.h"
    3127
    3228Model* obj;
    33 TextureSequence* seq;
    34 Texture* test;
    3529Material* testMat;
     30MediaContainer* media_container;
    3631
    37 float counter = 0;
     32int counter = 0;
     33float timer = 0;
     34float fps;
    3835
    3936
    4037void Framework::moduleInit(int argc, char** argv)
    4138{
    42   ResourceManager::getInstance()->addImageDir("./");
     39  if( argc <= 1)
     40  {
     41    printf("Wrong arguments try following notations:\n");
     42    printf("./multitex [media_file]\n");
     43    exit(0);
     44  }
     45
     46  media_container = new MediaContainer(argv[1]);
    4347
    4448  testMat = new Material;
    45 
    46   seq = new TextureSequence();
    47   for (int i = 1; i < argc; i++)
    48   {
    49     seq->addFrame(argv[i]);
    50     printf("%s\n", argv[i]);
    51   }
    52   test = new Texture(argv[1]);
    53   testMat->setDiffuseMap(argv[1]);
    54 
    55   ResourceManager::getInstance()->addImageDir("");
    56 
    57 
    58   obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
    59 
    60   ResourceManager::getInstance()->debug();
     49  testMat->setDiffuseMap("maps/radialTransparency.png");
     50  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
    6151
    6252  LightManager* lightMan = LightManager::getInstance();
     
    6454  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
    6555  (new Light())->setAbsCoor(-10, -20, -100);
     56
     57  fps = media_container->getFPS();
    6658}
    6759
     
    7365      switch (event->key.keysym.sym)
    7466        {
    75         case SDLK_i:
     67        case SDLK_1:
     68          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
     69          break;
     70        case SDLK_2:
     71          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
     72          break;
     73        case SDLK_3:
     74          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
     75          break;
     76        // increase fps
     77        case SDLK_9:
     78          fps++;
     79          PRINTF(0)("fps: %0.2f\n", fps);
     80          break;
     81        // decrease fps
     82        case SDLK_8:
     83          if(fps > 0)
     84            fps--;
     85          PRINTF(0)("fps: %0.2f\n", fps);
    7686          break;
    7787        }
     
    8191void Framework::moduleTick(float dt)
    8292{
    83   counter+=dt;
     93  timer += dt;
    8494
    85   seq->gotoFrame((unsigned int)counter);
    86   if ((unsigned int)counter > seq->getFrameCount())
    87     counter = 0;
     95  if(counter != fps * timer)
     96  {
     97    counter = fps * timer;
     98
     99    if (counter >= media_container->getFrameCount())
     100    {
     101      timer = 0;
     102      counter = 0;
     103    }
     104  }
    88105}
    89106
     
    91108{
    92109  testMat->select();
    93   glBindTexture(GL_TEXTURE_2D, seq->getTexture());
     110  glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
    94111  obj->draw();
    95112
     
    97114}
    98115
    99 
    100116void Framework::moduleHelp(void) const
    101117{
Note: See TracChangeset for help on using the changeset viewer.