Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 460 was 460, checked in by landauf, 16 years ago

first try to add a WorldEntity. at the moment it's just a class with an Ogre::SceneNode

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