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