Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/movie_loader.cc @ 6837

Last change on this file since 6837 was 6731, checked in by bensch, 19 years ago

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

File size: 2.6 KB
RevLine 
[6555]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: David Hasenfratz, Stefan Lienhard
[6557]13   co-programmer:
[6555]14*/
15
16#include "movie_loader.h"
[6576]17
[6570]18#include "movie_player.h"
[6598]19#include "factory.h"
20#include "graphics_engine.h"
[6576]21#include "load_param.h"
[6731]22#include "state.h"
[6555]23
[6576]24
[6555]25using namespace std;
26
[6598]27CREATE_FACTORY(MovieLoader, CL_MOVIE_LOADER);
[6555]28
[6576]29MovieLoader::MovieLoader(const TiXmlElement* root)
[6555]30{
31  this->setClassID(CL_MOVIE_LOADER, "MovieLoader");
[6576]32
33  movie_player = new MoviePlayer();
34  this->loadParams(root);
[6555]35}
36
[6731]37MovieLoader::~MovieLoader() 
[6555]38{
[6731]39  delete this->movie_player;
[6555]40}
41
42
43
44void MovieLoader::loadParams(const TiXmlElement* root)
45{
[6576]46  StoryEntity::loadParams(root);
[6555]47
[6576]48  LoadParam(root, "name", this, MovieLoader, loadMovie);
[6555]49}
50
[6576]51void MovieLoader::loadMovie(const char* filename)
52{
53  movie_player->loadMovie(filename);
54}
55
56
[6731]57ErrorMessage MovieLoader::init() {}
[6555]58
59
[6731]60ErrorMessage MovieLoader::loadData() {}
[6555]61
62
[6731]63ErrorMessage MovieLoader::unloadData() {}
[6555]64
65bool MovieLoader::start()
66{
[6731]67  this->movie_player->start(0);
68 
[6574]69  this->isRunning = true;
[6598]70  this->run();
[6555]71}
72
73bool MovieLoader::stop()
74{
[6574]75  this->isRunning = false;
[6555]76}
77
[6574]78bool MovieLoader::pause() { }
79bool MovieLoader::resume() { }
[6555]80
81void MovieLoader::run()
82{
[6567]83  // first timestamp for t = 0
84  this->lastFrame = SDL_GetTicks ();
85
[6562]86  while( this->isRunning)
87  {
88    this->tick();
[6598]89    this->draw();
[6562]90  }
[6555]91}
[6557]92
[6598]93void MovieLoader::draw() const
94{
95  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
96
97
98  GraphicsEngine::enter2DMode();
99
[6599]100  glEnable(GL_TEXTURE_2D);
101  glBindTexture(GL_TEXTURE_2D, movie_player->getTexture());
[6598]102
103  glColor3f(1.0, 1.0, 1.0);
104
105  glBegin(GL_QUADS);
[6731]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);
[6598]110  glEnd();
111
112  GraphicsEngine::leave2DMode();
113
114  SDL_GL_SwapBuffers();
115}
116
117
[6557]118void MovieLoader::tick()
119{
[6567]120  // get timestamp
[6574]121  currentFrame = SDL_GetTicks();
[6557]122
[6567]123  // calculate time difference in milliseconds (Uint32)
[6731]124  this->dt = currentFrame - this->lastFrame; 
[6567]125  // calculate time difference in seconds (float)
[6570]126  this->dts = (float)this->dt / 1000.0f;
[6567]127
128  movie_player->tick(dts);
129
[6598]130  if (movie_player->getStatus() == STOP)
131    this->isRunning = false;
132
[6567]133  this->lastFrame = currentFrame;
[6557]134}
Note: See TracBrowser for help on using the repository browser.