Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6603 was 6600, checked in by bensch, 19 years ago

TRUNK: merged the avi_play branche again

File size: 2.7 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"
[6555]22#include "resource_manager.h"
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
37MovieLoader::~MovieLoader()
38{
39  PRINTF(4)("Deleted MoviePlayer\n");
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);
[6555]54
[6598]55  PRINTF(0)("\nloaded Movie %s\n\n", filename);
[6576]56}
57
58
[6555]59ErrorMessage MovieLoader::init()
60{
61
62}
63
64
65ErrorMessage MovieLoader::loadData()
66{
67
68}
69
70
71ErrorMessage MovieLoader::unloadData()
72{
73
74}
75
76bool MovieLoader::start()
77{
[6598]78  PRINTF(0)("\nMovieLoader INFO:\n");
79  movie_player->printInformation();
80  PRINTF(0)("\n");
81
[6574]82  this->isRunning = true;
[6555]83
[6598]84  this->run();
[6555]85}
86
87bool MovieLoader::stop()
88{
[6574]89  this->isRunning = false;
[6555]90}
91
[6574]92bool MovieLoader::pause() { }
93bool MovieLoader::resume() { }
[6555]94
95void MovieLoader::run()
96{
[6567]97  // first timestamp for t = 0
98  this->lastFrame = SDL_GetTicks ();
[6598]99  this->movie_player->start(0);
[6567]100
[6562]101  while( this->isRunning)
102  {
[6555]103
[6562]104    this->tick();
[6598]105    this->draw();
[6562]106
107  }
[6555]108}
[6557]109
[6598]110void MovieLoader::draw() const
111{
112  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
113
114
115  GraphicsEngine::enter2DMode();
116
[6599]117  glEnable(GL_TEXTURE_2D);
118  glBindTexture(GL_TEXTURE_2D, movie_player->getTexture());
[6598]119
120  glColor3f(1.0, 1.0, 1.0);
121
122  glBegin(GL_QUADS);
[6599]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);
[6598]127  glEnd();
128
129  GraphicsEngine::leave2DMode();
130
131  SDL_GL_SwapBuffers();
132}
133
134
[6557]135void MovieLoader::tick()
136{
[6567]137  // get timestamp
[6574]138  currentFrame = SDL_GetTicks();
[6557]139
[6567]140  // calculate time difference in milliseconds (Uint32)
141  this->dt = currentFrame - this->lastFrame;
142  // calculate time difference in seconds (float)
[6570]143  this->dts = (float)this->dt / 1000.0f;
[6567]144
145  movie_player->tick(dts);
146
[6598]147  if (movie_player->getStatus() == STOP)
148    this->isRunning = false;
149
[6567]150  this->lastFrame = currentFrame;
[6557]151}
Note: See TracBrowser for help on using the repository browser.