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 | |
---|
33 | Model* obj; |
---|
34 | TextureSequence* seq; |
---|
35 | Texture* test; |
---|
36 | Material* testMat; |
---|
37 | MediaContainer* movie; |
---|
38 | |
---|
39 | float counter = 0; |
---|
40 | |
---|
41 | |
---|
42 | void Framework::moduleInit(int argc, char** argv) |
---|
43 | { |
---|
44 | movie = new MediaContainer("/home/david/Desktop/Face2.avi"); |
---|
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 | for (int i = 1; i < argc; i++) |
---|
55 | { |
---|
56 | seq->addFrame(argv[i]); |
---|
57 | printf("%s\n", argv[i]); |
---|
58 | } |
---|
59 | |
---|
60 | // add one frame from the movie |
---|
61 | seq->addFrame(movie->getNextFrame()); |
---|
62 | GLuint tex; |
---|
63 | //while((tex = movie->getNextFrame()) != NULL) |
---|
64 | // seq->addFrame(tex); |
---|
65 | |
---|
66 | test = new Texture(argv[1]); |
---|
67 | testMat->setDiffuseMap(argv[1]); |
---|
68 | |
---|
69 | ResourceManager::getInstance()->addImageDir(""); |
---|
70 | |
---|
71 | |
---|
72 | obj = new PrimitiveModel(PRIM_PLANE, 10.0); |
---|
73 | |
---|
74 | ResourceManager::getInstance()->debug(); |
---|
75 | |
---|
76 | LightManager* lightMan = LightManager::getInstance(); |
---|
77 | lightMan->setAmbientColor(.1,.1,.1); |
---|
78 | (new Light())->setAbsCoor(5.0, 10.0, 40.0); |
---|
79 | (new Light())->setAbsCoor(-10, -20, -100); |
---|
80 | } |
---|
81 | |
---|
82 | void Framework::moduleEventHandler(SDL_Event* event) |
---|
83 | { |
---|
84 | switch (event->type) |
---|
85 | { |
---|
86 | case SDL_KEYDOWN: |
---|
87 | switch (event->key.keysym.sym) |
---|
88 | { |
---|
89 | case SDLK_1: |
---|
90 | obj = new PrimitiveModel(PRIM_CUBE, 10.0); |
---|
91 | break; |
---|
92 | case SDLK_2: |
---|
93 | obj = new PrimitiveModel(PRIM_SPHERE, 10.0); |
---|
94 | break; |
---|
95 | case SDLK_3: |
---|
96 | obj = new PrimitiveModel(PRIM_PLANE, 10.0); |
---|
97 | break; |
---|
98 | } |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | void Framework::moduleTick(float dt) |
---|
103 | { |
---|
104 | counter += dt; |
---|
105 | |
---|
106 | seq->gotoFrame((unsigned int)counter); |
---|
107 | |
---|
108 | if ((unsigned int)counter > seq->getFrameCount()) |
---|
109 | counter = 0; |
---|
110 | |
---|
111 | } |
---|
112 | |
---|
113 | void Framework::moduleDraw(void) const |
---|
114 | { |
---|
115 | testMat->select(); |
---|
116 | glBindTexture(GL_TEXTURE_2D, seq->getTexture()); |
---|
117 | obj->draw(); |
---|
118 | |
---|
119 | LightManager::getInstance()->draw(); |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | void Framework::moduleHelp(void) const |
---|
124 | { |
---|
125 | |
---|
126 | } |
---|