Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6731 in orxonox.OLD


Ignore:
Timestamp:
Jan 25, 2006, 6:46:06 PM (18 years ago)
Author:
bensch
Message:

merged avi_play back to the trunk. command https://svn.orxonox.net/orxonox/branches/avi_play . -r6602:HEAD

Location:
trunk/src
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r6695 r6731  
    107107  // SUPER-Modeling
    108108  CL_TEXTURE                    =    0x00c01000,
     109  CL_TEXTURE_SEQUENCE           =    0x00004000,
     110
    109111  CL_TEXT                       =    0x00c02000,
    110112
     
    202204  CL_NPC_TEST2                  =    0x00000302,
    203205  CL_MOVIE_ENTITY               =    0x00000303,
     206  CL_RECORDER                   =    0x00000304,
    204207
    205208
     
    243246
    244247  CL_MATERIAL                   =    0x00000804,
    245   CL_TEXTURE_SEQUENCE           =    0x00004805,
    246248  CL_OBJ_MODEL                  =    0x00000807,
    247249
  • trunk/src/lib/graphics/importer/media_container.cc

    r6532 r6731  
    4040
    4141  fps = 0;
    42 
    43   if (filename != NULL)
    44   {
    45     if(!this->loadMedia(filename))
    46       PRINTF(1)("MediaContainer::loadMedia() failed for %s\n", filename);
    47   }
    48 }
    49 
    50 MediaContainer::MediaContainer()
    51 {
    52   // set the class id for the base object
    53   this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
    54 
    55   fps = 0;
     42  mediaLoaded = false;
     43
     44  this->loadMedia(filename);
    5645}
    5746
     
    6150MediaContainer::~MediaContainer()
    6251{
     52  this->unloadMedia();
     53}
     54
     55void MediaContainer::unloadMedia()
     56{
     57  // check whether a movie is already loaded
     58  if(!mediaLoaded)
     59    return;
     60
     61  fps = 0;
     62
     63  // clear texturelist
     64  this->clearLists();
     65
    6366  if (glIsTexture(texture))
    64     glDeleteTextures(1, &texture);
     67  glDeleteTextures(1, &texture);
    6568
    6669  // Free the RGB image
     
    7679  // Close the video file
    7780  av_close_input_file(format_context);
     81
     82  mediaLoaded = false;
     83
    7884}
    7985
    8086bool MediaContainer::loadMedia(const char* filename)
    8187{
     88  this->unloadMedia();
     89
     90  if(filename == NULL)
     91    return false;
     92  // check whether file exists
     93  if(!ResourceManager::isInDataDir(filename))
     94  {
     95    PRINTF(1)("Could not find %s\n", filename);
     96    return false;
     97  }
     98
    8299  // register all formats and codecs
    83100  av_register_all();
     
    146163  // read the frames and save them in a sequence as textures
    147164  this->loadFrames();
     165  mediaLoaded = true;
    148166
    149167  return true;
  • trunk/src/lib/graphics/importer/media_container.h

    r6607 r6731  
    4040  int video_stream;
    4141  double fps;
     42  bool mediaLoaded;
    4243
    4344public:
    4445
    45   MediaContainer(const char* filename);
    46   MediaContainer();
     46  MediaContainer(const char* filename = NULL);
    4747  ~MediaContainer();
    4848
     
    5555 
    5656  GLuint getNextFrame();
    57 
     57  void unloadMedia();
    5858};
    5959
  • trunk/src/lib/graphics/importer/movie_player.cc

    r6600 r6731  
    3333MoviePlayer::MoviePlayer(const char* filename)
    3434{
    35   this->init();
    36 
    37   if (filename != NULL)
    38   {
    39     if(!this->loadMovie(filename))
    40       PRINTF(1)("MoviePlayer::loadMovie() failes for %s\n", filename);
    41   }
    42 }
    43 
    44 MoviePlayer::MoviePlayer()
    45 {
    46   this->init();
    47 }
     35  // set the class id for the base object
     36  this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
     37
     38  status = STOP;
     39  timer = 0;
     40  frame_number = 0;
     41
     42  mediaLoaded = false;
     43
     44  this->loadMovie(filename);
     45
     46}
     47
    4848
    4949MoviePlayer::~MoviePlayer()
    5050{
    51   //delete material;
    52   //delete model;
     51  this->unloadMedia();
     52}
     53
     54void MoviePlayer::unloadMedia()
     55{
     56  // check whether a movie is already loaded
     57  if(!mediaLoaded)
     58    return;
    5359
    5460  if (glIsTexture(texture))
     
    6268  av_free(frame);
    6369
    64   avcodec_default_free_buffers(codec_context);
    65 
    6670  // Close the codec
    6771  avcodec_close(codec_context);
     
    6973  // Close the video file
    7074  av_close_input_file(format_context);
    71 }
    72 
    73 void MoviePlayer::init()
    74 {
    75   // set the class id for the base object
    76   this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
    7775
    7876  status = STOP;
    7977  timer = 0;
    8078  frame_number = 0;
    81   loading = false;
    82 
    83   /*material = new Material;
    84   material->setDiffuseMap("maps/radialTransparency.png");
    85 
    86   model = new PrimitiveModel(PRIM_PLANE, 10.0);
    87 
    88   LightManager* lightMan = LightManager::getInstance();
    89   lightMan->setAmbientColor(.1,.1,.1);
    90   (new Light())->setAbsCoor(5.0, 10.0, 40.0);
    91   (new Light())->setAbsCoor(-10, -20, -100);
    92   */
    93 }
     79
     80  mediaLoaded = false;
     81
     82}
     83
    9484
    9585bool MoviePlayer::loadMovie(const char* filename)
    9686{
     87  this->unloadMedia();
     88
     89  if(filename == NULL)
     90    return false;
     91  // check whether file exists
     92  if(!ResourceManager::isInDataDir(filename))
     93  {
     94    PRINTF(1)("Could not find %s\n", filename);
     95    return false;
     96  }
     97
    9798  // register all formats and codecs
    9899  av_register_all();
     
    177178  glBindTexture(GL_TEXTURE_2D, 0);
    178179
    179   loading = true;
     180  mediaLoaded = true;
    180181  return true;
    181182}
     
    277278bool MoviePlayer::gotoFrame(int frames)
    278279{
    279   if(!loading)
     280  if(!mediaLoaded)
    280281  {
    281282    PRINTF(0)("Load first the media file with loadMovie\n");
     
    344345    status = PLAY;
    345346    timer = 0;
    346 
    347     this->gotoFrame(start_frame);
    348 
    349     PRINTF(0)("start\n");
    350347  }
    351348}
     
    354351{
    355352  if(status == PAUSE)
    356   {
    357353    status = PLAY;
    358     PRINTF(0)("resume\n");
    359   }
    360354}
    361355
     
    363357{
    364358  if(status == PLAY)
    365   {
    366359    status = PAUSE;
    367     PRINTF(0)("pause\n");
    368   }
    369360}
    370361
     
    372363{
    373364  status = STOP;
    374 
    375   PRINTF(0)("stop\n");
    376365}
    377366
     
    389378        this->skipFrame(actual_frame - frame_number - 1);
    390379    }
    391     //PRINTF(0)("frame_number: %i\n", frame_number);
    392   }
    393 }
    394 
    395 /*const void MoviePlayer::draw()
    396 {
    397   material->select();
    398   glBindTexture(GL_TEXTURE_2D, texture);
    399   model->draw();
    400 
    401   LightManager::getInstance()->draw();
    402 }*/
     380  }
     381}
    403382
    404383GLuint MoviePlayer::getTexture()
     
    425404void MoviePlayer::printInformation()
    426405{
    427   if(!loading)
     406  if(!mediaLoaded)
    428407  {
    429408    PRINTF(0)("Load first the media file with loadMovie\n");
  • trunk/src/lib/graphics/importer/movie_player.h

    r6607 r6731  
    1717
    1818#include "glincl.h"
    19 
    20 //#include "light.h"
    2119#include "texture.h"
    22 //#include "material.h"
    23 //#include "primitive_model.h"
    2420
    2521// include base_object.h since all classes are derived from this one
     
    2925typedef enum MP_STATUS {
    3026  PLAY,
    31         PAUSE,
    32         STOP
     27  PAUSE,
     28  STOP
    3329};
    3430
     
    3733
    3834private:
    39 
    40   //Model* model;
    41   //Material* material;
    4235
    4336  AVFormatContext* format_context;
     
    6154  float fps;
    6255  int duration;
    63   bool loading;
     56  bool mediaLoaded;
    6457
    6558public:
    6659
    67   MoviePlayer(const char* filename);
    68   MoviePlayer();
     60  MoviePlayer(const char* filename = NULL);
    6961  ~MoviePlayer();
    7062
    7163  bool loadMovie(const char* filename);
    7264
    73         void start(float start_time);
    74         void resume();
    75         void pause();
    76         void stop();
     65  void start(float start_time);
     66  void resume();
     67  void pause();
     68  void stop();
    7769
    78         void tick(float dt);
    79         //const void draw();
    80         GLuint getTexture();
     70  void tick(float dt);
     71  GLuint getTexture();
    8172
    82         void setFPS(float fps);
    83         float getFPS();
    84         const MP_STATUS getStatus();
     73  void setFPS(float fps);
     74  float getFPS();
     75  const MP_STATUS getStatus();
    8576  void printInformation();
    8677
    8778private:
    8879
    89   void init();
    9080  void getNextFrame();
    9181  void skipFrame(int frames);
    9282  bool gotoFrame(int frames);
    9383
     84  void unloadMedia();
     85
    9486};
    9587
    96 
    97 
    9888#endif // _MOVIE_PLAYER
  • trunk/src/story_entities/movie_loader.cc

    r6600 r6731  
    2020#include "graphics_engine.h"
    2121#include "load_param.h"
    22 #include "resource_manager.h"
     22#include "state.h"
    2323
    2424
     
    3535}
    3636
    37 MovieLoader::~MovieLoader()
     37MovieLoader::~MovieLoader() 
    3838{
    39   PRINTF(4)("Deleted MoviePlayer\n");
     39  delete this->movie_player;
    4040}
    4141
     
    5252{
    5353  movie_player->loadMovie(filename);
    54 
    55   PRINTF(0)("\nloaded Movie %s\n\n", filename);
    5654}
    5755
    5856
    59 ErrorMessage MovieLoader::init()
    60 {
    61 
    62 }
     57ErrorMessage MovieLoader::init() {}
    6358
    6459
    65 ErrorMessage MovieLoader::loadData()
    66 {
    67 
    68 }
     60ErrorMessage MovieLoader::loadData() {}
    6961
    7062
    71 ErrorMessage MovieLoader::unloadData()
    72 {
    73 
    74 }
     63ErrorMessage MovieLoader::unloadData() {}
    7564
    7665bool MovieLoader::start()
    7766{
    78   PRINTF(0)("\nMovieLoader INFO:\n");
    79   movie_player->printInformation();
    80   PRINTF(0)("\n");
    81 
     67  this->movie_player->start(0);
     68 
    8269  this->isRunning = true;
    83 
    8470  this->run();
    8571}
     
    9783  // first timestamp for t = 0
    9884  this->lastFrame = SDL_GetTicks ();
    99   this->movie_player->start(0);
    10085
    10186  while( this->isRunning)
    10287  {
    103 
    10488    this->tick();
    10589    this->draw();
    106 
    10790  }
    10891}
     
    121104
    122105  glBegin(GL_QUADS);
    123     glTexCoord2f(1.0f, 0.0f); glVertex2f( 0, 0);
    124     glTexCoord2f(1.0f, 1.0f); glVertex2f( 0, 100);
    125     glTexCoord2f(0.0f, 1.0f); glVertex2f( 100, 100);
    126     glTexCoord2f(0.0f, 0.0f); glVertex2f( 100, 0);
     106    glTexCoord2f(0.0f, 0.0f); glVertex2f( 0, 0);
     107    glTexCoord2f(0.0f, 1.0f); glVertex2f( 0, State::getResY());
     108    glTexCoord2f(1.0f, 1.0f); glVertex2f( State::getResX(), State::getResY());
     109    glTexCoord2f(1.0f, 0.0f); glVertex2f( State::getResX(), 0);
    127110  glEnd();
    128111
     
    139122
    140123  // calculate time difference in milliseconds (Uint32)
    141   this->dt = currentFrame - this->lastFrame;
     124  this->dt = currentFrame - this->lastFrame; 
    142125  // calculate time difference in seconds (float)
    143126  this->dts = (float)this->dt / 1000.0f;
  • trunk/src/world_entities/Makefile.am

    r6655 r6731  
    2121                  world_entities/satellite.cc \
    2222                  world_entities/movie_entity.cc \
     23                  world_entities/recorder.cc \
    2324                  world_entities/character_attributes.cc \
    2425                  world_entities/test_entity.cc \
     
    7475                 world_entities/satellite.h \
    7576                 world_entities/movie_entity.h \
     77                 world_entities/recorder.h \
    7678                 world_entities/character_attributes.h \
    7779                 world_entities/test_entity.h \
  • trunk/src/world_entities/movie_entity.cc

    r6695 r6731  
    3737  height = 20;
    3838  width = 20;
     39  mediaLoaded = false;
    3940
    4041  this->toList(OM_COMMON);
     
    6364  LoadParam(root, "name", this, MovieEntity, loadMovie);
    6465  LoadParam(root, "axis", this, MovieEntity, setAxis);
    65   LoadParam(root, "rotation", this, MovieEntity, setRotation);
     66  //LoadParam(root, "rotation", this, MovieEntity, setRotation);
    6667  LoadParam(root, "size", this, MovieEntity, setSize);
    6768}
     
    6970void MovieEntity::loadMovie(const char* filename)
    7071{
    71   media_container->loadMedia(filename);
     72  if(media_container->loadMedia(filename))
     73    mediaLoaded = true;
     74  else
     75    mediaLoaded = false;
    7276}
    7377
     
    97101void MovieEntity::tick(float time)
    98102{
     103  if(!mediaLoaded)
     104    return;
     105
    99106  timer += time;
    100107
     
    122129void MovieEntity::draw() const
    123130{
     131  if(!mediaLoaded)
     132    false;
    124133
    125134  glPushMatrix();
  • trunk/src/world_entities/movie_entity.h

    r6600 r6731  
    2626    float width;
    2727
     28    bool mediaLoaded;
     29
    2830  public:
    2931    MovieEntity (const TiXmlElement* root = NULL);
Note: See TracChangeset for help on using the changeset viewer.