Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6254 was 6254, checked in by stefalie, 18 years ago

branches\avi_play: some changes….

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