Index: trunk/src/defs/class_id.h
===================================================================
--- trunk/src/defs/class_id.h	(revision 6523)
+++ trunk/src/defs/class_id.h	(revision 6532)
@@ -192,4 +192,5 @@
   CL_NPC_TEST1                  =    0x00000301,
   CL_NPC_TEST2                  =    0x00000302,
+  CL_MOVIE_ENTITY               =    0x00000303,
 
 
@@ -226,4 +227,7 @@
   CL_TEXTURE_SEQUENCE           =    0x00004805,
   CL_OBJ_MODEL                  =    0x00000807,
+
+  CL_MOVIE_PLAYER               =    0x00000805,
+  CL_MEDIA_CONTAINER            =    0x00000806,
   CL_PROMITIVE_MODEL            =    0x00000808,
   CL_MD2Model                   =    0x00000809,
Index: trunk/src/lib/graphics/importer/Makefile.am
===================================================================
--- trunk/src/lib/graphics/importer/Makefile.am	(revision 6523)
+++ trunk/src/lib/graphics/importer/Makefile.am	(revision 6532)
@@ -14,5 +14,7 @@
                            texture.cc \
                            texture_sequence.cc \
-                           height_map.cc
+                           height_map.cc \
+                           media_container.cc \
+                           movie_player.cc
 
 libtc_a_SOURCES  = tc.cc
@@ -32,3 +34,5 @@
                  height_map.h \
                  anorms.h \
-                 anormtab.h
+                 anormtab.h \
+                 media_container.h \
+                 movie_player.h
Index: trunk/src/lib/graphics/importer/media_container.cc
===================================================================
--- trunk/src/lib/graphics/importer/media_container.cc	(revision 6532)
+++ trunk/src/lib/graphics/importer/media_container.cc	(revision 6532)
@@ -0,0 +1,243 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: David Hasenfratz, Stephan Lienhard
+   co-programmer:
+*/
+
+
+
+/* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_MEDIA module
+   For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
+*/
+#define DEBUG_MODULE_MEDIA
+
+
+/* include your own header */
+#include "media_container.h"
+
+#include "resource_manager.h"
+
+/* header for debug output */
+#include "debug.h"
+
+
+/**
+ * Default constructor
+ */
+MediaContainer::MediaContainer(const char* filename)
+{
+  // set the class id for the base object
+  this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
+
+  fps = 0;
+
+  if (filename != NULL)
+  {
+    if(!this->loadMedia(filename))
+      PRINTF(1)("MediaContainer::loadMedia() failed for %s\n", filename);
+  }
+}
+
+MediaContainer::MediaContainer()
+{
+  // set the class id for the base object
+  this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
+
+  fps = 0;
+}
+
+/**
+ * Default destructor
+ */
+MediaContainer::~MediaContainer()
+{
+  if (glIsTexture(texture))
+    glDeleteTextures(1, &texture);
+
+  // Free the RGB image
+  delete [] buffer;
+  av_free(RGB_frame);
+
+  // Free the frame
+  av_free(frame);
+
+  // Close the codec
+  avcodec_close(codec_context);
+
+  // Close the video file
+  av_close_input_file(format_context);
+}
+
+bool MediaContainer::loadMedia(const char* filename)
+{
+  // register all formats and codecs
+  av_register_all();
+
+  // Open video file
+  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename), NULL, 0, NULL) !=0 )
+  {
+    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename));
+    return false;
+  }
+
+  // Retrieve stream information
+  if (av_find_stream_info(format_context) < 0)
+  {
+    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename));
+    return false;
+  }
+
+  // Find the first video stream and take it
+  video_stream = av_find_default_stream_index(format_context);
+  
+  if(video_stream == -1)
+  {
+    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename));
+    return false;
+  }
+
+  // Get a pointer to the codec context for the video stream
+  codec_context = format_context->streams[video_stream]->codec;
+
+  // Find the decoder for the video stream
+  codec = avcodec_find_decoder(codec_context->codec_id);
+  if (codec == NULL)
+  {
+    PRINTF(1)("Could not find codec\n");
+    return false;
+  }
+
+  // Open codec
+  if (avcodec_open(codec_context, codec) < 0)
+  {
+    PRINTF(1)("Could not open codec\n");
+    return false;
+  }
+
+  // Allocate video frame
+  frame = avcodec_alloc_frame();
+  RGB_frame = avcodec_alloc_frame();
+
+  // Determine required buffer size and allocate buffer
+  num_bytes = avpicture_get_size(PIX_FMT_RGB24, codec_context->width, codec_context->height);
+  buffer=new uint8_t[num_bytes];
+
+  // data buffer for the texture
+  data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
+
+  // Assign appropriate parts of buffer to image planes in RGB_frame
+  avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height);
+
+  // Calculate fps
+  fps = av_q2d(format_context->streams[video_stream]->r_frame_rate);
+  // NOTE: fix this fps problem!!
+  if(fps < 0 || fps > 1000)
+    fps = 30;
+
+  // read the frames and save them in a sequence as textures
+  this->loadFrames();
+
+  return true;
+}
+
+double MediaContainer::getFPS()
+{
+  return this->fps;
+}
+
+void MediaContainer::loadFrames()
+{
+  // empty texture list
+  this->clearLists();
+
+  // go to the begin of the video
+  av_seek_frame(format_context, video_stream, 0, AVSEEK_FLAG_BACKWARD);
+
+  // get all the frames and save them in the sequence
+  while(this->addFrame(this->getNextFrame()) != NULL);
+}
+
+
+GLuint MediaContainer::getNextFrame()
+{
+
+  // get next frame
+  if(av_read_frame(format_context, &packet) >= 0)
+  {
+    // Is this a packet from the video stream?
+    if(packet.stream_index == video_stream)
+    {
+      int frame_finished;
+      // Decode video frame
+      avcodec_decode_video(codec_context, frame, &frame_finished,
+                           packet.data, packet.size);
+
+      // Free the packet that was allocated by av_read_frame
+      av_free_packet(&packet);
+      
+      // Did we get a video frame?
+      if(frame_finished)
+      {
+        // Conversion from YUV to RGB
+        // Most codecs return images in YUV 420 format
+        // (one luminance and two chrominance channels, with the chrominance
+        // channels samples at half the spatial resolution of the luminance channel)
+        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame,
+                    codec_context->pix_fmt, codec_context->width, codec_context->height);
+
+        for(int i = 0; i < codec_context->height; i++)
+          memcpy(&data[i*codec_context->width*3],
+                 ((AVPicture*)RGB_frame)->data[0]+i *
+                 ((AVPicture*)RGB_frame)->linesize[0], 
+                  codec_context->width*sizeof(uint8_t)*3);
+
+        // Create an OpenGL texture
+        glGenTextures(1, &texture);
+        glBindTexture(GL_TEXTURE_2D, texture);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        // create the texture
+        glTexImage2D(GL_TEXTURE_2D,
+                    0,
+                    GL_RGB,
+                    codec_context->width, codec_context->height,
+                    0,
+                    GL_RGB,
+                    GL_UNSIGNED_BYTE,
+                    data);
+        // build the MipMaps
+        gluBuild2DMipmaps(GL_TEXTURE_2D,
+                        GL_RGB,
+                        codec_context->width,
+                        codec_context->height,
+                        GL_RGB,
+                        GL_UNSIGNED_BYTE,
+                        data);
+        glBindTexture(GL_TEXTURE_2D, 0);
+
+        return texture;
+      }
+      else
+      {
+        av_free_packet(&packet);
+        return this->getNextFrame();
+      }
+    }
+    else
+    {
+      av_free_packet(&packet);
+      return this->getNextFrame();
+    }
+  }
+  else
+    return NULL;
+}
Index: trunk/src/lib/graphics/importer/media_container.h
===================================================================
--- trunk/src/lib/graphics/importer/media_container.h	(revision 6532)
+++ trunk/src/lib/graphics/importer/media_container.h	(revision 6532)
@@ -0,0 +1,61 @@
+/*!
+ * @file media_container.h
+  *  Manages the media files
+
+*/
+
+#ifndef _MEDIA_CONTAINER
+#define _MEDIA_CONTAINER
+
+#include <SDL.h>
+
+#ifdef HAVE_AVFORMAT_H
+  #include <avformat.h>
+#else
+  #include <ffmpeg/avformat.h>
+#endif
+
+/* include base_object.h since all classes are derived from this one */
+#include "base_object.h"
+#include "texture_sequence.h"
+
+#include "glincl.h"
+
+class MediaContainer : public TextureSequence
+{
+
+private:
+
+  AVFormatContext* format_context;
+  AVCodecContext* codec_context;
+  AVCodec* codec;
+  AVFrame* frame;
+  AVPacket packet;
+  AVFrame* RGB_frame;
+
+  GLuint texture;
+  uint8_t* data;
+  uint8_t* buffer;
+  int num_bytes;
+  int video_stream;
+  double fps;
+
+public:
+
+  MediaContainer(const char* filename);
+  MediaContainer();
+  ~MediaContainer();
+
+  bool loadMedia(const char* filename);
+  void loadFrames();
+
+  double getFPS();
+
+private:
+  
+  GLuint getNextFrame();
+
+};
+
+
+#endif /* _MEDIA_CONTAINER */
Index: trunk/src/lib/graphics/importer/movie_player.cc
===================================================================
--- trunk/src/lib/graphics/importer/movie_player.cc	(revision 6532)
+++ trunk/src/lib/graphics/importer/movie_player.cc	(revision 6532)
@@ -0,0 +1,455 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: David Hasenfratz
+   co-programmer:
+*/
+
+
+
+/* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_MEDIA module
+   For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
+*/
+#define DEBUG_MODULE_MEDIA
+
+
+// include your own header
+#include "movie_player.h"
+
+#include "resource_manager.h"
+
+// header for debug output
+#include "debug.h"
+
+
+MoviePlayer::MoviePlayer(const char* filename)
+{
+  this->init();
+
+  if (filename != NULL)
+  {
+    if(!this->loadMovie(filename))
+      PRINTF(1)("MoviePlayer::loadMovie() failes for %s\n", filename);
+  }
+}
+
+MoviePlayer::MoviePlayer()
+{
+  this->init();
+}
+
+MoviePlayer::~MoviePlayer()
+{
+  delete material;
+  delete model;
+
+  if (glIsTexture(texture))
+    glDeleteTextures(1, &texture);
+
+  // Free the RGB image
+  delete [] buffer;
+  av_free(RGB_frame);
+
+  // Free the frame
+  av_free(frame);
+
+  avcodec_default_free_buffers(codec_context);
+
+  // Close the codec
+  avcodec_close(codec_context);
+
+  // Close the video file
+  av_close_input_file(format_context);
+}
+
+void MoviePlayer::init()
+{
+  // set the class id for the base object
+  this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
+
+  status = STOP;
+  timer = 0;
+  frame_number = 0;
+  loading = false;
+
+  material = new Material;
+  material->setDiffuseMap("maps/radialTransparency.png");
+
+  model = new PrimitiveModel(PRIM_PLANE, 10.0);
+
+  LightManager* lightMan = LightManager::getInstance();
+  lightMan->setAmbientColor(.1,.1,.1);
+  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
+  (new Light())->setAbsCoor(-10, -20, -100);
+}
+
+bool MoviePlayer::loadMovie(const char* filename)
+{
+  // register all formats and codecs
+  av_register_all();
+
+  // Open video file
+  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename), NULL, 0, NULL) !=0 )
+  {
+    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename));
+    return false;
+  }
+
+  // Retrieve stream information
+  if (av_find_stream_info(format_context) < 0)
+  {
+    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename));
+    return false;
+  }
+
+  // Find the first video stream and take it
+  video_stream = av_find_default_stream_index(format_context);
+
+  if(video_stream == -1)
+  {
+    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename));
+    return false;
+  }
+
+  // Get a pointer to the codec context for the video stream
+  codec_context = format_context->streams[video_stream]->codec;
+
+  // Find the decoder for the video stream
+  codec = avcodec_find_decoder(codec_context->codec_id);
+  if (codec == NULL)
+  {
+    PRINTF(1)("Could not find codec\n");
+    return false;
+  }
+
+  // Open codec
+  if (avcodec_open(codec_context, codec) < 0)
+  {
+    PRINTF(1)("Could not open codec\n");
+    return false;
+  }
+
+  // Allocate video frame
+  frame = avcodec_alloc_frame();
+  RGB_frame = avcodec_alloc_frame();
+
+  // Determine required buffer size and allocate buffer
+  num_bytes = avpicture_get_size(PIX_FMT_RGB24, codec_context->width, codec_context->height);
+  buffer=new uint8_t[num_bytes];
+
+  // Assign appropriate parts of buffer to image planes in RGB_frame
+  avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height);
+
+  // data buffer for the texture
+  data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
+
+  // Calculate fps
+  fps = av_q2d(format_context->streams[video_stream]->r_frame_rate);
+  // NOTE: fix this fps problem!!
+  if(fps < 0 || fps > 1000)
+    fps = 30;
+
+  // duration
+  duration = format_context->duration / 1000000LL;
+
+  // create texture
+  glGenTextures(1, &texture);
+  glBindTexture(GL_TEXTURE_2D, texture);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+  glTexImage2D(GL_TEXTURE_2D,
+              0,
+              GL_RGB,
+              0, 0,
+              0,
+              GL_RGB,
+              GL_UNSIGNED_BYTE,
+              NULL);
+  glBindTexture(GL_TEXTURE_2D, 0);
+
+  loading = true;
+  return true;
+}
+
+void MoviePlayer::getNextFrame()
+{
+  // get next frame
+  if(av_read_frame(format_context, &packet) >= 0)
+  {
+    // Is this a packet from the video stream?
+    if(packet.stream_index == video_stream)
+    {
+      int frame_finished;
+      // Decode video frame
+      avcodec_decode_video(codec_context, frame, &frame_finished,
+                           packet.data, packet.size);
+
+      // Free the packet that was allocated by av_read_frame
+      av_free_packet(&packet);
+      
+      // Did we get a video frame?
+      if(frame_finished)
+      {
+        frame_number++;
+        //PRINTF(0)("frame_number: %i\n", frame_number);
+        // Conversion from YUV to RGB
+        // Most codecs return images in YUV 420 format
+        // (one luminance and two chrominance channels, with the chrominance
+        // channels samples at half the spatial resolution of the luminance channel)
+        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame,
+                    codec_context->pix_fmt, codec_context->width, codec_context->height);
+
+        for(int i = 0; i < codec_context->height; i++)
+          memcpy(&data[i*codec_context->width*3], ((AVPicture*)RGB_frame)->data[0]+i *
+                 ((AVPicture*)RGB_frame)->linesize[0],
+                 codec_context->width*sizeof(uint8_t)*3);
+
+        glBindTexture(GL_TEXTURE_2D, texture);
+        // update the texture
+        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
+                          codec_context->width, codec_context->height,
+                          GL_RGB, GL_UNSIGNED_BYTE,
+                          data);
+        // build the MipMaps
+        gluBuild2DMipmaps(GL_TEXTURE_2D,
+                        GL_RGB,
+                        codec_context->width,
+                        codec_context->height,
+                        GL_RGB,
+                        GL_UNSIGNED_BYTE,
+                        data);
+        glBindTexture(GL_TEXTURE_2D, 0);
+
+      }
+      else
+      {
+        av_free_packet(&packet);
+        this->getNextFrame();
+      }
+    }
+    else
+    {
+      av_free_packet(&packet);
+      this->getNextFrame();
+    }
+  }
+  else
+    this->stop();
+}
+
+void MoviePlayer::skipFrame(int frames)
+{
+  
+  while(frames != 0)
+  {
+    if(av_read_frame(format_context, &packet) < 0)
+      break;
+    if(packet.stream_index == video_stream)
+    {
+      int frame_finished;
+      // We have to decode the frame to not get ugly fragments
+      avcodec_decode_video(codec_context, frame, &frame_finished,
+                            packet.data, packet.size);
+        
+      // Did we get a video frame?
+      if(frame_finished)
+      {
+        frames--;
+        frame_number++;
+      }
+    }
+    av_free_packet(&packet);
+  }
+  
+  this->getNextFrame();
+
+}
+
+bool MoviePlayer::gotoFrame(int frames)
+{
+  if(!loading)
+  {
+    PRINTF(0)("Load first the media file with loadMovie\n");
+    return false;
+  }
+
+  int err;
+  // seek doesnt work for the first two frames
+  // you will get ugly fragments
+  if(frames < 2)
+  {
+    // go to the begin of the video
+    err = av_seek_frame(format_context, video_stream, 0, AVSEEK_FLAG_BACKWARD);
+    if(err < 0)
+    {
+      PRINTF(1)("Could not seek to frame 0\n");
+      return false;
+    }
+
+    this->frame_number = 0;
+  }
+  else
+  {
+    // seeks to the nearest keyframe
+    // NOTE: there is only about every 5s a keyframe!
+    err = av_seek_frame(format_context, video_stream, frames, AVSEEK_FLAG_BACKWARD);
+    if(err < 0)
+    {
+      PRINTF(1)("Could not seek to frame %i\n", frames);
+      return false;
+    }
+    
+    // go from the keyframe to the exact position
+    codec_context->hurry_up = 1;
+    do {
+      if(av_read_frame(format_context, &packet) < 0)
+      {
+        PRINTF(1)("Could not seek to frame %i\n", frames);
+        return false;
+      }
+
+      if(packet.stream_index == video_stream)
+      {
+        if(packet.pts >= frames-1)
+          break;
+        int frame_finished;
+        avcodec_decode_video(codec_context, frame, &frame_finished, packet.data, packet.size);
+        av_free_packet(&packet);
+      }
+    } while(1);
+    codec_context->hurry_up = 0;
+  
+    this->frame_number = frames;
+  }
+  
+  return true;
+}
+
+void MoviePlayer::start(float start_time)
+{
+  //start_frame = start_time * fps;
+  start_frame = 0;
+
+  if(this->gotoFrame(start_frame))
+  {
+    status = PLAY;
+    timer = 0;
+  
+    this->gotoFrame(start_frame);
+  
+    PRINTF(0)("start\n");
+  }
+}
+
+void MoviePlayer::resume()
+{
+  if(status == PAUSE)
+  {
+    status = PLAY;
+    PRINTF(0)("resume\n");
+  }
+}
+
+void MoviePlayer::pause()
+{
+  if(status == PLAY)
+  {
+    status = PAUSE;
+    PRINTF(0)("pause\n");
+  }
+}
+
+void MoviePlayer::stop()
+{
+  status = STOP;
+
+  PRINTF(0)("stop\n");
+}
+
+void MoviePlayer::tick(float dt)
+{
+  if(status == PLAY)
+  {
+    timer += dt;
+    actual_frame = timer * fps + start_frame;
+    if(actual_frame != frame_number)
+    {
+      if(actual_frame - frame_number == 1)
+        this->getNextFrame();
+      else
+        this->skipFrame(actual_frame - frame_number - 1);
+    }   
+    //PRINTF(0)("frame_number: %i\n", frame_number);
+  }
+}
+
+const void MoviePlayer::draw()
+{
+  material->select();
+  glBindTexture(GL_TEXTURE_2D, texture);
+  model->draw();
+
+  LightManager::getInstance()->draw();
+}
+
+void MoviePlayer::setFPS(float fps)
+{
+  if(fps > 0)
+    this->fps = fps;
+}
+
+float MoviePlayer::getFPS()
+{
+  return this->fps;
+}
+
+const MP_STATUS MoviePlayer::getStatus()
+{
+  return this->status;
+}
+
+void MoviePlayer::printInformation()
+{
+  if(!loading)
+  {
+    PRINTF(0)("Load first the media file with loadMovie\n");
+    return;
+  }
+
+  PRINTF(0)("========================\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("=    MEDIACONTAINER    =\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("=    AVFormatContext   =\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("filename: %s\n", format_context->filename);
+  PRINTF(0)("nb_streams: %i\n", format_context->nb_streams);
+  PRINTF(0)("duration: (%02d:%02d:%02d)\n", duration/3600, (duration%3600)/60, duration%60);
+  PRINTF(0)("file_size: %ikb\n", format_context->file_size/1024);
+  PRINTF(0)("bit_rate: %ikb/s\n", format_context->bit_rate/1000);
+  PRINTF(0)("nb_frames: %i\n", format_context->streams[video_stream]->nb_frames);
+  PRINTF(0)("r_frame_rate: %i\n", format_context->streams[video_stream]->r_frame_rate.num);
+  PRINTF(0)("fps: %0.2f\n", fps);
+  PRINTF(0)("========================\n");
+  PRINTF(0)("=    AVCodecContext    =\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("width: %i\n", codec_context->width);
+  PRINTF(0)("height: %i\n", codec_context->height);
+  PRINTF(0)("time_base.den: %i\n", codec_context->time_base.den);
+  PRINTF(0)("time_base.num: %i\n", codec_context->time_base.num);
+  PRINTF(0)("========================\n");
+  PRINTF(0)("=       AVCodec        =\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("codec name: %s\n", codec->name);
+  PRINTF(0)("========================\n");
+  PRINTF(0)("========================\n");
+}
Index: trunk/src/lib/graphics/importer/movie_player.h
===================================================================
--- trunk/src/lib/graphics/importer/movie_player.h	(revision 6532)
+++ trunk/src/lib/graphics/importer/movie_player.h	(revision 6532)
@@ -0,0 +1,97 @@
+/*!
+ * @file movie_player.h
+  *  Manages the media files
+
+*/
+
+#ifndef _MOVIE_PLAYER
+#define _MOVIE_PLAYER
+
+#include <SDL.h>
+
+#ifdef HAVE_AVFORMAT_H
+  #include <avformat.h>
+#else
+  #include <ffmpeg/avformat.h>
+#endif
+
+#include "glincl.h"
+
+#include "light.h"
+#include "texture.h"
+#include "material.h"
+#include "primitive_model.h"
+
+// include base_object.h since all classes are derived from this one
+#include "base_object.h"
+
+// The state of the MoviePlayer
+typedef enum MP_STATUS {
+  PLAY,
+	PAUSE,
+	STOP
+};
+
+class MoviePlayer : public BaseObject
+{
+
+private:
+
+  Model* model;
+  Material* material;
+
+  AVFormatContext* format_context;
+  AVCodecContext* codec_context;
+  AVCodec* codec;
+  AVFrame* frame;
+  AVPacket packet;
+  AVFrame* RGB_frame;
+
+  GLuint texture;
+  uint8_t* data;
+  uint8_t* buffer;
+  int num_bytes;
+  int video_stream;
+
+  MP_STATUS status;	
+  float timer;
+  int start_frame;
+  int actual_frame;
+  int frame_number;
+  float fps;
+  int duration;
+  bool loading;  
+
+public:
+
+  MoviePlayer(const char* filename);
+  MoviePlayer();
+  ~MoviePlayer();
+
+  bool loadMovie(const char* filename);
+
+	void start(float start_time);
+	void resume();
+	void pause();
+	void stop();
+
+	void tick(float dt);
+	const void draw();
+
+	void setFPS(float fps);
+	float getFPS();
+	const MP_STATUS getStatus();
+  void printInformation();
+
+private:
+  
+  void init();
+  void getNextFrame();
+  void skipFrame(int frames);
+  bool gotoFrame(int frames);
+
+};
+
+
+
+#endif // _MOVIE_PLAYER
Index: trunk/src/lib/graphics/importer/texture.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture.cc	(revision 6523)
+++ trunk/src/lib/graphics/importer/texture.cc	(revision 6532)
@@ -199,5 +199,5 @@
                                0xFF000000
 #else
-                                   0xFF000000,
+                               0xFF000000,
                                0x00FF0000,
                                0x0000FF00,
Index: trunk/src/lib/graphics/importer/texture_sequence.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture_sequence.cc	(revision 6523)
+++ trunk/src/lib/graphics/importer/texture_sequence.cc	(revision 6532)
@@ -47,4 +47,9 @@
 TextureSequence::~TextureSequence()
 {
+  this->clearLists();
+}
+
+void TextureSequence::clearLists()
+{
   // delete all images
   while(!this->images.empty())
@@ -54,5 +59,4 @@
   }
 
-  this->setTexture(0);
   // delete all textures.
   while(!this->textures.empty())
@@ -63,5 +67,4 @@
   }
 }
-
 
 /**
@@ -149,8 +152,20 @@
   }
   this->setAlpha(hasAlpha);
+
   return true;
 }
 
+/**
+ * @brief adds a new Frame at the end of the Sequence.
+ * @param texture the texture to add at the end of the Sequence.
+ */
+bool TextureSequence::addFrame(GLuint texture)
+{
+  if (texture == 0)
+    return false;
+  this->textures.push_back(texture);
 
+  return true;
+}
 
 /**
@@ -158,7 +173,8 @@
  * @param frameNumber the n-th frame
  */
-void TextureSequence::gotoFrame(unsigned int frameNumber)
+/*void TextureSequence::gotoFrame(unsigned int frameNumber)
 {
   if (this->textures.size() > frameNumber)
     this->setTexture(this->textures[frameNumber]);
 }
+*/
Index: trunk/src/lib/graphics/importer/texture_sequence.h
===================================================================
--- trunk/src/lib/graphics/importer/texture_sequence.h	(revision 6523)
+++ trunk/src/lib/graphics/importer/texture_sequence.h	(revision 6532)
@@ -29,4 +29,7 @@
     bool addFrame(const char* image);
     bool addFrame(SDL_Surface* surface);
+    bool addFrame(GLuint texture);
+
+    void clearLists();
 
     virtual bool rebuild();
@@ -35,5 +38,5 @@
     inline unsigned int getFrameCount() const { return this->textures.size(); };
 
-    void gotoFrame(unsigned int frameNumber);
+    //void gotoFrame(unsigned int frameNumber);
     /** @returns The textureID of the Frame @param frameNumber the n-th frame this texture-series.  */
     inline GLuint getFrameTexture(unsigned int frameNumber) const { return (this->textures.size()>frameNumber)?this->textures[frameNumber]:0; };
Index: trunk/src/subprojects/importer/Makefile.am
===================================================================
--- trunk/src/subprojects/importer/Makefile.am	(revision 6523)
+++ trunk/src/subprojects/importer/Makefile.am	(revision 6532)
@@ -7,5 +7,6 @@
 
 bin_PROGRAMS = importer \
-               multitex
+               multitex \
+							 movie_player_test
 
 importer_LDADD = $(MAINSRCDIR)/lib/event/libORXevent.a \
@@ -63,2 +64,29 @@
                   $(MAINSRCDIR)/lib/util/executor/executor.cc \
                   $(MAINSRCDIR)/util/loading/factory.cc
+
+movie_player_test_LDADD = $(MAINSRCDIR)/lib/event/libORXevent.a \
+                 					$(MAINSRCDIR)/lib/parser/tinyxml/libtinyxml.a \
+                 					$(MAINSRCDIR)/lib/graphics/libORXgraphics.a \
+                 					$(MAINSRCDIR)/lib/shell/libORXshell.a \
+                 					$(MAINSRCDIR)/lib/sound/libORXsound.a \
+                 					$(MAINSRCDIR)/lib/graphics/importer/libORXimporter.a
+
+movie_player_test_SOURCES= ../framework.cc \
+                  				 movie_player_test.cc \
+                  				 $(MAINSRCDIR)/util/state.cc \
+                  				 $(MAINSRCDIR)/world_entities/camera.cc \
+                  				 $(MAINSRCDIR)/lib/lang/base_object.cc \
+													 $(MAINSRCDIR)/lib/lang/class_list.cc \
+													 $(MAINSRCDIR)/lib/math/vector.cc \
+													 $(MAINSRCDIR)/util/loading/resource_manager.cc \
+													 $(MAINSRCDIR)/lib/parser/ini_parser/ini_parser.cc \
+													 $(MAINSRCDIR)/lib/coord/p_node.cc \
+													 $(MAINSRCDIR)/lib/coord/null_parent.cc \
+													 $(MAINSRCDIR)/util/loading/load_param.cc \
+													 $(MAINSRCDIR)/util/loading/load_param_description.cc \
+													 $(MAINSRCDIR)/lib/util/helper_functions.cc \
+													 $(MAINSRCDIR)/lib/util/substring.cc \
+													 $(MAINSRCDIR)/lib/util/color.cc \
+													 $(MAINSRCDIR)/lib/util/multi_type.cc \
+													 $(MAINSRCDIR)/lib/util/executor/executor.cc \
+													 $(MAINSRCDIR)/util/loading/factory.cc
Index: trunk/src/subprojects/importer/movie_player_test.cc
===================================================================
--- trunk/src/subprojects/importer/movie_player_test.cc	(revision 6532)
+++ trunk/src/subprojects/importer/movie_player_test.cc	(revision 6532)
@@ -0,0 +1,85 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: David Hasenfratz
+   co-programmer: ...
+
+   this file extends the framework file, so it renders what i want.
+*/
+
+#include <stdlib.h>
+
+#include "framework.h"
+#include "movie_player.h"
+
+MoviePlayer* movie_player;
+
+void Framework::moduleInit(int argc, char** argv)
+{
+  if( argc <= 1)
+  {
+    printf("Wrong arguments try following notations:\n");
+    printf("./movie_player_test [media_file]\n");
+    exit(0);
+  }
+
+  movie_player = new MoviePlayer(argv[1]);
+
+  
+  movie_player->printInformation();
+}
+
+void Framework::moduleEventHandler(SDL_Event* event)
+{
+  switch (event->type)
+  {
+    case SDL_KEYDOWN:
+      switch (event->key.keysym.sym)
+      {
+        case SDLK_1:
+          movie_player->start(0);
+          break;
+        case SDLK_2:
+          movie_player->resume();
+          break;
+        case SDLK_3:
+          movie_player->pause();
+          break;
+        case SDLK_4:
+          movie_player->stop();
+          break;
+        case SDLK_9:
+          movie_player->setFPS(movie_player->getFPS() - 1);
+          PRINTF(0)("fps: %0.2f\n", movie_player->getFPS());
+          break;
+        case SDLK_0:
+          movie_player->setFPS(movie_player->getFPS() + 1);
+          PRINTF(0)("fps: %0.2f\n", movie_player->getFPS());
+          break;
+      }
+  }
+}
+
+void Framework::moduleTick(float dt)
+{
+  movie_player->tick(dt);
+}
+
+void Framework::moduleDraw(void) const
+{
+  movie_player->draw();
+}
+
+
+void Framework::moduleHelp(void) const
+{
+
+}
Index: trunk/src/subprojects/importer/multitex.cc
===================================================================
--- trunk/src/subprojects/importer/multitex.cc	(revision 6523)
+++ trunk/src/subprojects/importer/multitex.cc	(revision 6532)
@@ -10,5 +10,5 @@
 
    ### File Specific:
-   main-programmer: Benjamin Grauer
+   main-programmer: David Hasenfratz
    co-programmer: ...
 
@@ -20,43 +20,33 @@
 #include "light.h"
 
-#include "texture_sequence.h"
 #include "material.h"
-
-#include "objModel.h"
-
 #include "primitive_model.h"
 #include <stdlib.h>
 
-#include "resource_manager.h"
+#include "media_container.h"
 
 Model* obj;
-TextureSequence* seq;
-Texture* test;
 Material* testMat;
+MediaContainer* media_container;
 
-float counter = 0;
+int counter = 0;
+float timer = 0;
+float fps;
 
 
 void Framework::moduleInit(int argc, char** argv)
 {
-  ResourceManager::getInstance()->addImageDir("./");
+  if( argc <= 1)
+  {
+    printf("Wrong arguments try following notations:\n");
+    printf("./multitex [media_file]\n");
+    exit(0);
+  }
+
+  media_container = new MediaContainer(argv[1]);
 
   testMat = new Material;
-
-  seq = new TextureSequence();
-  for (int i = 1; i < argc; i++)
-  {
-    seq->addFrame(argv[i]);
-    printf("%s\n", argv[i]);
-  }
-  test = new Texture(argv[1]);
-  testMat->setDiffuseMap(argv[1]);
-
-  ResourceManager::getInstance()->addImageDir("");
-
-
-  obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
-
-  ResourceManager::getInstance()->debug();
+  testMat->setDiffuseMap("maps/radialTransparency.png");
+  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
 
   LightManager* lightMan = LightManager::getInstance();
@@ -64,4 +54,6 @@
   (new Light())->setAbsCoor(5.0, 10.0, 40.0);
   (new Light())->setAbsCoor(-10, -20, -100);
+
+  fps = media_container->getFPS();
 }
 
@@ -73,5 +65,23 @@
       switch (event->key.keysym.sym)
         {
-        case SDLK_i:
+        case SDLK_1:
+          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
+          break;
+        case SDLK_2:
+          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
+          break;
+        case SDLK_3:
+          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
+          break;
+        // increase fps
+        case SDLK_9:
+          fps++;
+          PRINTF(0)("fps: %0.2f\n", fps);
+          break;
+        // decrease fps
+        case SDLK_8:
+          if(fps > 0)
+            fps--;
+          PRINTF(0)("fps: %0.2f\n", fps);
           break;
         }
@@ -81,9 +91,16 @@
 void Framework::moduleTick(float dt)
 {
-  counter+=dt;
+  timer += dt;
 
-  seq->gotoFrame((unsigned int)counter);
-  if ((unsigned int)counter > seq->getFrameCount())
-    counter = 0;
+  if(counter != fps * timer)
+  {
+    counter = fps * timer;
+
+    if (counter >= media_container->getFrameCount())
+    {
+      timer = 0;
+      counter = 0;
+    }
+  }
 }
 
@@ -91,5 +108,5 @@
 {
   testMat->select();
-  glBindTexture(GL_TEXTURE_2D, seq->getTexture());
+  glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
   obj->draw();
 
@@ -97,5 +114,4 @@
 }
 
-
 void Framework::moduleHelp(void) const
 {
Index: trunk/src/world_entities/Makefile.am
===================================================================
--- trunk/src/world_entities/Makefile.am	(revision 6523)
+++ trunk/src/world_entities/Makefile.am	(revision 6532)
@@ -20,4 +20,5 @@
                   world_entities/terrain.cc \
                   world_entities/satellite.cc \
+                  world_entities/movie_entity.cc \
                   world_entities/character_attributes.cc \
                   world_entities/test_entity.cc \
@@ -68,4 +69,5 @@
                  world_entities/terrain.h \
                  world_entities/satellite.h \
+                 world_entities/movie_entity.h \
                  world_entities/character_attributes.h \
                  world_entities/test_entity.h \
Index: trunk/src/world_entities/movie_entity.cc
===================================================================
--- trunk/src/world_entities/movie_entity.cc	(revision 6532)
+++ trunk/src/world_entities/movie_entity.cc	(revision 6532)
@@ -0,0 +1,155 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2005 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: David Hasenfratz, Stefan Lienhard
+   co-programmer:
+*/
+
+#include "movie_entity.h"
+
+#include "media_container.h"
+#include "load_param.h"
+#include "factory.h"
+#include "material.h"
+
+#include "network_game_manager.h"
+#include "converter.h"
+
+using namespace std;
+
+CREATE_FACTORY(MovieEntity, CL_MOVIE_ENTITY);
+
+/**
+ *  standard constructor
+ */
+MovieEntity::MovieEntity (const TiXmlElement* root)
+{
+  this->setClassID(CL_MOVIE_ENTITY, "MovieEntity");
+
+  media_container = new MediaContainer();
+
+  this->material = new Material;
+  this->material->setDiffuseMap("maps/radialTransparency.png");
+
+  axis = 0;
+  rotation = 0;
+  height = 20;
+  width = 20;
+
+  this->toList(OM_COMMON);
+
+  this->loadParams(root);
+
+  counter = 0;
+  timer = 0;
+  fps = media_container->getFPS();
+}
+
+/**
+ *  standard destructor
+ */
+MovieEntity::~MovieEntity ()
+{
+  delete this->material;
+  delete this->media_container;
+}
+
+void MovieEntity::loadParams(const TiXmlElement* root)
+{
+  WorldEntity::loadParams(root);
+
+  LoadParam(root, "name", this, MovieEntity, loadMovie);
+  LoadParam(root, "axis", this, MovieEntity, setAxis);
+  LoadParam(root, "rotation", this, MovieEntity, setRotation);
+  LoadParam(root, "size", this, MovieEntity, setSize);
+}
+
+void MovieEntity::loadMovie(const char* filename)
+{
+  media_container->loadMedia(filename);
+}
+
+void MovieEntity::setAxis(float axis)
+{
+  this->axis = axis;
+}
+
+// Seconds for one loop
+void MovieEntity::setRotation(float rotation)
+{
+  this->rotation = rotation;
+}
+
+void MovieEntity::setSize(float width, float height)
+{
+  this->width = width;
+  this->height = height;
+}
+
+/**
+ *  this method is called every frame
+ * @param time: the time in seconds that has passed since the last tick
+
+   Handle all stuff that should update with time inside this method (movement, animation, etc.)
+ */
+void MovieEntity::tick(float time)
+{
+  timer += time;
+
+  if(counter != fps * timer)
+  {
+    counter = (int)(fps * timer);
+
+    if (counter >= media_container->getFrameCount())
+    {
+      timer = 0;
+      counter = 0;
+    }
+  }
+
+  if(rotation != 0)
+    axis = (int)(axis + (time * 360/rotation))%360;
+}
+
+
+/**
+ *  the entity is drawn onto the screen with this function
+
+   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
+ */
+void MovieEntity::draw() const
+{
+
+  glPushMatrix();
+  glTranslatef (this->getAbsCoor ().x,
+                this->getAbsCoor ().y,
+                this->getAbsCoor ().z);
+  glRotatef(axis, 0.0f, 1.0f, 0.0f);
+//PRINTF(0)("axis: %f\n", axis);
+
+  glPushAttrib(GL_ENABLE_BIT);
+  glDisable(GL_LIGHTING);
+
+  this->material->select();
+  glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
+
+  glBegin(GL_QUADS);
+    glTexCoord2f(1.0f, 1.0f); glVertex3f(-width/2, -height/2,  0.0f);
+    glTexCoord2f(0.0f, 1.0f); glVertex3f( width/2, -height/2,  0.0f);
+    glTexCoord2f(0.0f, 0.0f); glVertex3f( width/2,  height/2,  0.0f);
+    glTexCoord2f(1.0f, 0.0f); glVertex3f(-width/2,  height/2,  0.0f);
+  glEnd();
+
+  glPopAttrib();
+
+  glPopMatrix();
+
+}
Index: trunk/src/world_entities/movie_entity.h
===================================================================
--- trunk/src/world_entities/movie_entity.h	(revision 6532)
+++ trunk/src/world_entities/movie_entity.h	(revision 6532)
@@ -0,0 +1,46 @@
+/*!
+ * @file movie_entity.h
+ *  Definition of a Movie Screen
+ */
+
+#ifndef _MOVIE_ENTITY_H
+#define _MOVIE_ENTITY_H
+
+#include "world_entity.h"
+
+
+class MediaContainer;
+class Material;
+
+class MovieEntity : public WorldEntity
+{
+  private:
+    MediaContainer* media_container;
+    Material* material;
+
+    int counter;
+    float timer;
+    float fps;
+
+    float axis;
+    float rotation;
+    float height;
+    float width;
+
+  public:
+    MovieEntity (const TiXmlElement* root = NULL);
+    ~MovieEntity ();
+
+    virtual void draw () const;
+    virtual void tick (float time);
+
+    virtual void loadParams(const TiXmlElement* root);
+
+    void loadMovie(const char* filename);
+    void setAxis(float axis);
+    void setRotation(float rotation);
+    void setSize(float width, float height);
+
+};
+
+#endif /* _MOVIE_ENTITY_H */
Index: trunk/src/world_entities/space_ships/space_ship.cc
===================================================================
--- trunk/src/world_entities/space_ships/space_ship.cc	(revision 6523)
+++ trunk/src/world_entities/space_ships/space_ship.cc	(revision 6532)
@@ -123,5 +123,5 @@
   PRINTF(4)("SPACESHIP INIT\n");
 
-  EventHandler::getInstance()->grabEvents(true);
+  //EventHandler::getInstance()->grabEvents(true);
 
   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
