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