1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * |
---|
4 | * |
---|
5 | * License notice: |
---|
6 | * |
---|
7 | * This program is free software: you can redistribute it and/or modify |
---|
8 | * it under the terms of the GNU General Public License as published by |
---|
9 | * the Free Software Foundation, either version 3 of the License, or |
---|
10 | * (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | * |
---|
20 | * |
---|
21 | * Author: |
---|
22 | * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 |
---|
23 | * Co-authors: |
---|
24 | * ... |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | #include <Ogre.h> |
---|
29 | #include <OIS/OIS.h> |
---|
30 | #include <CEGUI/CEGUI.h> |
---|
31 | #include <OgreCEGUIRenderer.h> |
---|
32 | |
---|
33 | #include "BaseObject.h" |
---|
34 | #include "Test.h" |
---|
35 | |
---|
36 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
37 | #include <CoreFoundation/CoreFoundation.h> |
---|
38 | |
---|
39 | // This function will locate the path to our application on OS X, |
---|
40 | // unlike windows you can not rely on the curent working directory |
---|
41 | // for locating your configuration files and resources. |
---|
42 | std::string macBundlePath() |
---|
43 | { |
---|
44 | char path[1024]; |
---|
45 | CFBundleRef mainBundle = CFBundleGetMainBundle(); |
---|
46 | assert(mainBundle); |
---|
47 | |
---|
48 | CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); |
---|
49 | assert(mainBundleURL); |
---|
50 | |
---|
51 | CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); |
---|
52 | assert(cfStringRef); |
---|
53 | |
---|
54 | CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); |
---|
55 | |
---|
56 | CFRelease(mainBundleURL); |
---|
57 | CFRelease(cfStringRef); |
---|
58 | |
---|
59 | return std::string(path); |
---|
60 | } |
---|
61 | #endif |
---|
62 | |
---|
63 | namespace orxonox |
---|
64 | { |
---|
65 | class OrxExitListener : public Ogre::FrameListener |
---|
66 | { |
---|
67 | public: |
---|
68 | OrxExitListener(OIS::Keyboard *keyboard) |
---|
69 | : mKeyboard(keyboard) |
---|
70 | { |
---|
71 | } |
---|
72 | |
---|
73 | bool frameStarted(const Ogre::FrameEvent& evt) |
---|
74 | { |
---|
75 | mKeyboard->capture(); |
---|
76 | return !mKeyboard->isKeyDown(OIS::KC_ESCAPE); |
---|
77 | } |
---|
78 | |
---|
79 | private: |
---|
80 | OIS::Keyboard *mKeyboard; |
---|
81 | }; |
---|
82 | |
---|
83 | class OrxApplication |
---|
84 | { |
---|
85 | public: |
---|
86 | void go() |
---|
87 | { |
---|
88 | /* |
---|
89 | createRoot(); |
---|
90 | defineResources(); |
---|
91 | setupRenderSystem(); |
---|
92 | createRenderWindow(); |
---|
93 | initializeResourceGroups(); |
---|
94 | setupScene(); |
---|
95 | setupInputSystem(); |
---|
96 | setupCEGUI(); |
---|
97 | createFrameListener(); |
---|
98 | startRenderLoop(); |
---|
99 | */ |
---|
100 | /* |
---|
101 | std::cout << "Test 1\n"; |
---|
102 | BaseObject* test1; |
---|
103 | test1 = new BaseObject(); |
---|
104 | test1 = new BaseObject(); |
---|
105 | test1 = new BaseObject(); |
---|
106 | |
---|
107 | std::cout << "Test 2\n"; |
---|
108 | A1* test2; |
---|
109 | test2 = new A1(); |
---|
110 | test2 = new A1(); |
---|
111 | test2 = new A1(); |
---|
112 | |
---|
113 | std::cout << "Test 3\n"; |
---|
114 | BaseObject* test3; |
---|
115 | test3 = new BaseObject(); |
---|
116 | test3 = new BaseObject(); |
---|
117 | test3 = new BaseObject(); |
---|
118 | |
---|
119 | std::cout << "Test 4\n"; |
---|
120 | A3* test4; |
---|
121 | test4 = new A3(); |
---|
122 | test4 = new A3(); |
---|
123 | test4 = new A3(); |
---|
124 | */ |
---|
125 | |
---|
126 | std::cout << "Test 5\n"; |
---|
127 | A1* test5_01 = new A1(); |
---|
128 | A2* test5_02 = new A2(); |
---|
129 | A3* test5_03 = new A3(); |
---|
130 | A1B1* test5_04 = new A1B1(); |
---|
131 | A1B2* test5_05 = new A1B2(); |
---|
132 | A2B1* test5_06 = new A2B1(); |
---|
133 | A2B2* test5_07 = new A2B2(); |
---|
134 | A3B1* test5_08 = new A3B1(); |
---|
135 | A3B2* test5_09 = new A3B2(); |
---|
136 | A1B1C1* test5_10 = new A1B1C1(); |
---|
137 | A1B1C2* test5_11 = new A1B1C2(); |
---|
138 | A1B2C1* test5_12 = new A1B2C1(); |
---|
139 | A2B1C1* test5_13 = new A2B1C1(); |
---|
140 | A2B2C1* test5_14 = new A2B2C1(); |
---|
141 | A3B1C1* test5_15 = new A3B1C1(); |
---|
142 | A3B1C2* test5_16 = new A3B1C2(); |
---|
143 | A3B2C1* test5_17 = new A3B2C1(); |
---|
144 | A3B2C2* test5_18 = new A3B2C2(); |
---|
145 | |
---|
146 | /* |
---|
147 | OrxonoxClass* test5; |
---|
148 | for (int i = 0; i <= 18; i++) |
---|
149 | { |
---|
150 | if (i == 0) test5 = test1; |
---|
151 | if (i == 1) test5 = test5_01; |
---|
152 | if (i == 2) test5 = test5_02; |
---|
153 | if (i == 3) test5 = test5_03; |
---|
154 | if (i == 4) test5 = test5_04; |
---|
155 | if (i == 5) test5 = test5_05; |
---|
156 | if (i == 6) test5 = test5_06; |
---|
157 | if (i == 7) test5 = test5_07; |
---|
158 | if (i == 8) test5 = test5_08; |
---|
159 | if (i == 9) test5 = test5_09; |
---|
160 | if (i == 10) test5 = test5_10; |
---|
161 | if (i == 11) test5 = test5_11; |
---|
162 | if (i == 12) test5 = test5_12; |
---|
163 | if (i == 13) test5 = test5_13; |
---|
164 | if (i == 14) test5 = test5_14; |
---|
165 | if (i == 15) test5 = test5_15; |
---|
166 | if (i == 16) test5 = test5_16; |
---|
167 | if (i == 17) test5 = test5_17; |
---|
168 | if (i == 18) test5 = test5_18; |
---|
169 | |
---|
170 | std::cout << "\n"; |
---|
171 | std::cout << test5->getIdentifier()->getName() << ": directParents: " << test5->getIdentifier()->getDirectParents()->toString() << "\n"; |
---|
172 | std::cout << test5->getIdentifier()->getName() << ": allParents: " << test5->getIdentifier()->getAllParents()->toString() << "\n"; |
---|
173 | std::cout << test5->getIdentifier()->getName() << ": directChildren: " << test5->getIdentifier()->getDirectChildren()->toString() << "\n"; |
---|
174 | std::cout << test5->getIdentifier()->getName() << ": allChildren: " << test5->getIdentifier()->getAllChildren()->toString() << "\n"; |
---|
175 | } |
---|
176 | */ |
---|
177 | /* |
---|
178 | #define testandcout(code) \ |
---|
179 | std::cout << #code << " " << code << "\n" |
---|
180 | |
---|
181 | |
---|
182 | std::cout << "\n"; |
---|
183 | std::cout << "isA(XYZ)-Test:\n"; |
---|
184 | std::cout << "test5_01 = A1, Erwartet: 1 0 0 1 0\n"; |
---|
185 | testandcout(test5_01->isA(Class(A1))); |
---|
186 | testandcout(test5_01->isA(Class(A2))); |
---|
187 | testandcout(test5_01->isA(Class(A1B1))); |
---|
188 | testandcout(test5_01->isA(Class(BaseObject))); |
---|
189 | testandcout(test5_01->isA(Class(Interface1))); |
---|
190 | |
---|
191 | std::cout << "\n"; |
---|
192 | std::cout << "test5_02 = A2, Erwartet: 0 1 0 1 0\n"; |
---|
193 | testandcout(test5_02->isA(Class(A1))); |
---|
194 | testandcout(test5_02->isA(Class(A2))); |
---|
195 | testandcout(test5_02->isA(Class(A1B1))); |
---|
196 | testandcout(test5_02->isA(Class(BaseObject))); |
---|
197 | testandcout(test5_02->isA(Class(Interface1))); |
---|
198 | |
---|
199 | std::cout << "\n"; |
---|
200 | std::cout << "test5_01 = A3, Erwartet: 0 0 0 1 1\n"; |
---|
201 | testandcout(test5_03->isA(Class(A1))); |
---|
202 | testandcout(test5_03->isA(Class(A2))); |
---|
203 | testandcout(test5_03->isA(Class(A1B1))); |
---|
204 | testandcout(test5_03->isA(Class(BaseObject))); |
---|
205 | testandcout(test5_03->isA(Class(Interface1))); |
---|
206 | |
---|
207 | |
---|
208 | std::cout << "\n"; |
---|
209 | std::cout << "isDirectA(XYZ)-Test:\n"; |
---|
210 | std::cout << "test5_01 = A1, Erwartet: 1 0 0 0 0\n"; |
---|
211 | testandcout(test5_01->isDirectlyA(Class(A1))); |
---|
212 | testandcout(test5_01->isDirectlyA(Class(A2))); |
---|
213 | testandcout(test5_01->isDirectlyA(Class(A1B1))); |
---|
214 | testandcout(test5_01->isDirectlyA(Class(BaseObject))); |
---|
215 | testandcout(test5_01->isDirectlyA(Class(Interface1))); |
---|
216 | |
---|
217 | std::cout << "\n"; |
---|
218 | std::cout << "test5_02 = A2, Erwartet: 0 1 0 0 0\n"; |
---|
219 | testandcout(test5_02->isDirectlyA(Class(A1))); |
---|
220 | testandcout(test5_02->isDirectlyA(Class(A2))); |
---|
221 | testandcout(test5_02->isDirectlyA(Class(A1B1))); |
---|
222 | testandcout(test5_02->isDirectlyA(Class(BaseObject))); |
---|
223 | testandcout(test5_02->isDirectlyA(Class(Interface1))); |
---|
224 | |
---|
225 | std::cout << "\n"; |
---|
226 | std::cout << "test5_03 = A3, Erwartet: 0 0 0 0 0\n"; |
---|
227 | testandcout(test5_03->isDirectlyA(Class(A1))); |
---|
228 | testandcout(test5_03->isDirectlyA(Class(A2))); |
---|
229 | testandcout(test5_03->isDirectlyA(Class(A1B1))); |
---|
230 | testandcout(test5_03->isDirectlyA(Class(BaseObject))); |
---|
231 | testandcout(test5_03->isDirectlyA(Class(Interface1))); |
---|
232 | |
---|
233 | std::cout << "\n"; |
---|
234 | std::cout << "isChildOf(XYZ)-Test:\n"; |
---|
235 | std::cout << "test5_04 = A1B1, Erwartet: 1 0 1 0 0 0 0\n"; |
---|
236 | testandcout(test5_04->isChildOf(Class(A1))); |
---|
237 | testandcout(test5_04->isChildOf(Class(A2))); |
---|
238 | testandcout(test5_04->isChildOf(Class(BaseObject))); |
---|
239 | testandcout(test5_04->isChildOf(Class(Interface1))); |
---|
240 | testandcout(test5_04->isChildOf(Class(Interface2))); |
---|
241 | testandcout(test5_04->isChildOf(Class(A1B1C2))); |
---|
242 | testandcout(test5_04->isChildOf(Class(A1B1))); |
---|
243 | |
---|
244 | std::cout << "\n"; |
---|
245 | std::cout << "test5_06 = A2B1, Erwartet: 0 1 1 0 0 0 0\n"; |
---|
246 | testandcout(test5_06->isChildOf(Class(A1))); |
---|
247 | testandcout(test5_06->isChildOf(Class(A2))); |
---|
248 | testandcout(test5_06->isChildOf(Class(BaseObject))); |
---|
249 | testandcout(test5_06->isChildOf(Class(Interface1))); |
---|
250 | testandcout(test5_06->isChildOf(Class(Interface2))); |
---|
251 | testandcout(test5_06->isChildOf(Class(A1B1C2))); |
---|
252 | testandcout(test5_06->isChildOf(Class(A1B1))); |
---|
253 | |
---|
254 | std::cout << "\n"; |
---|
255 | std::cout << "test5_07 = A2B2, Erwartet: 0 1 1 1 0 0\n"; |
---|
256 | testandcout(test5_07->isChildOf(Class(A1))); |
---|
257 | testandcout(test5_07->isChildOf(Class(A2))); |
---|
258 | testandcout(test5_07->isChildOf(Class(BaseObject))); |
---|
259 | testandcout(test5_07->isChildOf(Class(Interface1))); |
---|
260 | testandcout(test5_07->isChildOf(Class(Interface2))); |
---|
261 | testandcout(test5_07->isChildOf(Class(A1B1C2))); |
---|
262 | |
---|
263 | std::cout << "\n"; |
---|
264 | std::cout << "test5_08 = A3B1, Erwartet: 0 0 1 1 0 0\n"; |
---|
265 | testandcout(test5_08->isChildOf(Class(A1))); |
---|
266 | testandcout(test5_08->isChildOf(Class(A2))); |
---|
267 | testandcout(test5_08->isChildOf(Class(BaseObject))); |
---|
268 | testandcout(test5_08->isChildOf(Class(Interface1))); |
---|
269 | testandcout(test5_08->isChildOf(Class(Interface2))); |
---|
270 | testandcout(test5_08->isChildOf(Class(A1B1C2))); |
---|
271 | |
---|
272 | std::cout << "\n"; |
---|
273 | std::cout << "test5_09 = A3B2, Erwartet: 0 0 1 1 1 0\n"; |
---|
274 | testandcout(test5_09->isChildOf(Class(A1))); |
---|
275 | testandcout(test5_09->isChildOf(Class(A2))); |
---|
276 | testandcout(test5_09->isChildOf(Class(BaseObject))); |
---|
277 | testandcout(test5_09->isChildOf(Class(Interface1))); |
---|
278 | testandcout(test5_09->isChildOf(Class(Interface2))); |
---|
279 | testandcout(test5_09->isChildOf(Class(A1B1C2))); |
---|
280 | |
---|
281 | std::cout << "\n"; |
---|
282 | std::cout << "isDirectChildOf(XYZ)-Test:\n"; |
---|
283 | std::cout << "test5_04 = A1B1, Erwartet: 1 0 0 0 0 0 0\n"; |
---|
284 | testandcout(test5_04->isDirectChildOf(Class(A1))); |
---|
285 | testandcout(test5_04->isDirectChildOf(Class(A2))); |
---|
286 | testandcout(test5_04->isDirectChildOf(Class(BaseObject))); |
---|
287 | testandcout(test5_04->isDirectChildOf(Class(Interface1))); |
---|
288 | testandcout(test5_04->isDirectChildOf(Class(Interface2))); |
---|
289 | testandcout(test5_04->isDirectChildOf(Class(A1B1C2))); |
---|
290 | testandcout(test5_04->isDirectChildOf(Class(A1B1))); |
---|
291 | |
---|
292 | std::cout << "\n"; |
---|
293 | std::cout << "test5_06 = A2B1, Erwartet: 0 1 0 0 0 0 0\n"; |
---|
294 | testandcout(test5_06->isDirectChildOf(Class(A1))); |
---|
295 | testandcout(test5_06->isDirectChildOf(Class(A2))); |
---|
296 | testandcout(test5_06->isDirectChildOf(Class(BaseObject))); |
---|
297 | testandcout(test5_06->isDirectChildOf(Class(Interface1))); |
---|
298 | testandcout(test5_06->isDirectChildOf(Class(Interface2))); |
---|
299 | testandcout(test5_06->isDirectChildOf(Class(A1B1C2))); |
---|
300 | testandcout(test5_06->isDirectChildOf(Class(A1B1))); |
---|
301 | |
---|
302 | std::cout << "\n"; |
---|
303 | std::cout << "test5_07 = A2B2, Erwartet: 0 1 0 1 0 0\n"; |
---|
304 | testandcout(test5_07->isDirectChildOf(Class(A1))); |
---|
305 | testandcout(test5_07->isDirectChildOf(Class(A2))); |
---|
306 | testandcout(test5_07->isDirectChildOf(Class(BaseObject))); |
---|
307 | testandcout(test5_07->isDirectChildOf(Class(Interface1))); |
---|
308 | testandcout(test5_07->isDirectChildOf(Class(Interface2))); |
---|
309 | testandcout(test5_07->isDirectChildOf(Class(A1B1C2))); |
---|
310 | |
---|
311 | std::cout << "\n"; |
---|
312 | std::cout << "test5_08 = A3B1, Erwartet: 0 0 0 0 0 0\n"; |
---|
313 | testandcout(test5_08->isDirectChildOf(Class(A1))); |
---|
314 | testandcout(test5_08->isDirectChildOf(Class(A2))); |
---|
315 | testandcout(test5_08->isDirectChildOf(Class(BaseObject))); |
---|
316 | testandcout(test5_08->isDirectChildOf(Class(Interface1))); |
---|
317 | testandcout(test5_08->isDirectChildOf(Class(Interface2))); |
---|
318 | testandcout(test5_08->isDirectChildOf(Class(A1B1C2))); |
---|
319 | |
---|
320 | std::cout << "\n"; |
---|
321 | std::cout << "test5_09 = A3B2, Erwartet: 0 0 0 0 1 0\n"; |
---|
322 | testandcout(test5_09->isDirectChildOf(Class(A1))); |
---|
323 | testandcout(test5_09->isDirectChildOf(Class(A2))); |
---|
324 | testandcout(test5_09->isDirectChildOf(Class(BaseObject))); |
---|
325 | testandcout(test5_09->isDirectChildOf(Class(Interface1))); |
---|
326 | testandcout(test5_09->isDirectChildOf(Class(Interface2))); |
---|
327 | testandcout(test5_09->isDirectChildOf(Class(A1B1C2))); |
---|
328 | |
---|
329 | std::cout << "\n"; |
---|
330 | std::cout << "isParentOf(XYZ)-Test:\n"; |
---|
331 | std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 1 1 1\n"; |
---|
332 | testandcout(test1->isParentOf(Class(BaseObject))); |
---|
333 | testandcout(test1->isParentOf(Class(Interface1))); |
---|
334 | testandcout(test1->isParentOf(Class(A1))); |
---|
335 | testandcout(test1->isParentOf(Class(A2))); |
---|
336 | testandcout(test1->isParentOf(Class(A1B1))); |
---|
337 | testandcout(test1->isParentOf(Class(A2B2))); |
---|
338 | testandcout(test1->isParentOf(Class(A3B1C2))); |
---|
339 | |
---|
340 | std::cout << "\n"; |
---|
341 | std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n"; |
---|
342 | testandcout(test5_01->isParentOf(Class(BaseObject))); |
---|
343 | testandcout(test5_01->isParentOf(Class(Interface1))); |
---|
344 | testandcout(test5_01->isParentOf(Class(A1))); |
---|
345 | testandcout(test5_01->isParentOf(Class(A2))); |
---|
346 | testandcout(test5_01->isParentOf(Class(A1B1))); |
---|
347 | testandcout(test5_01->isParentOf(Class(A2B2))); |
---|
348 | testandcout(test5_01->isParentOf(Class(A3B1C2))); |
---|
349 | |
---|
350 | std::cout << "\n"; |
---|
351 | std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 1\n"; |
---|
352 | testandcout(Class(Interface1)->isParentOf(Class(BaseObject))); |
---|
353 | testandcout(Class(Interface1)->isParentOf(Class(Interface1))); |
---|
354 | testandcout(Class(Interface1)->isParentOf(Class(A1))); |
---|
355 | testandcout(Class(Interface1)->isParentOf(Class(A2))); |
---|
356 | testandcout(Class(Interface1)->isParentOf(Class(A1B1))); |
---|
357 | testandcout(Class(Interface1)->isParentOf(Class(A2B2))); |
---|
358 | testandcout(Class(Interface1)->isParentOf(Class(A3B1C2))); |
---|
359 | |
---|
360 | std::cout << "\n"; |
---|
361 | std::cout << "isDirectParentOf(XYZ)-Test:\n"; |
---|
362 | std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 0 0 0\n"; |
---|
363 | testandcout(test1->isDirectParentOf(Class(BaseObject))); |
---|
364 | testandcout(test1->isDirectParentOf(Class(Interface1))); |
---|
365 | testandcout(test1->isDirectParentOf(Class(A1))); |
---|
366 | testandcout(test1->isDirectParentOf(Class(A2))); |
---|
367 | testandcout(test1->isDirectParentOf(Class(A1B1))); |
---|
368 | testandcout(test1->isDirectParentOf(Class(A2B2))); |
---|
369 | testandcout(test1->isDirectParentOf(Class(A3B1C2))); |
---|
370 | |
---|
371 | std::cout << "\n"; |
---|
372 | std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n"; |
---|
373 | testandcout(test5_01->isDirectParentOf(Class(BaseObject))); |
---|
374 | testandcout(test5_01->isDirectParentOf(Class(Interface1))); |
---|
375 | testandcout(test5_01->isDirectParentOf(Class(A1))); |
---|
376 | testandcout(test5_01->isDirectParentOf(Class(A2))); |
---|
377 | testandcout(test5_01->isDirectParentOf(Class(A1B1))); |
---|
378 | testandcout(test5_01->isDirectParentOf(Class(A2B2))); |
---|
379 | testandcout(test5_01->isDirectParentOf(Class(A3B1C2))); |
---|
380 | |
---|
381 | std::cout << "\n"; |
---|
382 | std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 0\n"; |
---|
383 | testandcout(Class(Interface1)->isDirectParentOf(Class(BaseObject))); |
---|
384 | testandcout(Class(Interface1)->isDirectParentOf(Class(Interface1))); |
---|
385 | testandcout(Class(Interface1)->isDirectParentOf(Class(A1))); |
---|
386 | testandcout(Class(Interface1)->isDirectParentOf(Class(A2))); |
---|
387 | testandcout(Class(Interface1)->isDirectParentOf(Class(A1B1))); |
---|
388 | testandcout(Class(Interface1)->isDirectParentOf(Class(A2B2))); |
---|
389 | testandcout(Class(Interface1)->isDirectParentOf(Class(A3B1C2))); |
---|
390 | */ |
---|
391 | /* |
---|
392 | std::cout << "Test 6\n"; |
---|
393 | std::cout << "1:\n"; |
---|
394 | Identifier* test6_01 = Class(A1B1); |
---|
395 | std::cout << "2:\n"; |
---|
396 | Identifier* test6_02 = Class(A1B1); |
---|
397 | std::cout << "3:\n"; |
---|
398 | Identifier* test6_03 = Class(A1); |
---|
399 | std::cout << "4:\n"; |
---|
400 | Identifier* test6_04 = Class(A1B1C1); |
---|
401 | std::cout << "5:\n"; |
---|
402 | Identifier* test6_05 = Class(A1B1); |
---|
403 | std::cout << "6:\n"; |
---|
404 | Identifier* test6_06 = Class(A1B1C1); |
---|
405 | */ |
---|
406 | /* |
---|
407 | std::cout << "\n"; |
---|
408 | std::cout << "BaseObject: directParents: " << Class(BaseObject)->getDirectParents()->toString() << "\n"; |
---|
409 | std::cout << "BaseObject: allParents: " << Class(BaseObject)->getAllParents()->toString() << "\n"; |
---|
410 | std::cout << "BaseObject: directChildren: " << Class(BaseObject)->getDirectChildren()->toString() << "\n"; |
---|
411 | std::cout << "BaseObject: allChildren: " << Class(BaseObject)->getAllChildren()->toString() << "\n"; |
---|
412 | |
---|
413 | std::cout << "\n"; |
---|
414 | std::cout << "A1: directParents: " << Class(A1)->getDirectParents()->toString() << "\n"; |
---|
415 | std::cout << "A1: allParents: " << Class(A1)->getAllParents()->toString() << "\n"; |
---|
416 | std::cout << "A1: directChildren: " << Class(A1)->getDirectChildren()->toString() << "\n"; |
---|
417 | std::cout << "A1: allChildren: " << Class(A1)->getAllChildren()->toString() << "\n"; |
---|
418 | |
---|
419 | std::cout << "\n"; |
---|
420 | std::cout << "A1B1: directParents: " << Class(A1B1)->getDirectParents()->toString() << "\n"; |
---|
421 | std::cout << "A1B1: allParents: " << Class(A1B1)->getAllParents()->toString() << "\n"; |
---|
422 | std::cout << "A1B1: directChildren: " << Class(A1B1)->getDirectChildren()->toString() << "\n"; |
---|
423 | std::cout << "A1B1: allChildren: " << Class(A1B1)->getAllChildren()->toString() << "\n"; |
---|
424 | |
---|
425 | std::cout << "\n"; |
---|
426 | std::cout << "A1B1C1: directParents: " << Class(A1B1C1)->getDirectParents()->toString() << "\n"; |
---|
427 | std::cout << "A1B1C1: allParents: " << Class(A1B1C1)->getAllParents()->toString() << "\n"; |
---|
428 | std::cout << "A1B1C1: directChildren: " << Class(A1B1C1)->getDirectChildren()->toString() << "\n"; |
---|
429 | std::cout << "A1B1C1: allChildren: " << Class(A1B1C1)->getAllChildren()->toString() << "\n"; |
---|
430 | |
---|
431 | std::cout << "\n"; |
---|
432 | std::cout << "A3B1C1 child of A3: " << Class(A3B1C1)->isChildOf(Class(A3)) << "\n"; |
---|
433 | std::cout << "\n"; |
---|
434 | std::cout << "A2 parent of A2B1C1: " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n"; |
---|
435 | */ |
---|
436 | |
---|
437 | std::cout << "Test 7\n"; |
---|
438 | std::cout << "1\n"; |
---|
439 | BaseIdentifier<A1B1> test7_01; |
---|
440 | test7_01 = Class(A1B1C1); |
---|
441 | |
---|
442 | BaseIdentifier<A1B1> test7_02; |
---|
443 | test7_02 = Class(A1B1); |
---|
444 | |
---|
445 | // std::cout << Identifier(test7_02).getName() << "\n"; |
---|
446 | |
---|
447 | /* |
---|
448 | BaseIdentifier<A1B1> test7_03; |
---|
449 | test7_03 = Class(A1); |
---|
450 | |
---|
451 | BaseIdentifier<A1B1> test7_04; |
---|
452 | test7_04 = Class(A1B2); |
---|
453 | |
---|
454 | BaseIdentifier<A1B1> test7_05; |
---|
455 | test7_05 = Class(A2); |
---|
456 | */ |
---|
457 | std::cout << "2\n"; |
---|
458 | |
---|
459 | |
---|
460 | } |
---|
461 | |
---|
462 | ~OrxApplication() |
---|
463 | { |
---|
464 | mInputManager->destroyInputObject(mKeyboard); |
---|
465 | OIS::InputManager::destroyInputSystem(mInputManager); |
---|
466 | |
---|
467 | delete mRenderer; |
---|
468 | delete mSystem; |
---|
469 | |
---|
470 | delete mListener; |
---|
471 | delete mRoot; |
---|
472 | } |
---|
473 | |
---|
474 | private: |
---|
475 | Ogre::Root *mRoot; |
---|
476 | OIS::Keyboard *mKeyboard; |
---|
477 | OIS::Mouse *mMouse; |
---|
478 | OIS::InputManager *mInputManager; |
---|
479 | CEGUI::OgreCEGUIRenderer *mRenderer; |
---|
480 | CEGUI::System *mSystem; |
---|
481 | OrxExitListener *mListener; |
---|
482 | |
---|
483 | void createRoot() |
---|
484 | { |
---|
485 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
486 | mRoot = new Ogre::Root(macBundlePath() + "/Contents/Resources/plugins.cfg"); |
---|
487 | #else |
---|
488 | mRoot = new Ogre::Root(); |
---|
489 | #endif |
---|
490 | } |
---|
491 | |
---|
492 | void defineResources() |
---|
493 | { |
---|
494 | Ogre::String secName, typeName, archName; |
---|
495 | Ogre::ConfigFile cf; |
---|
496 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
497 | cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); |
---|
498 | #else |
---|
499 | cf.load("resources.cfg"); |
---|
500 | #endif |
---|
501 | |
---|
502 | Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); |
---|
503 | while (seci.hasMoreElements()) |
---|
504 | { |
---|
505 | secName = seci.peekNextKey(); |
---|
506 | Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); |
---|
507 | Ogre::ConfigFile::SettingsMultiMap::iterator i; |
---|
508 | for (i = settings->begin(); i != settings->end(); ++i) |
---|
509 | { |
---|
510 | typeName = i->first; |
---|
511 | archName = i->second; |
---|
512 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
513 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName); |
---|
514 | #else |
---|
515 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); |
---|
516 | #endif |
---|
517 | } |
---|
518 | } |
---|
519 | } |
---|
520 | |
---|
521 | void setupRenderSystem() |
---|
522 | { |
---|
523 | if (!mRoot->restoreConfig() && !mRoot->showConfigDialog()) |
---|
524 | throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); |
---|
525 | } |
---|
526 | |
---|
527 | void createRenderWindow() |
---|
528 | { |
---|
529 | mRoot->initialise(true, "Ogre Render Window"); |
---|
530 | } |
---|
531 | |
---|
532 | void initializeResourceGroups() |
---|
533 | { |
---|
534 | Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); |
---|
535 | Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); |
---|
536 | } |
---|
537 | |
---|
538 | void setupScene() |
---|
539 | { |
---|
540 | Ogre::SceneManager *mgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager"); |
---|
541 | Ogre::Camera *cam = mgr->createCamera("Camera"); |
---|
542 | Ogre::Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam); |
---|
543 | } |
---|
544 | |
---|
545 | void setupInputSystem() |
---|
546 | { |
---|
547 | size_t windowHnd = 0; |
---|
548 | std::ostringstream windowHndStr; |
---|
549 | OIS::ParamList pl; |
---|
550 | Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); |
---|
551 | |
---|
552 | win->getCustomAttribute("WINDOW", &windowHnd); |
---|
553 | windowHndStr << windowHnd; |
---|
554 | pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); |
---|
555 | mInputManager = OIS::InputManager::createInputSystem(pl); |
---|
556 | |
---|
557 | try |
---|
558 | { |
---|
559 | mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false)); |
---|
560 | mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false)); |
---|
561 | } |
---|
562 | catch (const OIS::Exception &e) |
---|
563 | { |
---|
564 | throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem"); |
---|
565 | } |
---|
566 | } |
---|
567 | |
---|
568 | void setupCEGUI() |
---|
569 | { |
---|
570 | Ogre::SceneManager *mgr = mRoot->getSceneManager("Default SceneManager"); |
---|
571 | Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); |
---|
572 | |
---|
573 | // CEGUI setup |
---|
574 | mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr); |
---|
575 | mSystem = new CEGUI::System(mRenderer); |
---|
576 | |
---|
577 | // Other CEGUI setup here. |
---|
578 | } |
---|
579 | |
---|
580 | void createFrameListener() |
---|
581 | { |
---|
582 | mListener = new OrxExitListener(mKeyboard); |
---|
583 | mRoot->addFrameListener(mListener); |
---|
584 | } |
---|
585 | |
---|
586 | void startRenderLoop() |
---|
587 | { |
---|
588 | mRoot->startRendering(); |
---|
589 | } |
---|
590 | }; |
---|
591 | } |
---|
592 | |
---|
593 | using namespace Ogre; |
---|
594 | |
---|
595 | #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
596 | #define WIN32_LEAN_AND_MEAN |
---|
597 | #include "windows.h" |
---|
598 | |
---|
599 | INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) |
---|
600 | #else |
---|
601 | int main(int argc, char **argv) |
---|
602 | #endif |
---|
603 | { |
---|
604 | try |
---|
605 | { |
---|
606 | orxonox::OrxApplication orxonox; |
---|
607 | orxonox.go(); |
---|
608 | } |
---|
609 | catch(Exception& e) |
---|
610 | { |
---|
611 | #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
612 | MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); |
---|
613 | #else |
---|
614 | fprintf(stderr, "An exception has occurred: %s\n", |
---|
615 | e.getFullDescription().c_str()); |
---|
616 | #endif |
---|
617 | } |
---|
618 | |
---|
619 | return 0; |
---|
620 | } |
---|