Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/avi_play/src/subprojects/importer/multitex.cc @ 6289

Last change on this file since 6289 was 6289, checked in by hdavid, 18 years ago

branches/avi_play: begin of the media_player implementation

File size: 3.1 KB
RevLine 
[4554]1/*
[4333]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:
[6286]12   main-programmer: David Hasenfratz
[4333]13   co-programmer: ...
14
15   this file extends the framework file, so it renders what i want.
16*/
17
18#include "framework.h"
19
[4343]20#include "light.h"
[4333]21
[5865]22#include "texture_sequence.h"
23#include "material.h"
24
[4343]25#include "primitive_model.h"
26#include <stdlib.h>
[4333]27
[4649]28#include "resource_manager.h"
[6094]29#include "media_container.h"
[4343]30
31Model* obj;
[5865]32TextureSequence* seq;
33Texture* test;
[5866]34Material* testMat;
[6094]35MediaContainer* movie;
[5866]36
[6168]37int counter = 0;
38float timer = 0;
39float fps;
[4343]40
[5866]41
[4343]42void Framework::moduleInit(int argc, char** argv)
[4333]43{
[6254]44  if( argc <= 2)
[6168]45  {
46    printf("Wrong arguments try following notations:\n");
[6254]47    printf("./multitex [media_file] [start_time]\n");
[6168]48    exit(0);
49  }
[6094]50
[6163]51  movie = new MediaContainer(argv[1]);
[6289]52  //movie = new MediaContainer();
53  //movie->loadMedia(argv[1]);
[6168]54  fps = movie->getFPS();
[6163]55
[6260]56  int start_time = atoi(argv[2]);
[6254]57
[6094]58  // print information about the media file
59  movie->printMediaInformation();
60
[4649]61  ResourceManager::getInstance()->addImageDir("./");
62
[5866]63  testMat = new Material;
64
[5865]65  seq = new TextureSequence();
[6094]66
[6254]67  // get each fram individually
[6163]68  //while(seq->addFrame(movie->getNextFrame()) != NULL);
69  // get a list of frames
[6254]70  seq->addFrame(movie->getFrame(start_time));
[6163]71  seq->addFrameList(movie->getFrameList());
72
[6160]73  test = new Texture();
[6163]74  testMat->setDiffuseMap("maps/radialTransparency.png");
[5865]75
[4653]76  ResourceManager::getInstance()->addImageDir("");
77
78
[6003]79  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
[4333]80
[4653]81  ResourceManager::getInstance()->debug();
82
[4343]83  LightManager* lightMan = LightManager::getInstance();
84  lightMan->setAmbientColor(.1,.1,.1);
[4741]85  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
86  (new Light())->setAbsCoor(-10, -20, -100);
[4333]87}
88
[4334]89void Framework::moduleEventHandler(SDL_Event* event)
90{
91  switch (event->type)
92    {
93    case SDL_KEYDOWN:
94      switch (event->key.keysym.sym)
[4554]95        {
[6003]96        case SDLK_1:
[6013]97          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
[4554]98          break;
[6068]99        case SDLK_2:
[6013]100          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
[6003]101          break;
[6013]102        case SDLK_3:
103          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
[6003]104          break;
[6168]105        // increase fps
106        case SDLK_9:
107          fps++;
108          PRINTF(1)("fps: %f\n", fps);
109          break;
110        // decrease fps
111        case SDLK_8:
112          if(fps > 0)
113            fps--;
114          PRINTF(1)("fps: %f\n", fps);
115          break;
[4554]116        }
[4334]117    }
[4333]118}
119
120void Framework::moduleTick(float dt)
121{
[6168]122  timer += dt;
[4554]123
[6168]124  if(counter != fps * timer)
125  {
126    counter = fps * timer;
[6254]127
[6168]128    if (counter > seq->getFrameCount())
129    {
130      timer = 0;
131      counter = 0;
132    }
[6112]133
[6168]134    seq->gotoFrame(counter);
[6254]135  }
[4333]136}
137
[4349]138void Framework::moduleDraw(void) const
[4334]139{
[5866]140  testMat->select();
[5865]141  glBindTexture(GL_TEXTURE_2D, seq->getTexture());
[4343]142  obj->draw();
143
144  LightManager::getInstance()->draw();
[4334]145}
[4333]146
[4334]147
[4333]148void Framework::moduleHelp(void) const
149{
[4554]150
[4333]151}
Note: See TracBrowser for help on using the repository browser.