Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core2/src/orxonox/Orxonox.cc @ 952

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

moved core tests from core1 to core2

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