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 "fields.h" |
---|
21 | #include "stdlibincl.h" |
---|
22 | #include "light.h" |
---|
23 | |
---|
24 | #include "cd_engine.h" |
---|
25 | #include "bv_tree.h" |
---|
26 | |
---|
27 | #include "md2Model.h" |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | MD2Model* model; |
---|
33 | int drawMode; |
---|
34 | int depth; |
---|
35 | |
---|
36 | void Framework::moduleInit(int argc, char** argv) |
---|
37 | { |
---|
38 | CDEngine::getInstance(); |
---|
39 | //CDEngine::getInstance()->debug(); |
---|
40 | |
---|
41 | model = new MD2Model("models/tris.md2", "models/tris.pcx"); |
---|
42 | model->tick(0.1f); |
---|
43 | |
---|
44 | // int const length = 6; |
---|
45 | // sVec3D* vertList = new sVec3D[length]; |
---|
46 | // sVec3D data[length] = {{5.0, 0.0, 0.0},{2.0, 0.0, 5.0},{14.0, 0.0, 0.0}, {5.0, 0.0, 1.0}, {12.0, 0.0, 8.0}, {3.0, 5.0, 4.9}}; |
---|
47 | // |
---|
48 | // for(int i = 0; i < length; ++i) |
---|
49 | // { |
---|
50 | // vertList[i][0] = data[i][0]; |
---|
51 | // vertList[i][1] = data[i][1]; |
---|
52 | // vertList[i][2] = data[i][2]; |
---|
53 | // } |
---|
54 | |
---|
55 | CDEngine::getInstance()->debugSpawnTree(7, model->data->pVertices, model->data->numVertices); |
---|
56 | |
---|
57 | |
---|
58 | LightManager* lightMan = LightManager::getInstance(); |
---|
59 | lightMan->setAmbientColor(.1,.1,.1); |
---|
60 | lightMan->addLight(); |
---|
61 | lightMan->addLight(); |
---|
62 | lightMan->setPosition(10, 20, 100); |
---|
63 | |
---|
64 | drawMode = DRAW_MODEL; |
---|
65 | depth = 2; |
---|
66 | |
---|
67 | printf("\n\n==========================="); |
---|
68 | printf("Collision Detection Modler:\n"); |
---|
69 | printf("Key Bindings:\n"); |
---|
70 | printf(" -| Displaying Polygons\t\t p\n"); |
---|
71 | printf(" -| Displaying Separation Plane\t s\n"); |
---|
72 | printf("\n"); |
---|
73 | printf(" -| Tree Depth 1\t\t 1\n"); |
---|
74 | printf(" -| Tree Depth 2\t\t 2\n"); |
---|
75 | printf(" -| Tree Depth 3\t\t 3\n"); |
---|
76 | printf(" -| Tree Depth 4\t\t 4\n"); |
---|
77 | printf(" -| Tree Depth 5\t\t 5\n"); |
---|
78 | printf("===========================\n\n"); |
---|
79 | } |
---|
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_a: |
---|
90 | drawMode |= DRAW_ALL; |
---|
91 | break; |
---|
92 | case SDLK_1: |
---|
93 | { |
---|
94 | printf("Setting tree depth = 1\n"); |
---|
95 | depth = 1; |
---|
96 | int temp = drawMode & DRAW_ALL; |
---|
97 | drawMode ^= temp; |
---|
98 | drawMode |= DRAW_SINGLE; |
---|
99 | break; |
---|
100 | } |
---|
101 | case SDLK_2: |
---|
102 | { |
---|
103 | printf("Setting tree depth = 2\n"); |
---|
104 | depth = 2; |
---|
105 | int temp = drawMode & DRAW_ALL; |
---|
106 | drawMode ^= temp; |
---|
107 | drawMode |= DRAW_SINGLE; |
---|
108 | break; |
---|
109 | } |
---|
110 | case SDLK_3: |
---|
111 | { |
---|
112 | printf("Setting tree depth = 3\n"); |
---|
113 | depth = 3; |
---|
114 | int temp = drawMode & DRAW_ALL; |
---|
115 | drawMode ^= temp; |
---|
116 | drawMode |= DRAW_SINGLE; |
---|
117 | break; |
---|
118 | } |
---|
119 | case SDLK_4: |
---|
120 | { |
---|
121 | printf("Setting tree depth = 4\n"); |
---|
122 | depth = 4; |
---|
123 | int temp = drawMode & DRAW_ALL; |
---|
124 | drawMode ^= temp; |
---|
125 | drawMode |= DRAW_SINGLE; |
---|
126 | break; |
---|
127 | } |
---|
128 | case SDLK_5: |
---|
129 | { |
---|
130 | printf("Setting tree depth = 5\n"); |
---|
131 | depth = 5; |
---|
132 | int temp = drawMode & DRAW_ALL; |
---|
133 | drawMode ^= temp; |
---|
134 | drawMode |= DRAW_SINGLE; |
---|
135 | break; |
---|
136 | } |
---|
137 | case SDLK_6: |
---|
138 | { |
---|
139 | printf("Setting tree depth = 6\n"); |
---|
140 | depth = 6; |
---|
141 | int temp = drawMode & DRAW_ALL; |
---|
142 | drawMode ^= temp; |
---|
143 | drawMode |= DRAW_SINGLE; |
---|
144 | break; |
---|
145 | } |
---|
146 | case SDLK_s: |
---|
147 | if(drawMode & DRAW_SEPARATING_PLANE) |
---|
148 | { |
---|
149 | int temp = drawMode & DRAW_SEPARATING_PLANE; |
---|
150 | drawMode ^= temp; |
---|
151 | printf("Removing Separation Plane\n"); |
---|
152 | } |
---|
153 | else |
---|
154 | { |
---|
155 | drawMode |= DRAW_SEPARATING_PLANE; |
---|
156 | printf("Drawing Separation Plane\n"); |
---|
157 | } |
---|
158 | |
---|
159 | break; |
---|
160 | case SDLK_p: |
---|
161 | if(drawMode & DRAW_BV_POLYGON) |
---|
162 | { |
---|
163 | int temp = drawMode & DRAW_BV_POLYGON; |
---|
164 | drawMode ^= temp; |
---|
165 | printf("Removing OBB Polygons\n"); |
---|
166 | } |
---|
167 | else |
---|
168 | { |
---|
169 | drawMode |= DRAW_BV_POLYGON; |
---|
170 | printf("Drawing OBB Polygons\n"); |
---|
171 | } |
---|
172 | break; |
---|
173 | |
---|
174 | } |
---|
175 | } |
---|
176 | } |
---|
177 | |
---|
178 | |
---|
179 | void Framework::moduleTick(float dt) |
---|
180 | { |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | void Framework::moduleDraw() const |
---|
185 | { |
---|
186 | CDEngine::getInstance()->drawBV(depth, drawMode); |
---|
187 | |
---|
188 | LightManager::getInstance()->draw(); |
---|
189 | |
---|
190 | //model->draw(); |
---|
191 | } |
---|
192 | |
---|
193 | |
---|
194 | void Framework::moduleHelp(void) const |
---|
195 | { |
---|
196 | PRINT(0)("\n"); |
---|
197 | PRINT(0)("i - print debug information of Collision-detection\n"); |
---|
198 | PRINT(0)("\n"); |
---|
199 | } |
---|
200 | |
---|
201 | |
---|
202 | void Framework::moduleInitGui(int argc, char** argv) |
---|
203 | { |
---|
204 | Window* guiMainWindow = NULL; |
---|
205 | |
---|
206 | initGUI(0, NULL); |
---|
207 | |
---|
208 | guiMainWindow = new Window("Collision_detection"); |
---|
209 | { |
---|
210 | //all the Widgets you need |
---|
211 | } |
---|
212 | Window::mainWindow->showall(); |
---|
213 | Window::mainWindow->setSize(300, 500); |
---|
214 | } |
---|