Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

branches/avi_play: frames are displayed correct and fast…took me only 3 days to find out that the only faut was wrong number in the SDL_CreateRGBSurfaceFrom call :-/

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: 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
39float counter = 0;
40
41
42void Framework::moduleInit(int argc, char** argv)
43{
44  movie = new MediaContainer(argv[2]);
45
46  // print information about the media file
47  movie->printMediaInformation();
48
49  ResourceManager::getInstance()->addImageDir("./");
50
51  testMat = new Material;
52
53  seq = new TextureSequence();
54  while(seq->addFrame(movie->getNextFrame()) != NULL);
55
56  test = new Texture();
57 
58  // ???: Only works if i set as diffuse map an image
59  // from the avifile created with importer (frameXX.ppm)
60  testMat->setDiffuseMap(argv[1]);
61
62  ResourceManager::getInstance()->addImageDir("");
63
64
65  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
66
67  ResourceManager::getInstance()->debug();
68
69  LightManager* lightMan = LightManager::getInstance();
70  lightMan->setAmbientColor(.1,.1,.1);
71  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
72  (new Light())->setAbsCoor(-10, -20, -100);
73}
74
75void Framework::moduleEventHandler(SDL_Event* event)
76{
77  switch (event->type)
78    {
79    case SDL_KEYDOWN:
80      switch (event->key.keysym.sym)
81        {
82        case SDLK_1:
83          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
84          break;
85        case SDLK_2:
86          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
87          break;
88        case SDLK_3:
89          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
90          break;
91        }
92    }
93}
94
95void Framework::moduleTick(float dt)
96{
97  counter += 0.2;
98
99  seq->gotoFrame((unsigned int)counter);
100
101  if ((unsigned int)counter > seq->getFrameCount())
102    counter = 0;
103
104}
105
106void Framework::moduleDraw(void) const
107{
108  testMat->select();
109  glBindTexture(GL_TEXTURE_2D, seq->getTexture());
110  obj->draw();
111
112  LightManager::getInstance()->draw();
113}
114
115
116void Framework::moduleHelp(void) const
117{
118
119}
Note: See TracBrowser for help on using the repository browser.