Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/orxonox.cc @ 454

Last change on this file since 454 was 454, checked in by landauf, 17 years ago

no idea if this works: added chrigis SignalHandler from orxonox_v1 to catch SIGSEGV, SIGABRT and SIGILL signals and write debug informations into orxonox.log

File size: 29.7 KB
Line 
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/**
29 @file  orxonox.cc
30 @brief Orxonox Main File
31 */
32
33#include <Ogre.h>
34#include <OIS/OIS.h>
35#include <CEGUI/CEGUI.h>
36#include <OgreCEGUIRenderer.h>
37
38#include <string>
39#include <iostream>
40
41//#include "../xml/xmlParser.h"
42//#include "../loader/LevelLoader.h"
43
44#include "core/CoreIncludes.h"
45#include "core/SignalHandler.h"
46#include "objects/Tickable.h"
47#include "objects/Timer.h"
48
49#include "objects/BaseObject.h"
50#include "objects/Test.h"
51#include "objects/test1.h"
52#include "objects/test2.h"
53#include "objects/test3.h"
54
55// some tests to see if enet works without includsion
56//#include <enet/enet.h>
57//#include <enet/protocol.h>
58
59#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
60#include <CoreFoundation/CoreFoundation.h>
61
62// This function will locate the path to our application on OS X,
63// unlike windows you can not rely on the curent working directory
64// for locating your configuration files and resources.
65std::string macBundlePath()
66{
67  char path[1024];
68  CFBundleRef mainBundle = CFBundleGetMainBundle();
69  assert(mainBundle);
70
71  CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
72  assert(mainBundleURL);
73
74  CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
75  assert(cfStringRef);
76
77  CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
78
79  CFRelease(mainBundleURL);
80  CFRelease(cfStringRef);
81
82  return std::string(path);
83}
84#endif
85
86namespace orxonox
87{
88  class OrxExitListener : public Ogre::FrameListener
89  {
90    public:
91      OrxExitListener(OIS::Keyboard *keyboard)
92    : mKeyboard(keyboard)
93      {
94      }
95
96      bool frameStarted(const Ogre::FrameEvent& evt)
97      {
98        mKeyboard->capture();
99        return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
100      }
101
102    private:
103      OIS::Keyboard *mKeyboard;
104  };
105
106  class OrxApplication
107  {
108    public:
109      void go()
110      {
111        createRoot();
112        defineResources();
113        setupRenderSystem();
114        createRenderWindow();
115        initializeResourceGroups();
116        createScene();
117        setupScene();
118        setupInputSystem();
119        setupCEGUI();
120        createFrameListener();
121
122
123        #define testandcout(code) \
124          std::cout << #code << " " << code << "\n"
125
126/*
127        std::cout << "Test 1\n";
128        BaseObject* test1;
129        test1 = new BaseObject();
130        test1 = new BaseObject();
131        test1 = new BaseObject();
132
133        std::cout << "Test 2\n";
134        A1* test2;
135        test2 = new A1();
136        test2 = new A1();
137        test2 = new A1();
138
139        std::cout << "Test 3\n";
140        BaseObject* test3;
141        test3 = new BaseObject();
142        test3 = new BaseObject();
143        test3 = new BaseObject();
144
145        std::cout << "Test 4\n";
146        A3* test4;
147        test4 = new A3();
148        test4 = new A3();
149        test4 = new A3();
150*/
151/*
152        std::cout << "Test 5\n";
153        A1* test5_01 = new A1();
154        A2* test5_02 = new A2();
155        A3* test5_03 = new A3();
156        A1B1* test5_04 = new A1B1();
157        A1B2* test5_05 = new A1B2();
158        A2B1* test5_06 = new A2B1();
159        A2B2* test5_07 = new A2B2();
160        A3B1* test5_08 = new A3B1();
161        A3B2* test5_09 = new A3B2();
162        A1B1C1* test5_10 = new A1B1C1();
163        A1B1C2* test5_11 = new A1B1C2();
164        A1B2C1* test5_12 = new A1B2C1();
165        A2B1C1* test5_13 = new A2B1C1();
166        A2B2C1* test5_14 = new A2B2C1();
167        A3B1C1* test5_15 = new A3B1C1();
168        A3B1C2* test5_16 = new A3B1C2();
169        A3B2C1* test5_17 = new A3B2C1();
170        A3B2C2* test5_18 = new A3B2C2();
171
172        OrxonoxClass* test5;
173        for (int i = 0; i <= 18; i++)
174        {
175          if (i == 0) test5 = new BaseObject;
176          if (i == 1) test5 = test5_01;
177          if (i == 2) test5 = test5_02;
178          if (i == 3) test5 = test5_03;
179          if (i == 4) test5 = test5_04;
180          if (i == 5) test5 = test5_05;
181          if (i == 6) test5 = test5_06;
182          if (i == 7) test5 = test5_07;
183          if (i == 8) test5 = test5_08;
184          if (i == 9) test5 = test5_09;
185          if (i == 10) test5 = test5_10;
186          if (i == 11) test5 = test5_11;
187          if (i == 12) test5 = test5_12;
188          if (i == 13) test5 = test5_13;
189          if (i == 14) test5 = test5_14;
190          if (i == 15) test5 = test5_15;
191          if (i == 16) test5 = test5_16;
192          if (i == 17) test5 = test5_17;
193          if (i == 18) test5 = test5_18;
194
195          std::cout << "\n";
196          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): parents:     " << test5->getIdentifier()->getParents().toString() << "\n";
197          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): children:    " << test5->getIdentifier()->getChildren().toString() << "\n";
198        }
199
200        std::cout << "Class with ID 0: " << ID(0) << " " << ID(0)->getName() << "\n";
201        std::cout << "Class with ID 1: " << ID(1) << " " << ID(1)->getName() << "\n";
202        std::cout << "Class with ID 2: " << ID(2) << " " << ID(2)->getName() << "\n";
203        std::cout << "Class with ID 3: " << ID(3) << " " << ID(3)->getName() << "\n";
204        std::cout << "Class with ID 4: " << ID(4) << " " << ID(4)->getName() << "\n";
205        std::cout << "Class with ID 100: " << ID(100) << "\n";
206        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
207
208        std::cout << "\nChange ID of BaseObject to 100\n";
209        Class(BaseObject)->setNetworkID(100);
210        std::cout << "Class with ID 100: " << ID(100) << "\n";
211        std::cout << "Class with ID 1: " << ID(1) << "\n";
212        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
213
214        std::cout << "\nChange ID of BaseObject to 3\n";
215        Class(BaseObject)->setNetworkID(3);
216        std::cout << "Class with ID 100: " << ID(100) << "\n";
217        std::cout << "Class with ID 1: " << ID(1) << "\n";
218        std::cout << "Class with ID 3: " << ID(3) << "\n";
219        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
220        std::cout << "ID of Test1: " << Class(Test1)->getNetworkID() << "\n";
221*/
222/*
223        std::cout << "\n";
224        std::cout << "isA(XYZ)-Test:\n";
225        std::cout << "test5_01 = A1, Erwartet: 1 0 0 1 0\n";
226        testandcout(test5_01->isA(Class(A1)));
227        testandcout(test5_01->isA(Class(A2)));
228        testandcout(test5_01->isA(Class(A1B1)));
229        testandcout(test5_01->isA(Class(BaseObject)));
230        testandcout(test5_01->isA(Class(Interface1)));
231
232        std::cout << "\n";
233        std::cout << "test5_02 = A2, Erwartet: 0 1 0 1 0\n";
234        testandcout(test5_02->isA(Class(A1)));
235        testandcout(test5_02->isA(Class(A2)));
236        testandcout(test5_02->isA(Class(A1B1)));
237        testandcout(test5_02->isA(Class(BaseObject)));
238        testandcout(test5_02->isA(Class(Interface1)));
239
240        std::cout << "\n";
241        std::cout << "test5_01 = A3, Erwartet: 0 0 0 1 1\n";
242        testandcout(test5_03->isA(Class(A1)));
243        testandcout(test5_03->isA(Class(A2)));
244        testandcout(test5_03->isA(Class(A1B1)));
245        testandcout(test5_03->isA(Class(BaseObject)));
246        testandcout(test5_03->isA(Class(Interface1)));
247
248        std::cout << "\n";
249        std::cout << "isDirectA(XYZ)-Test:\n";
250        std::cout << "test5_01 = A1, Erwartet: 1 0 0 0 0\n";
251        testandcout(test5_01->isDirectlyA(Class(A1)));
252        testandcout(test5_01->isDirectlyA(Class(A2)));
253        testandcout(test5_01->isDirectlyA(Class(A1B1)));
254        testandcout(test5_01->isDirectlyA(Class(BaseObject)));
255        testandcout(test5_01->isDirectlyA(Class(Interface1)));
256
257        std::cout << "\n";
258        std::cout << "test5_02 = A2, Erwartet: 0 1 0 0 0\n";
259        testandcout(test5_02->isDirectlyA(Class(A1)));
260        testandcout(test5_02->isDirectlyA(Class(A2)));
261        testandcout(test5_02->isDirectlyA(Class(A1B1)));
262        testandcout(test5_02->isDirectlyA(Class(BaseObject)));
263        testandcout(test5_02->isDirectlyA(Class(Interface1)));
264
265        std::cout << "\n";
266        std::cout << "test5_03 = A3, Erwartet: 0 0 0 0 0\n";
267        testandcout(test5_03->isDirectlyA(Class(A1)));
268        testandcout(test5_03->isDirectlyA(Class(A2)));
269        testandcout(test5_03->isDirectlyA(Class(A1B1)));
270        testandcout(test5_03->isDirectlyA(Class(BaseObject)));
271        testandcout(test5_03->isDirectlyA(Class(Interface1)));
272
273        std::cout << "\n";
274        std::cout << "isChildOf(XYZ)-Test:\n";
275        std::cout << "test5_04 = A1B1, Erwartet: 1 0 1 0 0 0 0\n";
276        testandcout(test5_04->isChildOf(Class(A1)));
277        testandcout(test5_04->isChildOf(Class(A2)));
278        testandcout(test5_04->isChildOf(Class(BaseObject)));
279        testandcout(test5_04->isChildOf(Class(Interface1)));
280        testandcout(test5_04->isChildOf(Class(Interface2)));
281        testandcout(test5_04->isChildOf(Class(A1B1C2)));
282        testandcout(test5_04->isChildOf(Class(A1B1)));
283
284        std::cout << "\n";
285        std::cout << "test5_06 = A2B1, Erwartet: 0 1 1 0 0 0 0\n";
286        testandcout(test5_06->isChildOf(Class(A1)));
287        testandcout(test5_06->isChildOf(Class(A2)));
288        testandcout(test5_06->isChildOf(Class(BaseObject)));
289        testandcout(test5_06->isChildOf(Class(Interface1)));
290        testandcout(test5_06->isChildOf(Class(Interface2)));
291        testandcout(test5_06->isChildOf(Class(A1B1C2)));
292        testandcout(test5_06->isChildOf(Class(A1B1)));
293
294        std::cout << "\n";
295        std::cout << "test5_07 = A2B2, Erwartet: 0 1 1 1 0 0\n";
296        testandcout(test5_07->isChildOf(Class(A1)));
297        testandcout(test5_07->isChildOf(Class(A2)));
298        testandcout(test5_07->isChildOf(Class(BaseObject)));
299        testandcout(test5_07->isChildOf(Class(Interface1)));
300        testandcout(test5_07->isChildOf(Class(Interface2)));
301        testandcout(test5_07->isChildOf(Class(A1B1C2)));
302
303        std::cout << "\n";
304        std::cout << "test5_08 = A3B1, Erwartet: 0 0 1 1 0 0\n";
305        testandcout(test5_08->isChildOf(Class(A1)));
306        testandcout(test5_08->isChildOf(Class(A2)));
307        testandcout(test5_08->isChildOf(Class(BaseObject)));
308        testandcout(test5_08->isChildOf(Class(Interface1)));
309        testandcout(test5_08->isChildOf(Class(Interface2)));
310        testandcout(test5_08->isChildOf(Class(A1B1C2)));
311
312        std::cout << "\n";
313        std::cout << "test5_09 = A3B2, Erwartet: 0 0 1 1 1 0\n";
314        testandcout(test5_09->isChildOf(Class(A1)));
315        testandcout(test5_09->isChildOf(Class(A2)));
316        testandcout(test5_09->isChildOf(Class(BaseObject)));
317        testandcout(test5_09->isChildOf(Class(Interface1)));
318        testandcout(test5_09->isChildOf(Class(Interface2)));
319        testandcout(test5_09->isChildOf(Class(A1B1C2)));
320
321        std::cout << "\n";
322        std::cout << "isParentOf(XYZ)-Test:\n";
323        std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 1 1 1\n";
324        testandcout(test1->isParentOf(Class(BaseObject)));
325        testandcout(test1->isParentOf(Class(Interface1)));
326        testandcout(test1->isParentOf(Class(A1)));
327        testandcout(test1->isParentOf(Class(A2)));
328        testandcout(test1->isParentOf(Class(A1B1)));
329        testandcout(test1->isParentOf(Class(A2B2)));
330        testandcout(test1->isParentOf(Class(A3B1C2)));
331
332        std::cout << "\n";
333        std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n";
334        testandcout(test5_01->isParentOf(Class(BaseObject)));
335        testandcout(test5_01->isParentOf(Class(Interface1)));
336        testandcout(test5_01->isParentOf(Class(A1)));
337        testandcout(test5_01->isParentOf(Class(A2)));
338        testandcout(test5_01->isParentOf(Class(A1B1)));
339        testandcout(test5_01->isParentOf(Class(A2B2)));
340        testandcout(test5_01->isParentOf(Class(A3B1C2)));
341
342        std::cout << "\n";
343        std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 1\n";
344        testandcout(Class(Interface1)->isParentOf(Class(BaseObject)));
345        testandcout(Class(Interface1)->isParentOf(Class(Interface1)));
346        testandcout(Class(Interface1)->isParentOf(Class(A1)));
347        testandcout(Class(Interface1)->isParentOf(Class(A2)));
348        testandcout(Class(Interface1)->isParentOf(Class(A1B1)));
349        testandcout(Class(Interface1)->isParentOf(Class(A2B2)));
350        testandcout(Class(Interface1)->isParentOf(Class(A3B1C2)));
351*/
352/*
353        std::cout << "Test 6\n";
354        std::cout << "1:\n";
355        Identifier* test6_01 = Class(A1B1);
356        std::cout << "2:\n";
357        Identifier* test6_02 = Class(A1B1);
358        std::cout << "3:\n";
359        Identifier* test6_03 = Class(A1);
360        std::cout << "4:\n";
361        Identifier* test6_04 = Class(A1B1C1);
362        std::cout << "5:\n";
363        Identifier* test6_05 = Class(A1B1);
364        std::cout << "6:\n";
365        Identifier* test6_06 = Class(A1B1C1);
366
367        std::cout << "\n";
368        std::cout << "BaseObject: parents:     " << Class(BaseObject)->getParents().toString() << "\n";
369        std::cout << "BaseObject: children:    " << Class(BaseObject)->getChildren().toString() << "\n";
370
371        std::cout << "\n";
372        std::cout << "A1: parents:     " << Class(A1)->getParents().toString() << "\n";
373        std::cout << "A1: children:    " << Class(A1)->getChildren().toString() << "\n";
374
375        std::cout << "\n";
376        std::cout << "A1B1: parents:     " << Class(A1B1)->getParents().toString() << "\n";
377        std::cout << "A1B1: children:    " << Class(A1B1)->getChildren().toString() << "\n";
378
379        std::cout << "\n";
380        std::cout << "A1B1C1: parents:     " << Class(A1B1C1)->getParents().toString() << "\n";
381        std::cout << "A1B1C1: children:    " << Class(A1B1C1)->getChildren().toString() << "\n";
382
383        std::cout << "\n";
384        std::cout << "A3B1C1 child of A3:  " << Class(A3B1C1)->isChildOf(Class(A3)) << "\n";
385        std::cout << "\n";
386        std::cout << "A2 parent of A2B1C1: " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n";
387*/
388/*
389        std::cout << "Test 7\n";
390        std::cout << "1\n";
391        SubclassIdentifier<A1B1> test7_01;
392        test7_01 = Class(A1B1C1);
393
394        SubclassIdentifier<A1B1> test7_02;
395        test7_02 = Class(A1B1);
396
397        std::cout << test7_01->getName() << "\n";
398        std::cout << test7_02->getName() << "\n";
399*/
400/*
401        std::cout << "2\n";
402
403        SubclassIdentifier<A1B1> test7_03;
404        test7_03 = Class(A1);
405
406        SubclassIdentifier<A1B1> test7_04;
407        test7_04 = Class(A1B2);
408
409        SubclassIdentifier<A1B1> test7_05;
410        test7_05 = Class(A2);
411*/
412/*
413        std::cout << "Test 8\n";
414
415        std::cout << "1\n";
416        Test1* test8_01 = new Test1;
417        Test3* test8_03 = new Test3;
418        test8_03->usefullClassesIsATest(test8_01);
419
420        std::cout << "2\n";
421        Test2* test8_02 = new Test2;
422        test8_03->usefullClassesIsATest(test8_02);
423
424        std::cout << "3\n";
425        test8_01->setUsefullClass1(Class(Test1));
426        test8_01->setUsefullClass1(test8_02->getIdentifier());
427        test8_01->setUsefullClass2(Class(Test2));
428        test8_01->setUsefullClassOfTypeTest3(Class(Test3));
429        test8_01->setUsefullClassOfTypeTest3(test8_03->getIdentifier());
430
431
432        testandcout(test8_01->isA(Class(Test1)));
433        testandcout(test8_01->isA(Class(Test2)));
434        testandcout(test8_01->isA(Class(Test3)));
435
436        Test2* test8_04 = new Test2;
437        testandcout(test8_02->isA(Class(Test1)));
438        testandcout(test8_02->isA(Class(Test2)));
439        testandcout(test8_02->isA(Class(Test3)));
440
441        Test3* test8_05 = new Test3;
442        testandcout(test8_03->isA(Class(Test1)));
443        testandcout(test8_03->isA(Class(Test2)));
444        testandcout(test8_03->isA(Class(Test3)));
445
446        delete test8_01;
447        delete test8_02;
448        delete test8_03;
449
450
451        std::cout << "Test 9\n";
452        std::cout << "1\n";
453        Identifier* test9_01 = Class(A3);
454        BaseObject* test9_02 = test9_01->fabricate();
455        std::cout << test9_02->getIdentifier()->getName() << "\n";
456
457        std::cout << "\n2\n";
458        BaseObject* test9_03 = Class(A1B2)->fabricate();
459        std::cout << test9_03->getIdentifier()->getName() << "\n";
460
461        std::cout << "\n3\n";
462        SubclassIdentifier<A1> test9_04;
463        test9_04 = Class(A1B1C1);
464        A1* test9_05 = test9_04.fabricate();
465        std::cout << test9_05->getIdentifier()->getName() << "\n";
466
467        std::cout << "\n4\n";
468        BaseObject* test9_06 = ID("A2B2")->fabricate();
469        std::cout << test9_06->getIdentifier()->getName() << "\n";
470
471        std::cout << "\n5\n";
472        delete test9_02;
473        delete test9_03;
474        delete test9_05;
475        delete test9_06;
476*/
477/*
478        std::cout << "Test 10\n";
479        Identifier* test10_01 = Class(A1B2);
480        Identifier* test10_02 = Class(A2);
481        Identifier* test10_03 = Class(A3B1C1);
482
483        BaseObject* test10_04 = test10_01->fabricate();
484        BaseObject* test10_05 = test10_02->fabricate();
485        BaseObject* test10_06 = test10_03->fabricate();
486
487        BaseObject* test10_07;
488        for (int i = 0; i < 10; i++)
489            test10_07 = ID("A1B1C1")->fabricate();
490
491        std::cout << "1\n";
492        int count;
493
494        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; }
495        std::cout << "Anzahl BaseObjects: " << count << "\n";
496        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; }
497        std::cout << "Anzahl A1: " << count << "\n";
498        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
499        std::cout << "Anzahl A1B1: " << count << "\n";
500        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
501        std::cout << "Anzahl A1B1C1: " << count << "\n";
502        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
503        std::cout << "Anzahl A2: " << count << "\n";
504
505        std::cout << "2\n";
506        BaseObject* test10_08;
507        BaseObject* test10_09;
508        BaseObject* test10_10;
509        for (int i = 0; i < 10; i++)
510        {
511            test10_08 = ID("A2B1C1")->fabricate();
512            std::string objName = "A2B1C1#";
513            objName += '0' + i;
514            test10_08->setName(objName);
515
516            if (i == 0)
517                test10_09 = test10_08;
518
519            if (i == 5)
520                test10_10 = test10_08;
521        }
522
523        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; }
524        std::cout << "Anzahl BaseObjects: " << count << "\n";
525        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; }
526        std::cout << "Anzahl A1: " << count << "\n";
527        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
528        std::cout << "Anzahl A1B1: " << count << "\n";
529        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
530        std::cout << "Anzahl A1B1C1: " << count << "\n";
531        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
532        std::cout << "Anzahl A2: " << count << "\n";
533
534        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
535            std::cout << "Name: " << it->getName() << "\n";
536
537        std::cout << "3\n";
538        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
539            std::cout << "Name: " << it->getName() << "\n";
540
541        std::cout << "4\n";
542        delete test10_08;
543
544        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; }
545        std::cout << "Anzahl BaseObjects: " << count << "\n";
546        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; }
547        std::cout << "Anzahl A1: " << count << "\n";
548        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
549        std::cout << "Anzahl A1B1: " << count << "\n";
550        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
551        std::cout << "Anzahl A1B1C1: " << count << "\n";
552        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
553        std::cout << "Anzahl A2: " << count << "\n";
554
555        std::cout << "5\n";
556        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
557            std::cout << "Name: " << it->getName() << "\n";
558
559        std::cout << "6\n";
560        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
561            std::cout << "Name: " << it->getName() << "\n";
562
563        std::cout << "7\n";
564        delete test10_09;
565
566        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::end(); it != 0; --it) { count++; }
567        std::cout << "Anzahl BaseObjects: " << count << "\n";
568        count = 0; for (Iterator<A1> it = ObjectList<A1>::end(); it != 0; --it) { count++; }
569        std::cout << "Anzahl A1: " << count << "\n";
570        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::end(); it; --it) { count++; }
571        std::cout << "Anzahl A1B1: " << count << "\n";
572        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::end(); it; --it) { count++; }
573        std::cout << "Anzahl A1B1C1: " << count << "\n";
574        count = 0; for (Iterator<A2> it = ObjectList<A2>::end(); it; --it) { count++; }
575        std::cout << "Anzahl A2: " << count << "\n";
576
577        std::cout << "8\n";
578        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
579            std::cout << "Name: " << it->getName() << "\n";
580
581        std::cout << "9\n";
582        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
583            std::cout << "Name: " << it->getName() << "\n";
584
585        std::cout << "10\n";
586        delete test10_10;
587
588        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; }
589        std::cout << "Anzahl BaseObjects: " << count << "\n";
590        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; }
591        std::cout << "Anzahl A1: " << count << "\n";
592        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
593        std::cout << "Anzahl A1B1: " << count << "\n";
594        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
595        std::cout << "Anzahl A1B1C1: " << count << "\n";
596        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
597        std::cout << "Anzahl A2: " << count << "\n";
598
599        std::cout << "11\n";
600        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
601            std::cout << "Name: " << it->getName() << "\n";
602
603        std::cout << "12\n";
604        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
605            std::cout << "Name: " << it->getName() << "\n";
606
607        std::cout << "13\n";
608*/
609        std::cout << "Test 11\n";
610/*
611        std::cout << "1\n";
612        count = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count++; }
613        std::cout << "AnzahlTickable: " << count << "\n";
614
615        Test1* test11_1;
616        for (int i = 0; i < 3; i++)
617            test11_1 = new Test1;
618
619        count = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count++; }
620        std::cout << "AnzahlTickable: " << count << "\n";
621
622        for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
623            it->tick(0);
624
625        std::cout << "2\n";
626        Test2* test11_2 = new Test2;
627*/
628
629        std::cout << "3\n";
630        Test3* test11_3 = new Test3;
631        test11_3->configOutput();
632
633        std::cout << "4\n";
634
635        startRenderLoop();
636      }
637
638      ~OrxApplication()
639      {
640        mInputManager->destroyInputObject(mKeyboard);
641        OIS::InputManager::destroyInputSystem(mInputManager);
642
643//        delete mRenderer;
644//        delete mSystem;
645
646        delete mListener;
647        delete mRoot;
648      }
649
650    private:
651      Ogre::Root *mRoot;
652      OIS::Keyboard *mKeyboard;
653      OIS::Mouse *mMouse;
654      OIS::InputManager *mInputManager;
655      CEGUI::OgreCEGUIRenderer *mRenderer;
656      CEGUI::System *mSystem;
657      OrxExitListener *mListener;
658
659      void createRoot()
660      {
661#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
662        mRoot = new Ogre::Root(macBundlePath() + "/Contents/Resources/plugins.cfg");
663#else
664        mRoot = new Ogre::Root();
665#endif
666      }
667
668      void defineResources()
669      {
670        Ogre::String secName, typeName, archName;
671        Ogre::ConfigFile cf;
672#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
673        cf.load(macBundlePath() + "/Contents/Resources/resources.cfg");
674#else
675        cf.load("resources.cfg");
676#endif
677
678        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
679        while (seci.hasMoreElements())
680        {
681          secName = seci.peekNextKey();
682          Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
683          Ogre::ConfigFile::SettingsMultiMap::iterator i;
684          for (i = settings->begin(); i != settings->end(); ++i)
685          {
686            typeName = i->first;
687            archName = i->second;
688#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
689            Ogre::ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName);
690#else
691            Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);
692#endif
693          }
694        }
695      }
696
697      void setupRenderSystem()
698      {
699        if (!mRoot->restoreConfig() && !mRoot->showConfigDialog())
700          throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()");
701      }
702
703      void createRenderWindow()
704      {
705        mRoot->initialise(true, "Ogre Render Window");
706      }
707
708      void initializeResourceGroups()
709      {
710        Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
711        Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
712      }
713
714      void createScene(void)
715      {
716
717//        string levelFile = "sp_level_moonstation.oxw";
718//        loader::LevelLoader* loader = new loader::LevelLoader(levelFile);
719      }
720
721      void setupScene()
722      {
723        Ogre::SceneManager *mgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
724        Ogre::Camera *cam = mgr->createCamera("Camera");
725        Ogre::Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam);
726      }
727
728      void setupInputSystem()
729      {
730        size_t windowHnd = 0;
731        std::ostringstream windowHndStr;
732        OIS::ParamList pl;
733        Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow();
734
735        win->getCustomAttribute("WINDOW", &windowHnd);
736        windowHndStr << windowHnd;
737        pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
738        mInputManager = OIS::InputManager::createInputSystem(pl);
739
740        try
741        {
742          mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));
743          mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false));
744        }
745        catch (const OIS::Exception &e)
746        {
747          throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem");
748        }
749      }
750
751      void setupCEGUI()
752      {
753        Ogre::SceneManager *mgr = mRoot->getSceneManager("Default SceneManager");
754        Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow();
755
756        // CEGUI setup
757//        mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr);
758//        mSystem = new CEGUI::System(mRenderer);
759
760        // Other CEGUI setup here.
761      }
762
763      void createFrameListener()
764      {
765        TickFrameListener* TickFL = new TickFrameListener();
766        mRoot->addFrameListener(TickFL);
767
768        TimerFrameListener* TimerFL = new TimerFrameListener();
769        mRoot->addFrameListener(TimerFL);
770
771        mListener = new OrxExitListener(mKeyboard);
772        mRoot->addFrameListener(mListener);
773      }
774
775      void startRenderLoop()
776      {
777        mRoot->startRendering();
778      }
779  };
780}
781
782using namespace Ogre;
783
784//#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
785//#define WIN32_LEAN_AND_MEAN
786//#include "windows.h"
787
788//             INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
789//#else
790             int main(int argc, char **argv)
791//#endif
792{
793  try
794  {
795    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
796    orxonox::OrxApplication orxonox;
797    orxonox.go();
798  }
799  catch(Exception& e)
800  {
801//#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
802//    MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
803//#else
804    fprintf(stderr, "An exception has occurred: %s\n",
805            e.getFullDescription().c_str());
806//#endif
807  }
808
809  return 0;
810}
811
Note: See TracBrowser for help on using the repository browser.