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