Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

branches\avi_play

File size: 2.7 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 "material.h"
23#include "primitive_model.h"
24#include <stdlib.h>
25
26#include "media_container.h"
27
28Model* obj;
29Material* testMat;
30MediaContainer* media_container;
31
32int counter = 0;
33float timer = 0;
34float fps;
35
36
37void Framework::moduleInit(int argc, char** argv)
38{
39  if( argc <= 1)
40  {
41    printf("Wrong arguments try following notations:\n");
42    printf("./multitex [media_file]\n");
43    exit(0);
44  }
45
46  media_container = new MediaContainer(argv[1]);
47
48  testMat = new Material;
49  testMat->setDiffuseMap("maps/radialTransparency.png");
50  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
51
52  LightManager* lightMan = LightManager::getInstance();
53  lightMan->setAmbientColor(.1,.1,.1);
54  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
55  (new Light())->setAbsCoor(-10, -20, -100);
56
57  fps = media_container->getFPS();
58}
59
60void Framework::moduleEventHandler(SDL_Event* event)
61{
62  switch (event->type)
63    {
64    case SDL_KEYDOWN:
65      switch (event->key.keysym.sym)
66        {
67        case SDLK_1:
68          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
69          break;
70        case SDLK_2:
71          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
72          break;
73        case SDLK_3:
74          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
75          break;
76        case SDLK_5:
77          media_container->loadFrames();
78          counter = 0;
79          timer = 0;
80          PRINTF(0)("total_frames: %i\n", media_container->getFrameCount());
81          SDL_Delay(1000);
82          break;
83        // increase fps
84        case SDLK_9:
85          fps++;
86          PRINTF(0)("fps: %0.2f\n", fps);
87          break;
88        // decrease fps
89        case SDLK_8:
90          if(fps > 0)
91            fps--;
92          PRINTF(0)("fps: %0.2f\n", fps);
93          break;
94        }
95    }
96}
97
98void Framework::moduleTick(float dt)
99{
100  timer += dt;
101
102  if(counter != fps * timer)
103  {
104    counter = fps * timer;
105
106    if (counter >= media_container->getFrameCount())
107    {
108      timer = 0;
109      counter = 0;
110      PRINTF(0)("BEGIN\n");
111    }
112  }
113}
114
115void Framework::moduleDraw(void) const
116{
117  testMat->select();
118  glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
119  obj->draw();
120
121  LightManager::getInstance()->draw();
122}
123
124void Framework::moduleHelp(void) const
125{
126
127}
Note: See TracBrowser for help on using the repository browser.