Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

moved common object-functions and -variables (like isA() and name_) from BaseObject to OrxonoxClass, so they can still be used while iterating through a list of objects inheriting from an interface.

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