Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core/src/orxonox/Orxonox.cc @ 837

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

added a Level-class and a first implementation of the Loader, using ClassTreeMask and TinyXML++

File size: 50.6 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
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (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, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
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 Class
31 */
32
33// Precompiled Headers
34#include "OrxonoxStableHeaders.h"
35
36//****** OGRE ******
37#include <OgreException.h>
38#include <OgreRoot.h>
39#include <OgreFrameListener.h>
40#include <OgreRenderWindow.h>
41#include <OgreTextureManager.h>
42#include <OgreResourceGroupManager.h>
43#include <OgreConfigFile.h>
44#include <OgreOverlay.h>
45#include <OgreOverlayManager.h>
46
47//****** OIS *******
48#include <OIS/OIS.h>
49
50//****** STD *******
51#include <iostream>
52#include <exception>
53
54//***** ORXONOX ****
55//misc
56#include "util/Sleep.h"
57
58// loader and audio
59//#include "loader/LevelLoader.h"
60//#include "audio/AudioManager.h"
61
62// network
63//#include "network/Server.h"
64//#include "network/Client.h"
65//#include "network/NetworkFrameListener.h"
66
67// objects
68#include "objects/Tickable.h"
69#include "tools/Timer.h"
70//#include "objects/NPC.h"
71#include "core/ArgReader.h"
72#include "core/Factory.h"
73#include "core/Debug.h"
74//#include "hud/HUD.h"
75//#include "objects/weapon/BulletManager.h"
76#include "GraphicsEngine.h"
77
78#include "core/ClassTreeMask.h"
79#include "objects/WorldEntity.h"
80#include "core/DebugLevel.h"
81#include "core/BaseObject.h"
82#include "objects/Test.h"
83#include "objects/test1.h"
84#include "objects/test2.h"
85#include "objects/test3.h"
86#include "core/Loader.h"
87
88#include "Orxonox.h"
89
90namespace orxonox
91{
92   // put this in a seperate Class or solve the problem in another fashion
93  class OrxListener : public Ogre::FrameListener
94  {
95    public:
96      OrxListener(OIS::Keyboard *keyboard/*, audio::AudioManager*  auMan*/, gameMode mode)
97      {
98        mKeyboard = keyboard;
99        mode_=mode;
100//        auMan_ = auMan;
101      }
102
103      bool frameStarted(const Ogre::FrameEvent& evt)
104      {
105//        auMan_->update();
106        updateAI();
107
108/*        if(mode_ == PRESENTATION)
109          server_g->tick(evt.timeSinceLastFrame);
110        else if(mode_ == CLIENT)
111          client_g->tick(evt.timeSinceLastFrame);
112*/
113        usleep(10);
114
115        mKeyboard->capture();
116        return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
117      }
118
119      void updateAI()
120      {/*
121        for(Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it)
122        {
123          it->update();
124        }*/
125      }
126
127    private:
128      gameMode mode_;
129      OIS::Keyboard *mKeyboard;
130//      audio::AudioManager*  auMan_;
131  };
132
133  // init static singleton reference of Orxonox
134  Orxonox* Orxonox::singletonRef_ = NULL;
135
136  /**
137   * create a new instance of Orxonox
138   */
139  Orxonox::Orxonox()
140  {
141    this->ogre_ = new GraphicsEngine();
142    this->dataPath_ = "";
143//    this->loader_ = 0;
144//    this->auMan_ = 0;
145    this->singletonRef_ = 0;
146    this->keyboard_ = 0;
147    this->mouse_ = 0;
148    this->inputManager_ = 0;
149    this->frameListener_ = 0;
150    this->root_ = 0;
151  }
152
153  /**
154   * destruct Orxonox
155   */
156  Orxonox::~Orxonox()
157  {
158    // nothing to delete as for now
159  }
160
161  /**
162   * initialization of Orxonox object
163   * @param argc argument counter
164   * @param argv list of arguments
165   * @param path path to config (in home dir or something)
166   */
167  void Orxonox::init(int argc, char **argv, std::string path)
168  {
169    //TODO: find config file (assuming executable directory)
170    //TODO: read config file
171    //TODO: give config file to Ogre
172    std::string mode;
173//     if(argc>=2)
174//       mode = std::string(argv[1]);
175//     else
176//       mode = "";
177    ArgReader ar = ArgReader(argc, argv);
178    ar.checkArgument("mode", mode, false);
179    ar.checkArgument("data", this->dataPath_, false);
180    ar.checkArgument("ip", serverIp_, false);
181    //mode = "presentation";
182    if(ar.errorHandling()) die();
183    if(mode == std::string("server"))
184    {
185      serverInit(path);
186      mode_ = SERVER;
187    }
188    else if(mode == std::string("client"))
189    {
190      clientInit(path);
191      mode_ = CLIENT;
192    }
193    else if(mode == std::string("presentation"))
194    {
195      serverInit(path);
196      mode_ = PRESENTATION;
197    }
198    else{
199      standaloneInit(path);
200      mode_ = STANDALONE;
201    }
202  }
203
204  /**
205   * start modules
206   */
207  void Orxonox::start()
208  {
209    //TODO: start modules
210//    ogre_->startRender();
211    //TODO: run engine
212    Factory::createClassHierarchy();
213//    createScene();
214//    setupScene();
215//    setupInputSystem();
216    if(mode_!=CLIENT){ // remove this in future ---- presentation hack
217    }
218    else
219      std::cout << "client here" << std::endl;
220    createFrameListener();
221    switch(mode_){
222    case PRESENTATION:
223      //ogre_->getRoot()->addFrameListener(new network::ServerFrameListener());
224      //std::cout << "could not add framelistener" << std::endl;
225//      server_g->open();
226      break;
227    case CLIENT:
228//      client_g->establishConnection();
229      break;
230    case SERVER:
231    case STANDALONE:
232    default:
233      break;
234    }
235        #define testandcout(code) \
236          std::cout << #code << " " << code << "\n"
237/*
238        std::cout << "Test 1\n";
239        BaseObject* test1;
240        test1 = new BaseObject();
241        test1 = new BaseObject();
242        test1 = new BaseObject();
243
244        std::cout << "Test 2\n";
245        A1* test2;
246        test2 = new A1();
247        test2 = new A1();
248        test2 = new A1();
249
250        std::cout << "Test 3\n";
251        BaseObject* test3;
252        test3 = new BaseObject();
253        test3 = new BaseObject();
254        test3 = new BaseObject();
255
256        std::cout << "Test 4\n";
257        A3* test4;
258        test4 = new A3();
259        test4 = new A3();
260        test4 = new A3();
261
262
263        std::cout << "Test 5\n";
264        A1* test5_01 = new A1();
265        A2* test5_02 = new A2();
266        A3* test5_03 = new A3();
267        A1B1* test5_04 = new A1B1();
268        A1B2* test5_05 = new A1B2();
269        A2B1* test5_06 = new A2B1();
270        A2B2* test5_07 = new A2B2();
271        A3B1* test5_08 = new A3B1();
272        A3B2* test5_09 = new A3B2();
273        A1B1C1* test5_10 = new A1B1C1();
274        A1B1C2* test5_11 = new A1B1C2();
275        A1B2C1* test5_12 = new A1B2C1();
276        A2B1C1* test5_13 = new A2B1C1();
277        A2B2C1* test5_14 = new A2B2C1();
278        A3B1C1* test5_15 = new A3B1C1();
279        A3B1C2* test5_16 = new A3B1C2();
280        A3B2C1* test5_17 = new A3B2C1();
281        A3B2C2* test5_18 = new A3B2C2();
282*/
283/*
284        OrxonoxClass* test5 = 0;
285        for (int i = 0; i <= 18; i++)
286        {
287          if (i == 0) test5 = new BaseObject;
288          if (i == 1) test5 = test5_01;
289          if (i == 2) test5 = test5_02;
290          if (i == 3) test5 = test5_03;
291          if (i == 4) test5 = test5_04;
292          if (i == 5) test5 = test5_05;
293          if (i == 6) test5 = test5_06;
294          if (i == 7) test5 = test5_07;
295          if (i == 8) test5 = test5_08;
296          if (i == 9) test5 = test5_09;
297          if (i == 10) test5 = test5_10;
298          if (i == 11) test5 = test5_11;
299          if (i == 12) test5 = test5_12;
300          if (i == 13) test5 = test5_13;
301          if (i == 14) test5 = test5_14;
302          if (i == 15) test5 = test5_15;
303          if (i == 16) test5 = test5_16;
304          if (i == 17) test5 = test5_17;
305          if (i == 18) test5 = test5_18;
306
307          std::cout << "\n";
308          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): parents:         " << test5->getIdentifier()->getParents() << "\n";
309          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): children:        " << test5->getIdentifier()->getChildren() << "\n";
310          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): direct parents:  " << test5->getIdentifier()->getDirectParents() << "\n";
311          std::cout << test5->getIdentifier()->getName() << " (" << test5->getIdentifier()->getNetworkID() << "): direct children: " << test5->getIdentifier()->getDirectChildren() << "\n";
312        }
313*/
314/*
315        for (std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryBegin(); it != Factory::getFactoryEnd(); ++it)
316            std::cout << "Class with ID " << (*it).second->getNetworkID() << ": " << ID((*it).second->getNetworkID()) << " / " << ID((*it).second->getNetworkID())->getName() << std::endl;
317
318        std::cout << "Class with ID 100: " << ID(100) << "\n";
319        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
320
321        std::cout << "\nChange ID of BaseObject to 100\n";
322        Class(BaseObject)->setNetworkID(100);
323        std::cout << "Class with ID 100: " << ID(100) << "\n";
324        std::cout << "Class with ID 1: " << ID(1) << "\n";
325        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
326
327        std::cout << "\nChange ID of BaseObject to 3\n";
328        Class(BaseObject)->setNetworkID(3);
329        std::cout << "Class with ID 100: " << ID(100) << "\n";
330        std::cout << "Class with ID 1: " << ID(1) << "\n";
331        std::cout << "Class with ID 3: " << ID(3) << "\n";
332        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
333        std::cout << "ID of Test1: " << Class(Test1)->getNetworkID() << "\n";
334*/
335/*
336        std::cout << "\n";
337        std::cout << "isA(XYZ)-Test:\n";
338        std::cout << "test5_01 = A1, Erwartet: 1 0 0 1 0\n";
339        testandcout(test5_01->isA(Class(A1)));
340        testandcout(test5_01->isA(Class(A2)));
341        testandcout(test5_01->isA(Class(A1B1)));
342        testandcout(test5_01->isA(Class(BaseObject)));
343        testandcout(test5_01->isA(Class(Interface1)));
344
345        std::cout << "\n";
346        std::cout << "test5_02 = A2, Erwartet: 0 1 0 1 0\n";
347        testandcout(test5_02->isA(Class(A1)));
348        testandcout(test5_02->isA(Class(A2)));
349        testandcout(test5_02->isA(Class(A1B1)));
350        testandcout(test5_02->isA(Class(BaseObject)));
351        testandcout(test5_02->isA(Class(Interface1)));
352
353        std::cout << "\n";
354        std::cout << "test5_01 = A3, Erwartet: 0 0 0 1 1\n";
355        testandcout(test5_03->isA(Class(A1)));
356        testandcout(test5_03->isA(Class(A2)));
357        testandcout(test5_03->isA(Class(A1B1)));
358        testandcout(test5_03->isA(Class(BaseObject)));
359        testandcout(test5_03->isA(Class(Interface1)));
360
361        std::cout << "\n";
362        std::cout << "isDirectA(XYZ)-Test:\n";
363        std::cout << "test5_01 = A1, Erwartet: 1 0 0 0 0\n";
364        testandcout(test5_01->isExactlyA(Class(A1)));
365        testandcout(test5_01->isExactlyA(Class(A2)));
366        testandcout(test5_01->isExactlyA(Class(A1B1)));
367        testandcout(test5_01->isExactlyA(Class(BaseObject)));
368        testandcout(test5_01->isExactlyA(Class(Interface1)));
369
370        std::cout << "\n";
371        std::cout << "test5_02 = A2, Erwartet: 0 1 0 0 0\n";
372        testandcout(test5_02->isExactlyA(Class(A1)));
373        testandcout(test5_02->isExactlyA(Class(A2)));
374        testandcout(test5_02->isExactlyA(Class(A1B1)));
375        testandcout(test5_02->isExactlyA(Class(BaseObject)));
376        testandcout(test5_02->isExactlyA(Class(Interface1)));
377
378        std::cout << "\n";
379        std::cout << "test5_03 = A3, Erwartet: 0 0 0 0 0\n";
380        testandcout(test5_03->isExactlyA(Class(A1)));
381        testandcout(test5_03->isExactlyA(Class(A2)));
382        testandcout(test5_03->isExactlyA(Class(A1B1)));
383        testandcout(test5_03->isExactlyA(Class(BaseObject)));
384        testandcout(test5_03->isExactlyA(Class(Interface1)));
385
386        std::cout << "\n";
387        std::cout << "isChildOf(XYZ)-Test:\n";
388        std::cout << "test5_04 = A1B1, Erwartet: 1 0 1 0 0 0 0\n";
389        testandcout(test5_04->isChildOf(Class(A1)));
390        testandcout(test5_04->isChildOf(Class(A2)));
391        testandcout(test5_04->isChildOf(Class(BaseObject)));
392        testandcout(test5_04->isChildOf(Class(Interface1)));
393        testandcout(test5_04->isChildOf(Class(Interface2)));
394        testandcout(test5_04->isChildOf(Class(A1B1C2)));
395        testandcout(test5_04->isChildOf(Class(A1B1)));
396
397        std::cout << "\n";
398        std::cout << "test5_06 = A2B1, Erwartet: 0 1 1 0 0 0 0\n";
399        testandcout(test5_06->isChildOf(Class(A1)));
400        testandcout(test5_06->isChildOf(Class(A2)));
401        testandcout(test5_06->isChildOf(Class(BaseObject)));
402        testandcout(test5_06->isChildOf(Class(Interface1)));
403        testandcout(test5_06->isChildOf(Class(Interface2)));
404        testandcout(test5_06->isChildOf(Class(A1B1C2)));
405        testandcout(test5_06->isChildOf(Class(A1B1)));
406
407        std::cout << "\n";
408        std::cout << "test5_07 = A2B2, Erwartet: 0 1 1 1 0 0\n";
409        testandcout(test5_07->isChildOf(Class(A1)));
410        testandcout(test5_07->isChildOf(Class(A2)));
411        testandcout(test5_07->isChildOf(Class(BaseObject)));
412        testandcout(test5_07->isChildOf(Class(Interface1)));
413        testandcout(test5_07->isChildOf(Class(Interface2)));
414        testandcout(test5_07->isChildOf(Class(A1B1C2)));
415
416        std::cout << "\n";
417        std::cout << "test5_08 = A3B1, Erwartet: 0 0 1 1 0 0\n";
418        testandcout(test5_08->isChildOf(Class(A1)));
419        testandcout(test5_08->isChildOf(Class(A2)));
420        testandcout(test5_08->isChildOf(Class(BaseObject)));
421        testandcout(test5_08->isChildOf(Class(Interface1)));
422        testandcout(test5_08->isChildOf(Class(Interface2)));
423        testandcout(test5_08->isChildOf(Class(A1B1C2)));
424
425        std::cout << "\n";
426        std::cout << "test5_09 = A3B2, Erwartet: 0 0 1 1 1 0\n";
427        testandcout(test5_09->isChildOf(Class(A1)));
428        testandcout(test5_09->isChildOf(Class(A2)));
429        testandcout(test5_09->isChildOf(Class(BaseObject)));
430        testandcout(test5_09->isChildOf(Class(Interface1)));
431        testandcout(test5_09->isChildOf(Class(Interface2)));
432        testandcout(test5_09->isChildOf(Class(A1B1C2)));
433
434        std::cout << "\n";
435        std::cout << "isDirectChildOf(XYZ)-Test:\n";
436        std::cout << "test5_04 = A1B1, Erwartet: 1 0 0 0 0 0 0\n";
437        testandcout(test5_04->isDirectChildOf(Class(A1)));
438        testandcout(test5_04->isDirectChildOf(Class(A2)));
439        testandcout(test5_04->isDirectChildOf(Class(BaseObject)));
440        testandcout(test5_04->isDirectChildOf(Class(Interface1)));
441        testandcout(test5_04->isDirectChildOf(Class(Interface2)));
442        testandcout(test5_04->isDirectChildOf(Class(A1B1C2)));
443        testandcout(test5_04->isDirectChildOf(Class(A1B1)));
444
445        std::cout << "\n";
446        std::cout << "test5_06 = A2B1, Erwartet: 0 1 0 0 0 0 0\n";
447        testandcout(test5_06->isDirectChildOf(Class(A1)));
448        testandcout(test5_06->isDirectChildOf(Class(A2)));
449        testandcout(test5_06->isDirectChildOf(Class(BaseObject)));
450        testandcout(test5_06->isDirectChildOf(Class(Interface1)));
451        testandcout(test5_06->isDirectChildOf(Class(Interface2)));
452        testandcout(test5_06->isDirectChildOf(Class(A1B1C2)));
453        testandcout(test5_06->isDirectChildOf(Class(A1B1)));
454
455        std::cout << "\n";
456        std::cout << "test5_07 = A2B2, Erwartet: 0 1 0 1 0 0\n";
457        testandcout(test5_07->isDirectChildOf(Class(A1)));
458        testandcout(test5_07->isDirectChildOf(Class(A2)));
459        testandcout(test5_07->isDirectChildOf(Class(BaseObject)));
460        testandcout(test5_07->isDirectChildOf(Class(Interface1)));
461        testandcout(test5_07->isDirectChildOf(Class(Interface2)));
462        testandcout(test5_07->isDirectChildOf(Class(A1B1C2)));
463
464        std::cout << "\n";
465        std::cout << "test5_08 = A3B1, Erwartet: 0 0 0 0 0 0\n";
466        testandcout(test5_08->isDirectChildOf(Class(A1)));
467        testandcout(test5_08->isDirectChildOf(Class(A2)));
468        testandcout(test5_08->isDirectChildOf(Class(BaseObject)));
469        testandcout(test5_08->isDirectChildOf(Class(Interface1)));
470        testandcout(test5_08->isDirectChildOf(Class(Interface2)));
471        testandcout(test5_08->isDirectChildOf(Class(A1B1C2)));
472
473        std::cout << "\n";
474        std::cout << "test5_09 = A3B2, Erwartet: 0 0 0 0 1 0\n";
475        testandcout(test5_09->isDirectChildOf(Class(A1)));
476        testandcout(test5_09->isDirectChildOf(Class(A2)));
477        testandcout(test5_09->isDirectChildOf(Class(BaseObject)));
478        testandcout(test5_09->isDirectChildOf(Class(Interface1)));
479        testandcout(test5_09->isDirectChildOf(Class(Interface2)));
480        testandcout(test5_09->isDirectChildOf(Class(A1B1C2)));
481
482        std::cout << "\n";
483
484        std::cout << "isParentOf(XYZ)-Test:\n";
485        std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 1 1 1\n";
486        testandcout(test1->isParentOf(Class(BaseObject)));
487        testandcout(test1->isParentOf(Class(Interface1)));
488        testandcout(test1->isParentOf(Class(A1)));
489        testandcout(test1->isParentOf(Class(A2)));
490        testandcout(test1->isParentOf(Class(A1B1)));
491        testandcout(test1->isParentOf(Class(A2B2)));
492        testandcout(test1->isParentOf(Class(A3B1C2)));
493
494        std::cout << "\n";
495        std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n";
496        testandcout(test5_01->isParentOf(Class(BaseObject)));
497        testandcout(test5_01->isParentOf(Class(Interface1)));
498        testandcout(test5_01->isParentOf(Class(A1)));
499        testandcout(test5_01->isParentOf(Class(A2)));
500        testandcout(test5_01->isParentOf(Class(A1B1)));
501        testandcout(test5_01->isParentOf(Class(A2B2)));
502        testandcout(test5_01->isParentOf(Class(A3B1C2)));
503
504        std::cout << "\n";
505        std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 1\n";
506        testandcout(Class(Interface1)->isParentOf(Class(BaseObject)));
507        testandcout(Class(Interface1)->isParentOf(Class(Interface1)));
508        testandcout(Class(Interface1)->isParentOf(Class(A1)));
509        testandcout(Class(Interface1)->isParentOf(Class(A2)));
510        testandcout(Class(Interface1)->isParentOf(Class(A1B1)));
511        testandcout(Class(Interface1)->isParentOf(Class(A2B2)));
512        testandcout(Class(Interface1)->isParentOf(Class(A3B1C2)));
513
514        std::cout << "\n";
515        std::cout << "isDirectParentOf(XYZ)-Test:\n";
516        std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 0 0 0\n";
517        testandcout(test1->isDirectParentOf(Class(BaseObject)));
518        testandcout(test1->isDirectParentOf(Class(Interface1)));
519        testandcout(test1->isDirectParentOf(Class(A1)));
520        testandcout(test1->isDirectParentOf(Class(A2)));
521        testandcout(test1->isDirectParentOf(Class(A1B1)));
522        testandcout(test1->isDirectParentOf(Class(A2B2)));
523        testandcout(test1->isDirectParentOf(Class(A3B1C2)));
524
525        std::cout << "\n";
526        std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n";
527        testandcout(test5_01->isDirectParentOf(Class(BaseObject)));
528        testandcout(test5_01->isDirectParentOf(Class(Interface1)));
529        testandcout(test5_01->isDirectParentOf(Class(A1)));
530        testandcout(test5_01->isDirectParentOf(Class(A2)));
531        testandcout(test5_01->isDirectParentOf(Class(A1B1)));
532        testandcout(test5_01->isDirectParentOf(Class(A2B2)));
533        testandcout(test5_01->isDirectParentOf(Class(A3B1C2)));
534
535        std::cout << "\n";
536        std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 0\n";
537        testandcout(Class(Interface1)->isDirectParentOf(Class(BaseObject)));
538        testandcout(Class(Interface1)->isDirectParentOf(Class(Interface1)));
539        testandcout(Class(Interface1)->isDirectParentOf(Class(A1)));
540        testandcout(Class(Interface1)->isDirectParentOf(Class(A2)));
541        testandcout(Class(Interface1)->isDirectParentOf(Class(A1B1)));
542        testandcout(Class(Interface1)->isDirectParentOf(Class(A2B2)));
543        testandcout(Class(Interface1)->isDirectParentOf(Class(A3B1C2)));
544*/
545/*
546        std::cout << "Test 6\n";
547        std::cout << "1\n";
548        Identifier* test6_01 = Class(A1B1);
549        std::cout << "2\n";
550        Identifier* test6_02 = Class(A1B1);
551        std::cout << "3\n";
552        Identifier* test6_03 = Class(A1);
553        std::cout << "4\n";
554        Identifier* test6_04 = Class(A1B1C1);
555        std::cout << "5\n";
556        Identifier* test6_05 = Class(A1B1);
557        std::cout << "6\n";
558        Identifier* test6_06 = Class(A1B1C1);
559
560        std::cout << "7\n";
561
562        std::cout << "\n";
563        std::cout << "BaseObject: parents:         " << Class(BaseObject)->getParents() << "\n";
564        std::cout << "BaseObject: children:        " << Class(BaseObject)->getChildren() << "\n";
565        std::cout << "BaseObject: direct parents:  " << Class(BaseObject)->getDirectParents() << "\n";
566        std::cout << "BaseObject: direct children: " << Class(BaseObject)->getDirectChildren() << "\n";
567
568        std::cout << "\n";
569        std::cout << "A1: parents:                 " << Class(A1)->getParents() << "\n";
570        std::cout << "A1: children:                " << Class(A1)->getChildren() << "\n";
571        std::cout << "A1: direct parents:          " << Class(A1)->getDirectParents() << "\n";
572        std::cout << "A1: direct children:         " << Class(A1)->getDirectChildren() << "\n";
573
574        std::cout << "\n";
575        std::cout << "A1B1: parents:               " << Class(A1B1)->getParents() << "\n";
576        std::cout << "A1B1: children:              " << Class(A1B1)->getChildren() << "\n";
577        std::cout << "A1B1: direct parents:        " << Class(A1B1)->getDirectParents() << "\n";
578        std::cout << "A1B1: direct children:       " << Class(A1B1)->getDirectChildren() << "\n";
579
580        std::cout << "\n";
581        std::cout << "A1B1C1: parents:             " << Class(A1B1C1)->getParents() << "\n";
582        std::cout << "A1B1C1: children:            " << Class(A1B1C1)->getChildren() << "\n";
583        std::cout << "A1B1C1: direct parents:      " << Class(A1B1C1)->getDirectParents() << "\n";
584        std::cout << "A1B1C1: direct children:     " << Class(A1B1C1)->getDirectChildren() << "\n";
585
586        std::cout << "\n";
587        std::cout << "A3B1C1 child of A3:      " << Class(A3B1C1)->isChildOf(Class(A3)) << "\n";
588        std::cout << "\n";
589        std::cout << "A2 parent of A2B1C1:     " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n";
590
591        std::cout << "8\n";
592*/
593/*
594        std::cout << "Test 7\n";
595        std::cout << "1\n";
596        SubclassIdentifier<A1B1> test7_01;
597        test7_01 = Class(A1B1C1);
598
599        SubclassIdentifier<A1B1> test7_02;
600        test7_02 = Class(A1B1);
601
602        std::cout << test7_01->getName() << "\n";
603        std::cout << test7_02->getName() << "\n";
604*/
605/*
606// ## WARNING - CRASH! ##
607        std::cout << "2\n";
608
609        SubclassIdentifier<A1B1> test7_03;
610        test7_03 = Class(A1);
611
612        SubclassIdentifier<A1B1> test7_04;
613        test7_04 = Class(A1B2);
614
615        SubclassIdentifier<A1B1> test7_05;
616        test7_05 = Class(A2);
617// ## END WARNING - CRASH! ##
618*/
619/*
620        std::cout << "Test 8\n";
621
622        std::cout << "1\n";
623        Test1* test8_01 = new Test1;
624        Test3* test8_03 = new Test3;
625        test8_03->usefullClassesIsATest(test8_01);
626
627        std::cout << "2\n";
628        Test2* test8_02 = new Test2;
629        test8_03->usefullClassesIsATest(test8_02);
630
631        std::cout << "3\n";
632        test8_01->setUsefullClass1(Class(Test1));
633        test8_01->setUsefullClass1(test8_02->getIdentifier());
634        test8_01->setUsefullClass2(Class(Test2));
635        test8_01->setUsefullClassOfTypeTest3(Class(Test3));
636        test8_01->setUsefullClassOfTypeTest3(test8_03->getIdentifier());
637
638
639        testandcout(test8_01->isA(Class(Test1)));
640        testandcout(test8_01->isA(Class(Test2)));
641        testandcout(test8_01->isA(Class(Test3)));
642
643        Test2* test8_04 = new Test2;
644        testandcout(test8_02->isA(Class(Test1)));
645        testandcout(test8_02->isA(Class(Test2)));
646        testandcout(test8_02->isA(Class(Test3)));
647
648        Test3* test8_05 = new Test3;
649        testandcout(test8_03->isA(Class(Test1)));
650        testandcout(test8_03->isA(Class(Test2)));
651        testandcout(test8_03->isA(Class(Test3)));
652
653        delete test8_01;
654        delete test8_02;
655        delete test8_03;
656*/
657/*
658        std::cout << "Test 9\n";
659        std::cout << "1\n";
660        Identifier* test9_01 = Class(A3);
661        BaseObject* test9_02 = test9_01->fabricate();
662        std::cout << test9_02->getIdentifier()->getName() << "\n";
663
664        std::cout << "\n2\n";
665        BaseObject* test9_03 = Class(A1B2)->fabricate();
666        std::cout << test9_03->getIdentifier()->getName() << "\n";
667
668        std::cout << "\n3\n";
669        SubclassIdentifier<A1> test9_04;
670        test9_04 = Class(A1B1C1);
671        A1* test9_05 = test9_04.fabricate();
672        std::cout << test9_05->getIdentifier()->getName() << "\n";
673
674        std::cout << "\n4\n";
675        BaseObject* test9_06 = ID("A2B2")->fabricate();
676        std::cout << test9_06->getIdentifier()->getName() << "\n";
677
678        std::cout << "\n5\n";
679        delete test9_02;
680        delete test9_03;
681        delete test9_05;
682        delete test9_06;
683*/
684/*
685        std::cout << "Test 10\n";
686        Identifier* test10_01 = Class(A1B2);
687        Identifier* test10_02 = Class(A2);
688        Identifier* test10_03 = Class(A3B1C1);
689
690        BaseObject* test10_04 = test10_01->fabricate();
691        BaseObject* test10_05 = test10_02->fabricate();
692        BaseObject* test10_06 = test10_03->fabricate();
693
694        BaseObject* test10_07;
695        for (int i = 0; i < 10; i++)
696            test10_07 = ID("A1B1C1")->fabricate();
697
698        std::cout << "1\n";
699        int count;
700
701        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; }
702        std::cout << "Anzahl BaseObjects: " << count << "\n";
703        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; }
704        std::cout << "Anzahl A1: " << count << "\n";
705        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
706        std::cout << "Anzahl A1B1: " << count << "\n";
707        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
708        std::cout << "Anzahl A1B1C1: " << count << "\n";
709        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
710        std::cout << "Anzahl A2: " << count << "\n";
711
712        std::cout << "2\n";
713        BaseObject* test10_08;
714        BaseObject* test10_09 = 0;
715        BaseObject* test10_10 = 0;
716        for (int i = 0; i < 10; i++)
717        {
718            test10_08 = ID("A2B1C1")->fabricate();
719            std::string objName = "A2B1C1#";
720            objName += '0' + i;
721            test10_08->setName(objName);
722
723            if (i == 0)
724                test10_09 = test10_08;
725
726            if (i == 5)
727                test10_10 = test10_08;
728        }
729
730        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; }
731        std::cout << "Anzahl BaseObjects: " << count << "\n";
732        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; }
733        std::cout << "Anzahl A1: " << count << "\n";
734        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
735        std::cout << "Anzahl A1B1: " << count << "\n";
736        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
737        std::cout << "Anzahl A1B1C1: " << count << "\n";
738        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
739        std::cout << "Anzahl A2: " << count << "\n";
740
741        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
742            std::cout << "Name: " << it->getName() << "\n";
743
744        std::cout << "3\n";
745        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
746            std::cout << "Name: " << it->getName() << "\n";
747
748        std::cout << "4\n";
749        delete test10_08;
750
751        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; }
752        std::cout << "Anzahl BaseObjects: " << count << "\n";
753        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; }
754        std::cout << "Anzahl A1: " << count << "\n";
755        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
756        std::cout << "Anzahl A1B1: " << count << "\n";
757        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
758        std::cout << "Anzahl A1B1C1: " << count << "\n";
759        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
760        std::cout << "Anzahl A2: " << count << "\n";
761
762        std::cout << "5\n";
763        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
764            std::cout << "Name: " << it->getName() << "\n";
765
766        std::cout << "6\n";
767        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
768            std::cout << "Name: " << it->getName() << "\n";
769
770        std::cout << "7\n";
771        delete test10_09;
772
773        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::end(); it; --it) { count++; }
774        std::cout << "Anzahl BaseObjects: " << count << "\n";
775        count = 0; for (Iterator<A1> it = ObjectList<A1>::end(); it; --it) { count++; }
776        std::cout << "Anzahl A1: " << count << "\n";
777        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::end(); it; --it) { count++; }
778        std::cout << "Anzahl A1B1: " << count << "\n";
779        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::end(); it; --it) { count++; }
780        std::cout << "Anzahl A1B1C1: " << count << "\n";
781        count = 0; for (Iterator<A2> it = ObjectList<A2>::end(); it; --it) { count++; }
782        std::cout << "Anzahl A2: " << count << "\n";
783
784        std::cout << "8\n";
785        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
786            std::cout << "Name: " << it->getName() << "\n";
787
788        std::cout << "9\n";
789        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
790            std::cout << "Name: " << it->getName() << "\n";
791
792        std::cout << "10\n";
793        delete test10_10;
794
795        count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it; ++it) { count++; }
796        std::cout << "Anzahl BaseObjects: " << count << "\n";
797        count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it; ++it) { count++; }
798        std::cout << "Anzahl A1: " << count << "\n";
799        count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; }
800        std::cout << "Anzahl A1B1: " << count << "\n";
801        count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; }
802        std::cout << "Anzahl A1B1C1: " << count << "\n";
803        count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; }
804        std::cout << "Anzahl A2: " << count << "\n";
805
806        std::cout << "11\n";
807        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
808            std::cout << "Name: " << it->getName() << "\n";
809
810        std::cout << "12\n";
811        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
812            std::cout << "Name: " << it->getName() << "\n";
813
814        std::cout << "13\n";
815*/
816/*
817        std::cout << "Test 11\n";
818        std::cout << "1\n";
819        int count2 = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count2++; }
820        std::cout << "AnzahlTickable: " << count2 << "\n";
821
822        Test1* test11_1;
823        for (int i = 0; i < 3; i++)
824            test11_1 = new Test1;
825
826        count2 = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count2++; }
827        std::cout << "AnzahlTickable: " << count2 << "\n";
828
829        for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
830            it->tick(0);
831
832        std::cout << "2\n";
833        Test2* test11_2 = new Test2;
834
835
836        std::cout << "3\n";
837        Test3* test11_3 = new Test3;
838        test11_3->configOutput();
839
840        std::cout << "4\n";
841*/
842/*
843        std::cout << "Test 12\n";
844        std::cout << "1\n";
845
846        WorldEntity* test12_1 = new WorldEntity;
847
848        std::cout << sizeof(WorldEntity) << std::endl;
849
850        std::cout << "2\n";
851*/
852/*
853        std::cout << "Test 13\n";
854
855        #define BoolToYesNo(bool) \
856            if (bool) \
857                std::cout << "yes "; \
858            else \
859                std::cout << "no  "
860
861        #define TestClassTreeMask(mask) \
862            std::cout << "========== ClassTreeMask-Test ===========" << std::endl; \
863            std::cout << mask << std::endl << std::endl; \
864            std::cout << "                 "; \
865            BoolToYesNo(mask.isIncluded(Class(BaseObject))); \
866            std::cout << std::endl; \
867            \
868            std::cout << "     "; \
869            BoolToYesNo(mask.isIncluded(Class(A1))); \
870            std::cout << "        "; \
871            BoolToYesNo(mask.isIncluded(Class(A2))); \
872            std::cout << "           "; \
873            BoolToYesNo(mask.isIncluded(Class(A3))); \
874            std::cout << std::endl; \
875            \
876            std::cout << "  "; \
877            BoolToYesNo(mask.isIncluded(Class(A1B1))); \
878            std::cout << "  "; \
879            BoolToYesNo(mask.isIncluded(Class(A1B2))); \
880            std::cout << "  "; \
881            BoolToYesNo(mask.isIncluded(Class(A2B1))); \
882            std::cout << "  "; \
883            BoolToYesNo(mask.isIncluded(Class(A2B2))); \
884            std::cout << "    "; \
885            BoolToYesNo(mask.isIncluded(Class(A3B1))); \
886            std::cout << "    "; \
887            BoolToYesNo(mask.isIncluded(Class(A3B2))); \
888            std::cout << std::endl; \
889            \
890            BoolToYesNo(mask.isIncluded(Class(A1B1C1))); \
891            BoolToYesNo(mask.isIncluded(Class(A1B1C2))); \
892            BoolToYesNo(mask.isIncluded(Class(A1B2C1))); \
893            std::cout << "  "; \
894            BoolToYesNo(mask.isIncluded(Class(A2B1C1))); \
895            std::cout << "  "; \
896            BoolToYesNo(mask.isIncluded(Class(A2B2C1))); \
897            std::cout << "  "; \
898            BoolToYesNo(mask.isIncluded(Class(A3B1C1))); \
899            BoolToYesNo(mask.isIncluded(Class(A3B1C2))); \
900            BoolToYesNo(mask.isIncluded(Class(A3B2C1))); \
901            BoolToYesNo(mask.isIncluded(Class(A3B2C2))); \
902            std::cout << std::endl; \
903            std::cout << "=========================================" << std::endl
904
905        std::cout << "1\n";
906
907        ClassTreeMask test13_1;
908        test13_1.exclude(Class(A1B1));
909        test13_1.exclude(Class(A2));
910        test13_1.include(Class(A2B2));
911        test13_1.exclude(Class(A2B2C1));
912        test13_1.exclude(Class(A3B1));
913        test13_1.include(Class(A3B1C2));
914        test13_1.exclude(Class(A3B2C1));
915        test13_1.exclude(Class(A3B2C2));
916        std::cout << "Mask 1:\n";
917        TestClassTreeMask(test13_1);
918
919        ClassTreeMask test13_2;
920        test13_2.exclude(Class(BaseObject));
921        test13_2.include(Class(A1));
922        test13_2.exclude(Class(A1B2));
923        test13_2.exclude(Class(A1B1C2));
924        test13_2.include(Class(A2));
925        test13_2.exclude(Class(A2B2));
926        test13_2.include(Class(A3B1));
927        test13_2.include(Class(A3B2));
928        test13_2.exclude(Class(A3B2C2));
929        std::cout << std::endl;
930        std::cout << "Mask 2:\n";
931        TestClassTreeMask(test13_2);
932
933        std::cout << "2\n";
934
935        ClassTreeMask test13_3;
936        test13_3.include(Class(A1), true, false);
937        test13_3.exclude(Class(A1B2), true, false);
938        test13_3.exclude(Class(A1B1C2), true, false);
939        test13_3.include(Class(A2), true, false);
940        test13_3.exclude(Class(A2B2), true, false);
941        test13_3.include(Class(A3B1), true, false);
942        test13_3.include(Class(A3B2), true, false);
943        test13_3.exclude(Class(A3B2C2), true, false);
944        std::cout << std::endl;
945        std::cout << "Mask 2 without excluded BaseObject:\n";
946        TestClassTreeMask(test13_3);
947        test13_3.exclude(Class(BaseObject), false, false);
948        std::cout << std::endl;
949        std::cout << "Mask 2 with BaseObject excluded afterwards without overwrite:\n";
950        TestClassTreeMask(test13_3);
951        test13_3.exclude(Class(BaseObject), true);
952        std::cout << std::endl;
953        std::cout << "Mask 2 with BaseObject excluded afterwards with overwrite:\n";
954        TestClassTreeMask(test13_3);
955
956        ClassTreeMask test13_4;
957        test13_4.include(Class(A3B2));
958        test13_4.exclude(Class(A1B1C2));
959        test13_4.include(Class(A3B1));
960        test13_4.exclude(Class(A3B2C2));
961        test13_4.exclude(Class(BaseObject));
962        test13_4.include(Class(A2));
963        test13_4.exclude(Class(A1B2));
964        test13_4.exclude(Class(A2B2));
965        test13_4.include(Class(A1));
966        std::cout << std::endl;
967        std::cout << "Mask 2 created in random order with overwrite and clean:\n";
968        TestClassTreeMask(test13_4);
969
970        ClassTreeMask test13_4_2;
971        test13_4_2.include(Class(A3B2), false, false);
972        test13_4_2.exclude(Class(A1B1C2), false, false);
973        test13_4_2.include(Class(A3B1), false, false);
974        test13_4_2.exclude(Class(A3B2C2), false, false);
975        test13_4_2.exclude(Class(BaseObject), false, false);
976        test13_4_2.include(Class(A2), false, false);
977        test13_4_2.exclude(Class(A1B2), false, false);
978        test13_4_2.exclude(Class(A2B2), false, false);
979        test13_4_2.include(Class(A1), false, false);
980        std::cout << std::endl;
981        std::cout << "Mask 2 created in random order without overwrite and without clean:\n";
982        TestClassTreeMask(test13_4_2);
983
984        std::cout << "3\n";
985
986        ClassTreeMask test13_6 = !test13_1;
987        std::cout << std::endl;
988        std::cout << "Mask 1 inverted:\n";
989        TestClassTreeMask(test13_6);
990
991        std::cout << "4\n";
992
993        ClassTreeMask test13_7 = test13_1 + test13_2;
994        std::cout << std::endl;
995        std::cout << "Mask 1 + Mask 2:\n";
996        TestClassTreeMask(test13_7);
997
998        std::cout << "5\n";
999
1000        ClassTreeMask test13_8 = test13_1 * test13_2;
1001        std::cout << std::endl;
1002        std::cout << "Mask 1 * Mask 2:\n";
1003        TestClassTreeMask(test13_8);
1004
1005        std::cout << "6\n";
1006
1007        ClassTreeMask test13_9 = test13_1 - test13_2;
1008        std::cout << std::endl;
1009        std::cout << "Mask 1 - Mask 2:\n";
1010        TestClassTreeMask(test13_9);
1011
1012        std::cout << "7\n";
1013
1014        ClassTreeMask test13_10 = test13_1 ^ test13_2;
1015        std::cout << std::endl;
1016        std::cout << "Mask 1 ^ Mask 2:\n";
1017        TestClassTreeMask(test13_10);
1018
1019        std::cout << "8\n";
1020
1021        ClassTreeMask test13_12(!test13_1);
1022        std::cout << std::endl;
1023        std::cout << "Mask 1 inverted assigned with copyconstructor + the original from before:\n";
1024        TestClassTreeMask(test13_12);
1025        TestClassTreeMask(test13_1);
1026
1027
1028        ClassTreeMask test13_13 = test13_1 + test13_2;
1029        std::cout << std::endl;
1030        std::cout << "Mask 1 + Mask 2 assigned with copyconstructor + originals from before:\n";
1031        TestClassTreeMask(test13_13);
1032        TestClassTreeMask(test13_1);
1033        TestClassTreeMask(test13_2);
1034
1035        ClassTreeMask test13_14 = test13_1;
1036        test13_14 += test13_2;
1037        std::cout << std::endl;
1038        std::cout << "Mask 1 + Mask 2 with += operator + original of mask 2 from before:\n";
1039        TestClassTreeMask(test13_14);
1040        TestClassTreeMask(test13_2);
1041
1042        test13_1 = test13_1;
1043        std::cout << std::endl;
1044        std::cout << "Mask 1 assigned with = operator to itself:\n";
1045        TestClassTreeMask(test13_1);
1046
1047        std::cout << "9\n";
1048
1049        ClassTreeMask test13_15;
1050        test13_15.exclude(Class(Interface1));
1051        std::cout << std::endl;
1052        std::cout << "Mask with excluded Interface 1:\n";
1053        TestClassTreeMask(test13_15);
1054
1055        ClassTreeMask test13_16 = test13_1;
1056        test13_16.exclude(Class(Interface1));
1057        std::cout << std::endl;
1058        std::cout << "Mask 1 with excluded Interface 1 (overwrite):\n";
1059        TestClassTreeMask(test13_16);
1060
1061        ClassTreeMask test13_17 = test13_1;
1062        test13_17.exclude(Class(Interface1), false);
1063        std::cout << std::endl;
1064        std::cout << "Mask 1 with excluded Interface 1 (without overwrite):\n";
1065        TestClassTreeMask(test13_17);
1066
1067        ClassTreeMask test13_18 = test13_2;
1068        test13_18.exclude(Class(Interface1), false);
1069        std::cout << std::endl;
1070        std::cout << "Mask 2 with excluded Interface 1 (without overwrite):\n";
1071        TestClassTreeMask(test13_18);
1072
1073        std::cout << "10\n";
1074
1075        ClassTreeMask test13_19;
1076        test13_19.exclude(Class(Test1));
1077        std::cout << std::endl;
1078        std::cout << "Mask with excluded Test1:\n";
1079        TestClassTreeMask(test13_19);
1080
1081        std::cout << "11\n";
1082
1083        ClassTreeMask test13_20;
1084        test13_20.exclude(Class(DebugLevel));
1085        std::cout << std::endl;
1086        std::cout << "Mask with excluded DebugLevel:\n";
1087        TestClassTreeMask(test13_20);
1088
1089        std::cout << "12\n";
1090
1091        ClassTreeMask test13_21;
1092        test13_21.excludeSingle(Class(A2));
1093        std::cout << std::endl;
1094        std::cout << "Mask with single-excluded A2:\n";
1095        TestClassTreeMask(test13_21);
1096
1097        test13_21.exclude(Class(A2));
1098        std::cout << std::endl;
1099        std::cout << "Mask with excluded A2:\n";
1100        TestClassTreeMask(test13_21);
1101
1102        test13_21.includeSingle(Class(A2));
1103        std::cout << std::endl;
1104        std::cout << "Previous mask with single-included A2:\n";
1105        TestClassTreeMask(test13_21);
1106
1107        test13_21.includeSingle(Class(A2), false);
1108        std::cout << std::endl;
1109        std::cout << "Previous mask with single-included A2 without clean:\n";
1110        TestClassTreeMask(test13_21);
1111
1112        std::cout << "13\n";
1113*/
1114/*
1115        std::cout << "Test 14\n";
1116        std::cout << "1\n";
1117
1118        SubclassIdentifier<A1> test14_1;
1119        test14_1 = Class(A1B1C1);
1120        std::cout << test14_1.getIdentifier()->getName() << std::endl;
1121
1122        SubclassIdentifier<A1> test14_2 = Class(A1B1C2);
1123        std::cout << test14_2.getIdentifier()->getName() << std::endl;
1124
1125        SubclassIdentifier<Interface1> test14_3;
1126        test14_3 = Class(A2B2C1);
1127        std::cout << test14_3.getIdentifier()->getName() << std::endl;
1128
1129        SubclassIdentifier<A1B2> test14_4;
1130        test14_4 = Class(A1B2C1);
1131        std::cout << test14_4.getIdentifier()->getName() << std::endl;
1132
1133        SubclassIdentifier<BaseObject> test14_5 = Class(Test1);
1134        std::cout << test14_5.getIdentifier()->getName() << std::endl;
1135
1136        std::cout << "2\n";
1137*/
1138
1139        std::cout << "Test 15\n";
1140        std::cout << "1\n";
1141
1142        Level* test15_1 = new Level("levels/sample.oxw");
1143        Loader::open(test15_1);
1144
1145        std::cout << "2\n";
1146
1147//    startRenderLoop();
1148  }
1149
1150  /**
1151   * @return singleton object
1152   */
1153  Orxonox* Orxonox::getSingleton()
1154  {
1155    if (!singletonRef_)
1156      singletonRef_ = new Orxonox();
1157    return singletonRef_;
1158  }
1159
1160  /**
1161   * error kills orxonox
1162   */
1163  void Orxonox::die(/* some error code */)
1164  {
1165    //TODO: destroy and destruct everything and print nice error msg
1166    delete this;
1167  }
1168
1169  void Orxonox::standaloneInit(std::string path)
1170  {
1171    ogre_->setConfigPath(path);
1172    ogre_->setup();
1173    root_ = ogre_->getRoot();
1174    if(!ogre_->load()) die(/* unable to load */);
1175
1176    //defineResources();
1177    //setupRenderSystem();
1178    //createRenderWindow();
1179    //initializeResourceGroups();
1180    /*createScene();
1181    setupScene();
1182    setupInputSystem();
1183    createFrameListener();
1184    Factory::createClassHierarchy();
1185    startRenderLoop();*/
1186  }
1187
1188  void Orxonox::playableServer(std::string path)
1189  {
1190    ogre_->setConfigPath(path);
1191    ogre_->setup();
1192    root_ = ogre_->getRoot();
1193    defineResources();
1194    setupRenderSystem();
1195    createRenderWindow();
1196    initializeResourceGroups();
1197    setupInputSystem();
1198    Factory::createClassHierarchy();
1199    createScene();
1200    setupScene();
1201    createFrameListener();
1202    try{
1203//      server_g = new network::Server(); //!< add port and bindadress
1204//      server_g->open(); //!< open server and create listener thread
1205//      if(ogre_ && ogre_->getRoot())
1206//        ogre_->getRoot()->addFrameListener(new network::ServerFrameListener()); // adds a framelistener for the server
1207      COUT(3) << "Info: network framelistener added" << std::endl;
1208    }
1209    catch(...)
1210    {
1211      COUT(1) << "Error: There was a problem initialising the server :(" << std::endl;
1212    }
1213    startRenderLoop();
1214  }
1215
1216  void Orxonox::standalone(){
1217
1218
1219
1220  }
1221
1222  void Orxonox::serverInit(std::string path)
1223  {
1224    COUT(2) << "initialising server" << std::endl;
1225    ogre_->setConfigPath(path);
1226    ogre_->setup();
1227//    server_g = new network::Server(); // FIXME add some settings if wanted
1228    if(!ogre_->load()) die(/* unable to load */);
1229    // FIXME add network framelistener
1230  }
1231
1232  void Orxonox::clientInit(std::string path)
1233  {
1234    COUT(2) << "initialising client" << std::endl;
1235    ogre_->setConfigPath(path);
1236    ogre_->setup();
1237/*    if(serverIp_.compare("")==0)
1238      client_g = new network::Client();
1239    else
1240      client_g = new network::Client(serverIp_, 55556);*/
1241    if(!ogre_->load()) die(/* unable to load */);
1242//    ogre_->getRoot()->addFrameListener(new network::ClientFrameListener());
1243  }
1244
1245  void Orxonox::defineResources()
1246  {
1247    std::string secName, typeName, archName;
1248    Ogre::ConfigFile cf;
1249#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
1250    cf.load(macBundlePath() + "/Contents/Resources/resources.cfg");
1251#else
1252    cf.load(dataPath_ + "resources.cfg");
1253#endif
1254
1255    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
1256    while (seci.hasMoreElements())
1257    {
1258      secName = seci.peekNextKey();
1259      Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
1260      Ogre::ConfigFile::SettingsMultiMap::iterator i;
1261      for (i = settings->begin(); i != settings->end(); ++i)
1262      {
1263        typeName = i->first;
1264        archName = i->second;
1265#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
1266        Ogre::ResourceGroupManager::getSingleton().addResourceLocation( std::string(macBundlePath() + "/" + archName), typeName, secName);
1267#else
1268        Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);
1269#endif
1270      }
1271    }
1272  }
1273
1274  void Orxonox::setupRenderSystem()
1275  {
1276    if (!root_->restoreConfig() && !root_->showConfigDialog())
1277      throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()");
1278  }
1279
1280  void Orxonox::createRenderWindow()
1281  {
1282    root_->initialise(true, "OrxonoxV2");
1283  }
1284
1285  void Orxonox::initializeResourceGroups()
1286  {
1287    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
1288    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
1289  }
1290
1291  /**
1292   *
1293   * @param
1294   */
1295  void Orxonox::createScene(void)
1296  {
1297        // Init audio
1298//    auMan_ = new audio::AudioManager();
1299
1300//    bulletMgr_ = new BulletManager();
1301
1302    // load this file from config
1303//    loader_ = new loader::LevelLoader("sample.oxw");
1304//    loader_->loadLevel();
1305
1306//    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
1307//    HUD* orxonoxHud;
1308//    orxonoxHud = new HUD();
1309//    orxonoxHud->setEnergyValue(20);
1310//    orxonoxHud->setEnergyDistr(20,20,60);
1311//    hudOverlay->show();
1312
1313        /*
1314    auMan_->ambientAdd("a1");
1315    auMan_->ambientAdd("a2");
1316    auMan_->ambientAdd("a3");
1317                                //auMan->ambientAdd("ambient1");
1318    auMan_->ambientStart();*/
1319  }
1320
1321
1322  /**
1323   *
1324   */
1325  void Orxonox::setupScene()
1326  {
1327//    SceneManager *mgr = ogre_->getSceneManager();
1328
1329
1330//    SceneNode* node = (SceneNode*)mgr->getRootSceneNode()->getChild("OgreHeadNode");
1331//     SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
1332
1333
1334/*
1335    particle::ParticleInterface *e = new particle::ParticleInterface(mgr,"engine","Orxonox/strahl");
1336    e->particleSystem_->setParameter("local_space","true");
1337    e->setPositionOfEmitter(0, Vector3(0,-10,0));
1338    e->setDirection(Vector3(0,0,-1));
1339    e->addToSceneNode(node);
1340*/
1341  }
1342
1343
1344  void Orxonox::setupInputSystem()
1345  {
1346    size_t windowHnd = 0;
1347    std::ostringstream windowHndStr;
1348    OIS::ParamList pl;
1349
1350    // fixes auto repeat problem
1351    #if defined OIS_LINUX_PLATFORM
1352      pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
1353    #endif
1354
1355      Ogre::RenderWindow *win = ogre_->getRoot()->getAutoCreatedWindow();
1356    win->getCustomAttribute("WINDOW", &windowHnd);
1357    windowHndStr << windowHnd;
1358    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
1359    inputManager_ = OIS::InputManager::createInputSystem(pl);
1360
1361    try
1362    {
1363      keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, false));
1364      mouse_ = static_cast<OIS::Mouse*>(inputManager_->createInputObject(OIS::OISMouse, true));
1365    }
1366    catch (const OIS::Exception &e)
1367    {
1368      throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem");
1369    }
1370  }
1371
1372  // FIXME we actually want to do this differently...
1373  void Orxonox::createFrameListener()
1374  {
1375    TickFrameListener* TickFL = new TickFrameListener();
1376    ogre_->getRoot()->addFrameListener(TickFL);
1377
1378    TimerFrameListener* TimerFL = new TimerFrameListener();
1379    ogre_->getRoot()->addFrameListener(TimerFL);
1380
1381    //if(mode_!=CLIENT) // FIXME just a hack ------- remove this in future
1382      frameListener_ = new OrxListener(keyboard_/*, auMan_*/, mode_);
1383    ogre_->getRoot()->addFrameListener(frameListener_);
1384  }
1385
1386  void Orxonox::startRenderLoop()
1387  {
1388    // FIXME
1389    // this is a hack!!!
1390    // the call to reset the mouse clipping size should probably be somewhere
1391    // else, however this works for the moment.
1392    unsigned int width, height, depth;
1393    int left, top;
1394    ogre_->getRoot()->getAutoCreatedWindow()->getMetrics(width, height, depth, left, top);
1395
1396    if(mode_!=CLIENT){
1397      const OIS::MouseState &ms = mouse_->getMouseState();
1398      ms.width = width;
1399      ms.height = height;
1400    }
1401    ogre_->getRoot()->startRendering();
1402  }
1403}
Note: See TracBrowser for help on using the repository browser.