Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/bsp_model/src/subprojects/importer/multitex.cc @ 7799

Last change on this file since 7799 was 6532, checked in by bensch, 19 years ago

orxonox/trunk: merged branches/movie_play to the trunk. no conflicts, but a minor virtual function BUG

File size: 2.4 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        // increase fps
77        case SDLK_9:
78          fps++;
79          PRINTF(0)("fps: %0.2f\n", fps);
80          break;
81        // decrease fps
82        case SDLK_8:
83          if(fps > 0)
84            fps--;
85          PRINTF(0)("fps: %0.2f\n", fps);
86          break;
87        }
88    }
89}
90
91void Framework::moduleTick(float dt)
92{
93  timer += dt;
94
95  if(counter != fps * timer)
96  {
97    counter = fps * timer;
98
99    if (counter >= media_container->getFrameCount())
100    {
101      timer = 0;
102      counter = 0;
103    }
104  }
105}
106
107void Framework::moduleDraw(void) const
108{
109  testMat->select();
110  glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
111  obj->draw();
112
113  LightManager::getInstance()->draw();
114}
115
116void Framework::moduleHelp(void) const
117{
118
119}
Note: See TracBrowser for help on using the repository browser.