Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Fixed a small bug in the clean-function of ClassTreeMask (I made it recursively and forgot the recursion-call :D). From what I see now the ClassTreeMask works fine. And yes, I know it's overkill, no one will ever use more than 10% of the features, but I like it. ;)

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