Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6177 was 6168, checked in by hdavid, 19 years ago

branches\avi_play: animations play with the correct framerate

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: Benjamin Grauer
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 "objModel.h"
26
27#include "primitive_model.h"
28#include <stdlib.h>
29
30#include "resource_manager.h"
31#include "media_container.h"
32
33Model* obj;
34TextureSequence* seq;
35Texture* test;
36Material* testMat;
37MediaContainer* movie;
38
39int counter = 0;
40float timer = 0;
41float fps;
42
43
44void Framework::moduleInit(int argc, char** argv)
45{
46  if( argc <= 1)
47  {
48    printf("Wrong arguments try following notations:\n");
49    printf("./multitex [mediaFile]\n");
50    exit(0);
51  }
52
53  movie = new MediaContainer(argv[1]);
54  fps = movie->getFPS();
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->addFrameList(movie->getFrameList());
69
70  test = new Texture();
71  testMat->setDiffuseMap("maps/radialTransparency.png");
72
73  ResourceManager::getInstance()->addImageDir("");
74
75
76  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
77
78  ResourceManager::getInstance()->debug();
79
80  LightManager* lightMan = LightManager::getInstance();
81  lightMan->setAmbientColor(.1,.1,.1);
82  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
83  (new Light())->setAbsCoor(-10, -20, -100);
84}
85
86void Framework::moduleEventHandler(SDL_Event* event)
87{
88  switch (event->type)
89    {
90    case SDL_KEYDOWN:
91      switch (event->key.keysym.sym)
92        {
93        case SDLK_1:
94          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
95          break;
96        case SDLK_2:
97          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
98          break;
99        case SDLK_3:
100          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
101          break;
102        // increase fps
103        case SDLK_9:
104          fps++;
105          PRINTF(1)("fps: %f\n", fps);
106          break;
107        // decrease fps
108        case SDLK_8:
109          if(fps > 0)
110            fps--;
111          PRINTF(1)("fps: %f\n", fps);
112          break;
113        }
114    }
115}
116
117void Framework::moduleTick(float dt)
118{
119  timer += dt;
120
121  if(counter != fps * timer)
122  {
123    counter = fps * timer;
124 
125    if (counter > seq->getFrameCount())
126    {
127      timer = 0;
128      counter = 0;
129    }
130
131    seq->gotoFrame(counter);
132  }   
133}
134
135void Framework::moduleDraw(void) const
136{
137  testMat->select();
138  glBindTexture(GL_TEXTURE_2D, seq->getTexture());
139  obj->draw();
140
141  LightManager::getInstance()->draw();
142}
143
144
145void Framework::moduleHelp(void) const
146{
147
148}
Note: See TracBrowser for help on using the repository browser.