Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

branches\avi_play: added new file to the importer subproject

File size: 3.0 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]);
[6168]52  fps = movie->getFPS();
[6163]53
[6260]54  int start_time = atoi(argv[2]);
[6254]55
[6094]56  // print information about the media file
57  movie->printMediaInformation();
58
[4649]59  ResourceManager::getInstance()->addImageDir("./");
60
[5866]61  testMat = new Material;
62
[5865]63  seq = new TextureSequence();
[6094]64
[6254]65  // get each fram individually
[6163]66  //while(seq->addFrame(movie->getNextFrame()) != NULL);
67  // get a list of frames
[6254]68  seq->addFrame(movie->getFrame(start_time));
[6163]69  seq->addFrameList(movie->getFrameList());
70
[6160]71  test = new Texture();
[6163]72  testMat->setDiffuseMap("maps/radialTransparency.png");
[5865]73
[4653]74  ResourceManager::getInstance()->addImageDir("");
75
76
[6003]77  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
[4333]78
[4653]79  ResourceManager::getInstance()->debug();
80
[4343]81  LightManager* lightMan = LightManager::getInstance();
82  lightMan->setAmbientColor(.1,.1,.1);
[4741]83  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
84  (new Light())->setAbsCoor(-10, -20, -100);
[4333]85}
86
[4334]87void Framework::moduleEventHandler(SDL_Event* event)
88{
89  switch (event->type)
90    {
91    case SDL_KEYDOWN:
92      switch (event->key.keysym.sym)
[4554]93        {
[6003]94        case SDLK_1:
[6013]95          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
[4554]96          break;
[6068]97        case SDLK_2:
[6013]98          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
[6003]99          break;
[6013]100        case SDLK_3:
101          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
[6003]102          break;
[6168]103        // increase fps
104        case SDLK_9:
105          fps++;
106          PRINTF(1)("fps: %f\n", fps);
107          break;
108        // decrease fps
109        case SDLK_8:
110          if(fps > 0)
111            fps--;
112          PRINTF(1)("fps: %f\n", fps);
113          break;
[4554]114        }
[4334]115    }
[4333]116}
117
118void Framework::moduleTick(float dt)
119{
[6168]120  timer += dt;
[4554]121
[6168]122  if(counter != fps * timer)
123  {
124    counter = fps * timer;
[6254]125
[6168]126    if (counter > seq->getFrameCount())
127    {
128      timer = 0;
129      counter = 0;
130    }
[6112]131
[6168]132    seq->gotoFrame(counter);
[6254]133  }
[4333]134}
135
[4349]136void Framework::moduleDraw(void) const
[4334]137{
[5866]138  testMat->select();
[5865]139  glBindTexture(GL_TEXTURE_2D, seq->getTexture());
[4343]140  obj->draw();
141
142  LightManager::getInstance()->draw();
[4334]143}
[4333]144
[4334]145
[4333]146void Framework::moduleHelp(void) const
147{
[4554]148
[4333]149}
Note: See TracBrowser for help on using the repository browser.