Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6290 in orxonox.OLD for branches/avi_play/src/lib/graphics


Ignore:
Timestamp:
Dec 26, 2005, 12:59:35 AM (19 years ago)
Author:
hdavid
Message:

branches\avi_play: work on the movie_player

Location:
branches/avi_play/src/lib/graphics/importer
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/lib/graphics/importer/media_container.cc

    r6289 r6290  
    3434MediaContainer::MediaContainer(const char* filename)
    3535{
    36   /* set the class id for the base object */
    37   this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
    38 
    39   /* register all formats and codecs */
    40   av_register_all();
    41 
    42   fps = 0;
     36  this->init();
    4337
    4438  if (filename != NULL)
     
    4842MediaContainer::MediaContainer()
    4943{
    50   /* set the class id for the base object */
    51   this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
    52 
    53   /* register all formats and codecs */
    54   av_register_all();
    55 
    56   fps = 0;
     44  this->init();
    5745}
    5846
     
    8371  av_close_input_file(format_context);
    8472
     73}
     74
     75void MediaContainer::init()
     76{
     77  /* set the class id for the base object */
     78  this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
     79
     80  /* register all formats and codecs */
     81  av_register_all();
     82
     83  fps = 0;
    8584}
    8685
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6289 r6290  
    5353  ~MediaContainer();
    5454
     55  void init();
    5556  SDL_Surface* getFrame(int frame_number);
    5657  SDL_Surface* getNextFrame();
  • branches/avi_play/src/lib/graphics/importer/movie_player.cc

    r6289 r6290  
    3535{
    3636  media_container = new MediaContainer(filename);
     37
     38  this->init();
    3739}
    3840
     
    4042{
    4143  media_container = new MediaContainer();
     44
     45  this->init();
    4246}
    4347
     
    4751MoviePlayer::~MoviePlayer()
    4852{
     53  delete media_container;
     54}
    4955
     56void MoviePlayer::init()
     57{
     58  status = STOP;
     59
     60  tex = new Texture();
     61  material = new Material;
     62
     63  material->setDiffuseMap("maps/radialTransparency.png");
     64
     65  model = new PrimitiveModel(PRIM_PLANE, 10.0);
     66
     67  LightManager* lightMan = LightManager::getInstance();
     68  lightMan->setAmbientColor(.1,.1,.1);
     69  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
     70  (new Light())->setAbsCoor(-10, -20, -100);
    5071}
    5172
     
    6283void MoviePlayer::start(unsigned int start_frame)
    6384{
    64 
     85  status = PLAY;
    6586}
    6687
    6788void MoviePlayer::resume()
    6889{
    69 
     90  status = PLAY;
    7091}
    7192
    7293void MoviePlayer::pause()
    7394{
    74 
     95  status = PAUSE;
    7596}
    7697
    7798void MoviePlayer::stop()
    7899{
    79 
     100  status = STOP;
    80101}
    81102
    82103void MoviePlayer::tick(float time)
    83104{
     105  surface = media_container->getNextFrame();
    84106
     107  if(surface == NULL)
     108    texture = NULL;
     109  else
     110  {
     111    bool hasAlpha;
     112    SDL_Surface* newSurf = tex->prepareSurface(surface, hasAlpha);
     113    if (newSurf != NULL)
     114      texture = Texture::loadTexToGL(newSurf);
     115    else
     116      texture = NULL;
     117  }
    85118}
    86119
    87120const void MoviePlayer::draw()
    88121{
     122  material->select();
     123  glBindTexture(GL_TEXTURE_2D, texture);
     124  model->draw();
    89125
     126  LightManager::getInstance()->draw();
    90127}
    91128
     
    97134float MoviePlayer::getSpeed()
    98135{
    99 
     136  return speed;
    100137}
    101138
    102139const MP_STATUS MoviePlayer::getStatus()
    103140{
    104 
     141  return status;
    105142}
  • branches/avi_play/src/lib/graphics/importer/movie_player.h

    r6289 r6290  
    1010#include "glincl.h"
    1111#include "sdlincl.h"
     12
    1213#include "media_container.h"
     14#include "light.h"
     15#include "texture.h"
     16#include "material.h"
     17#include "primitive_model.h"
    1318
    1419/* include base_object.h since all classes are derived from this one */
     
    1924
    2025class MediaContainer;
     26class Model;
     27class Material;
     28class Texture;
    2129
    2230/* The state of the MoviePlayer */
     
    2735};
    2836
    29 
    30 
    3137class MoviePlayer : public BaseObject
    3238{
     
    3440private:
    3541
    36   MediaContainer* media_container;     
     42  MediaContainer* media_container;
     43  Model* model;
     44  Material* material;
     45  Texture* tex;
     46
     47  SDL_Surface* surface;
     48  GLuint texture;
     49
     50  MP_STATUS status;     
     51  float speed; 
    3752
    3853public:
     
    4257  ~MoviePlayer();
    4358
     59  void init();
    4460  void loadMovie(const char* filename);
    4561
  • branches/avi_play/src/lib/graphics/importer/texture.cc

    r5924 r6290  
    196196                               0xFF000000
    197197#else
    198                                    0xFF000000,
     198                               0xFF000000,
    199199                               0x00FF0000,
    200200                               0x0000FF00,
Note: See TracChangeset for help on using the changeset viewer.