[5939] | 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: |
---|
[6289] | 12 | main-programmer: David Hasenfratz |
---|
[5939] | 13 | co-programmer: |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_MEDIA module |
---|
| 19 | For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput |
---|
| 20 | */ |
---|
| 21 | #define DEBUG_MODULE_MEDIA |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | /* include your own header */ |
---|
| 25 | #include "movie_player.h" |
---|
| 26 | |
---|
| 27 | /* header for debug output */ |
---|
| 28 | #include "debug.h" |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | /** |
---|
| 32 | * Default constructor |
---|
| 33 | */ |
---|
| 34 | MoviePlayer::MoviePlayer(const char* filename) |
---|
| 35 | { |
---|
[6289] | 36 | media_container = new MediaContainer(filename); |
---|
[6290] | 37 | |
---|
| 38 | this->init(); |
---|
[6289] | 39 | } |
---|
[5939] | 40 | |
---|
[6289] | 41 | MoviePlayer::MoviePlayer() |
---|
| 42 | { |
---|
| 43 | media_container = new MediaContainer(); |
---|
[6290] | 44 | |
---|
| 45 | this->init(); |
---|
[5939] | 46 | } |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * Default destructor |
---|
| 50 | */ |
---|
| 51 | MoviePlayer::~MoviePlayer() |
---|
| 52 | { |
---|
[6290] | 53 | delete media_container; |
---|
| 54 | } |
---|
[5939] | 55 | |
---|
[6290] | 56 | void MoviePlayer::init() |
---|
| 57 | { |
---|
| 58 | status = STOP; |
---|
| 59 | |
---|
| 60 | material = new Material; |
---|
| 61 | |
---|
| 62 | material->setDiffuseMap("maps/radialTransparency.png"); |
---|
| 63 | |
---|
| 64 | model = new PrimitiveModel(PRIM_PLANE, 10.0); |
---|
| 65 | |
---|
| 66 | LightManager* lightMan = LightManager::getInstance(); |
---|
| 67 | lightMan->setAmbientColor(.1,.1,.1); |
---|
| 68 | (new Light())->setAbsCoor(5.0, 10.0, 40.0); |
---|
| 69 | (new Light())->setAbsCoor(-10, -20, -100); |
---|
[5939] | 70 | } |
---|
| 71 | |
---|
[6289] | 72 | void MoviePlayer::loadMovie(const char* filename) |
---|
| 73 | { |
---|
| 74 | media_container->loadMedia(filename); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | void MoviePlayer::printInformation() |
---|
| 78 | { |
---|
| 79 | media_container->printMediaInformation(); |
---|
| 80 | } |
---|
| 81 | |
---|
[5939] | 82 | void MoviePlayer::start(unsigned int start_frame) |
---|
| 83 | { |
---|
[6322] | 84 | texture = media_container->getFrame(start_frame); |
---|
[6290] | 85 | status = PLAY; |
---|
[5939] | 86 | } |
---|
| 87 | |
---|
| 88 | void MoviePlayer::resume() |
---|
| 89 | { |
---|
[6321] | 90 | if(status == STOP) |
---|
| 91 | texture = media_container->getFrame(2); |
---|
| 92 | status = PLAY; |
---|
[5939] | 93 | } |
---|
| 94 | |
---|
| 95 | void MoviePlayer::pause() |
---|
| 96 | { |
---|
[6321] | 97 | if(status != STOP) |
---|
| 98 | status = PAUSE; |
---|
[5939] | 99 | } |
---|
| 100 | |
---|
| 101 | void MoviePlayer::stop() |
---|
| 102 | { |
---|
[6290] | 103 | status = STOP; |
---|
[6321] | 104 | texture = NULL; |
---|
[5939] | 105 | } |
---|
| 106 | |
---|
| 107 | void MoviePlayer::tick(float time) |
---|
| 108 | { |
---|
[6319] | 109 | if(status == PLAY) |
---|
[6321] | 110 | { |
---|
[6319] | 111 | texture = media_container->getNextFrame(); |
---|
[6321] | 112 | if(texture == NULL) |
---|
| 113 | status = STOP; |
---|
| 114 | } |
---|
[5939] | 115 | } |
---|
| 116 | |
---|
| 117 | const void MoviePlayer::draw() |
---|
| 118 | { |
---|
[6290] | 119 | material->select(); |
---|
| 120 | glBindTexture(GL_TEXTURE_2D, texture); |
---|
| 121 | model->draw(); |
---|
[5939] | 122 | |
---|
[6290] | 123 | LightManager::getInstance()->draw(); |
---|
[5939] | 124 | } |
---|
| 125 | |
---|
| 126 | void MoviePlayer::setSpeed(float speed) |
---|
| 127 | { |
---|
[6319] | 128 | this->speed = speed; |
---|
[5939] | 129 | } |
---|
| 130 | |
---|
| 131 | float MoviePlayer::getSpeed() |
---|
| 132 | { |
---|
[6319] | 133 | return this->speed; |
---|
[5939] | 134 | } |
---|
[5950] | 135 | |
---|
| 136 | const MP_STATUS MoviePlayer::getStatus() |
---|
| 137 | { |
---|
[6319] | 138 | return this->status; |
---|
[5950] | 139 | } |
---|