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 | |
---|
32 | Model* obj; |
---|
33 | TextureSequence* seq; |
---|
34 | Texture* test; |
---|
35 | Material* testMat; |
---|
36 | |
---|
37 | float counter = 0; |
---|
38 | |
---|
39 | |
---|
40 | void Framework::moduleInit(int argc, char** argv) |
---|
41 | { |
---|
42 | ResourceManager::getInstance()->addImageDir("./"); |
---|
43 | |
---|
44 | testMat = new Material; |
---|
45 | |
---|
46 | seq = new TextureSequence(); |
---|
47 | for (int i = 1; i < argc; i++) |
---|
48 | { |
---|
49 | seq->addFrame(argv[i]); |
---|
50 | printf("%s\n", argv[i]); |
---|
51 | } |
---|
52 | test = new Texture(argv[1]); |
---|
53 | testMat->setDiffuseMap(argv[1]); |
---|
54 | |
---|
55 | ResourceManager::getInstance()->addImageDir(""); |
---|
56 | |
---|
57 | |
---|
58 | obj = new PrimitiveModel(PRIM_PLANE, 10.0); |
---|
59 | |
---|
60 | ResourceManager::getInstance()->debug(); |
---|
61 | |
---|
62 | LightManager* lightMan = LightManager::getInstance(); |
---|
63 | lightMan->setAmbientColor(.1,.1,.1); |
---|
64 | (new Light())->setAbsCoor(5.0, 10.0, 40.0); |
---|
65 | (new Light())->setAbsCoor(-10, -20, -100); |
---|
66 | } |
---|
67 | |
---|
68 | void Framework::moduleEventHandler(SDL_Event* event) |
---|
69 | { |
---|
70 | switch (event->type) |
---|
71 | { |
---|
72 | case SDL_KEYDOWN: |
---|
73 | switch (event->key.keysym.sym) |
---|
74 | { |
---|
75 | case SDLK_1: |
---|
76 | obj = new PrimitiveModel(PRIM_CUBE, 10.0); |
---|
77 | break; |
---|
78 | case SDLK_2: |
---|
79 | obj = new PrimitiveModel(PRIM_SPHERE, 10.0); |
---|
80 | break; |
---|
81 | case SDLK_3: |
---|
82 | obj = new PrimitiveModel(PRIM_PLANE, 10.0); |
---|
83 | break; |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | void Framework::moduleTick(float dt) |
---|
89 | { |
---|
90 | counter+=dt; |
---|
91 | |
---|
92 | seq->gotoFrame((unsigned int)counter); |
---|
93 | if ((unsigned int)counter > seq->getFrameCount()) |
---|
94 | counter = 0; |
---|
95 | } |
---|
96 | |
---|
97 | void Framework::moduleDraw(void) const |
---|
98 | { |
---|
99 | testMat->select(); |
---|
100 | glBindTexture(GL_TEXTURE_2D, seq->getTexture()); |
---|
101 | obj->draw(); |
---|
102 | |
---|
103 | LightManager::getInstance()->draw(); |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | void Framework::moduleHelp(void) const |
---|
108 | { |
---|
109 | |
---|
110 | } |
---|