[74] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * |
---|
| 4 | * |
---|
| 5 | * License notice: |
---|
| 6 | * |
---|
[462] | 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. |
---|
[74] | 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 |
---|
[462] | 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. |
---|
[74] | 20 | * |
---|
| 21 | * Author: |
---|
| 22 | * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 |
---|
| 23 | * Co-authors: |
---|
| 24 | * ... |
---|
| 25 | * |
---|
| 26 | */ |
---|
| 27 | |
---|
[142] | 28 | /** |
---|
| 29 | @file orxonox.cc |
---|
[462] | 30 | @brief Orxonox Main Class |
---|
[142] | 31 | */ |
---|
| 32 | |
---|
[462] | 33 | #include "orxonox.h" |
---|
| 34 | #include "graphicsEngine.h" |
---|
| 35 | |
---|
[379] | 36 | //#include <Ogre.h> |
---|
| 37 | // 40% speed up: (instead of Ogre.h) |
---|
| 38 | #include <OgreSceneNode.h> |
---|
| 39 | #include <OgreSceneManager.h> |
---|
| 40 | #include <OgreRoot.h> |
---|
| 41 | #include <OgreFrameListener.h> |
---|
| 42 | #include <OgreConfigFile.h> |
---|
| 43 | #include <OgreTextureManager.h> |
---|
| 44 | #include <OgreEntity.h> |
---|
| 45 | #include <OgreRenderWindow.h> |
---|
| 46 | |
---|
[137] | 47 | #include <OIS/OIS.h> |
---|
[346] | 48 | //#include <CEGUI/CEGUI.h> |
---|
| 49 | //#include <OgreCEGUIRenderer.h> |
---|
[74] | 50 | |
---|
[164] | 51 | #include <string> |
---|
| 52 | #include <iostream> |
---|
| 53 | |
---|
[496] | 54 | #include "objects/Tickable.h" |
---|
| 55 | #include "objects/Timer.h" |
---|
| 56 | #include "core/Factory.h" |
---|
| 57 | |
---|
[462] | 58 | #include "../loader/LevelLoader.h" |
---|
| 59 | #include "../audio/AudioManager.h" |
---|
[164] | 60 | |
---|
[337] | 61 | #include "spaceship_steering.h" |
---|
[164] | 62 | |
---|
[535] | 63 | #include "particle/ParticleInterface.h" |
---|
[337] | 64 | |
---|
[459] | 65 | //network stuff |
---|
[462] | 66 | #include "../network/Server.h" |
---|
| 67 | #include "../network/Client.h" |
---|
[473] | 68 | #include "../network/NetworkFrameListener.h" |
---|
[459] | 69 | |
---|
[142] | 70 | |
---|
[337] | 71 | namespace orxonox |
---|
| 72 | { |
---|
[462] | 73 | using namespace Ogre; |
---|
[74] | 74 | |
---|
[462] | 75 | // put this in seperate Class or solve the problem in another fashion |
---|
| 76 | class OrxListener : public FrameListener, public OIS::MouseListener |
---|
| 77 | { |
---|
| 78 | public: |
---|
[519] | 79 | OrxListener(OIS::Keyboard *keyboard, OIS::Mouse *mouse, audio::AudioManager* auMan, SpaceshipSteering* steering) |
---|
[462] | 80 | : mKeyboard(keyboard), mMouse(mouse) |
---|
| 81 | { |
---|
[530] | 82 | |
---|
| 83 | |
---|
| 84 | |
---|
[462] | 85 | speed = 250; |
---|
| 86 | loop = 100; |
---|
| 87 | rotate = 10; |
---|
| 88 | mouseX = 0; |
---|
| 89 | mouseY = 0; |
---|
| 90 | maxMouseX = 0; |
---|
| 91 | minMouseX = 0; |
---|
[337] | 92 | moved = false; |
---|
[530] | 93 | |
---|
[519] | 94 | steering_ = steering; |
---|
| 95 | |
---|
| 96 | steering_->brakeRotate(rotate*10); |
---|
| 97 | steering_->brakeLoop(loop); |
---|
| 98 | |
---|
[530] | 99 | |
---|
[462] | 100 | mMouse->setEventCallback(this); |
---|
| 101 | auMan_ = auMan; |
---|
[265] | 102 | } |
---|
[462] | 103 | bool frameStarted(const FrameEvent& evt) |
---|
| 104 | { |
---|
[135] | 105 | |
---|
[462] | 106 | auMan_->update(); |
---|
[74] | 107 | |
---|
[462] | 108 | mKeyboard->capture(); |
---|
| 109 | mMouse->capture(); |
---|
| 110 | if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) |
---|
[519] | 111 | steering_->moveForward(speed); |
---|
[462] | 112 | else |
---|
[519] | 113 | steering_->moveForward(0); |
---|
[462] | 114 | if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S)) |
---|
[519] | 115 | steering_->brakeForward(speed); |
---|
[462] | 116 | else |
---|
[519] | 117 | steering_->brakeForward(speed/10); |
---|
[462] | 118 | if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D)) |
---|
[519] | 119 | steering_->loopRight(loop); |
---|
[462] | 120 | else |
---|
[519] | 121 | steering_->loopRight(0); |
---|
[462] | 122 | if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A)) |
---|
[519] | 123 | steering_->loopLeft(loop); |
---|
[462] | 124 | else |
---|
[519] | 125 | steering_->loopLeft(0); |
---|
[337] | 126 | |
---|
[462] | 127 | if(moved) { |
---|
[512] | 128 | if (mouseY<=0) |
---|
[519] | 129 | steering_->rotateUp(-mouseY*rotate); |
---|
[462] | 130 | if (mouseY>0) |
---|
[519] | 131 | steering_->rotateDown(mouseY*rotate); |
---|
[462] | 132 | if (mouseX>0) |
---|
[519] | 133 | steering_->rotateRight(mouseX*rotate); |
---|
[512] | 134 | if (mouseX<=0) |
---|
[519] | 135 | steering_->rotateLeft(-mouseX*rotate); |
---|
[512] | 136 | mouseY = 0; |
---|
| 137 | mouseX = 0; |
---|
[462] | 138 | moved = false; |
---|
| 139 | } |
---|
| 140 | else { |
---|
[519] | 141 | steering_->rotateUp(0); |
---|
| 142 | steering_->rotateDown(0); |
---|
| 143 | steering_->rotateRight(0); |
---|
| 144 | steering_->rotateLeft(0); |
---|
[462] | 145 | } |
---|
[337] | 146 | |
---|
[519] | 147 | steering_->tick(evt.timeSinceLastFrame); |
---|
[530] | 148 | |
---|
| 149 | |
---|
| 150 | |
---|
[462] | 151 | // scenemanager->spacehip->tick(evt.timesincelastframe); |
---|
| 152 | if(mKeyboard->isKeyDown(OIS::KC_ESCAPE)) |
---|
| 153 | cout << "maximal MouseX: " << maxMouseX << "\tminMouseX: " << minMouseX << endl; |
---|
| 154 | return !mKeyboard->isKeyDown(OIS::KC_ESCAPE); |
---|
| 155 | } |
---|
[337] | 156 | |
---|
[462] | 157 | bool mouseMoved(const OIS::MouseEvent &e) |
---|
[265] | 158 | { |
---|
[511] | 159 | mouseX += e.state.X.rel; |
---|
| 160 | mouseY += e.state.Y.rel; |
---|
[462] | 161 | if(mouseX>maxMouseX) maxMouseX = mouseX; |
---|
| 162 | if(mouseX<minMouseX) minMouseX = mouseX; |
---|
| 163 | cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl; |
---|
| 164 | moved = true; |
---|
| 165 | return true; |
---|
[265] | 166 | } |
---|
[74] | 167 | |
---|
[462] | 168 | bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; } |
---|
| 169 | bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; } |
---|
[137] | 170 | |
---|
[265] | 171 | private: |
---|
[462] | 172 | float speed; |
---|
| 173 | float rotate; |
---|
| 174 | float loop; |
---|
| 175 | float mouseY; |
---|
| 176 | float mouseX; |
---|
| 177 | float maxMouseX; |
---|
| 178 | float minMouseX; |
---|
| 179 | bool moved; |
---|
[265] | 180 | OIS::Keyboard *mKeyboard; |
---|
| 181 | OIS::Mouse *mMouse; |
---|
[462] | 182 | audio::AudioManager* auMan_; |
---|
[519] | 183 | SpaceshipSteering* steering_; |
---|
[462] | 184 | }; |
---|
| 185 | // init static singleton reference of Orxonox |
---|
| 186 | Orxonox* Orxonox::singletonRef_ = NULL; |
---|
[137] | 187 | |
---|
[462] | 188 | /** |
---|
| 189 | * create a new instance of Orxonox |
---|
| 190 | */ |
---|
| 191 | Orxonox::Orxonox() |
---|
| 192 | { |
---|
| 193 | ogre_ = new GraphicsEngine(); |
---|
| 194 | } |
---|
[74] | 195 | |
---|
[462] | 196 | /** |
---|
| 197 | * destruct Orxonox |
---|
| 198 | */ |
---|
| 199 | Orxonox::~Orxonox() |
---|
| 200 | { |
---|
| 201 | // nothing to delete as for now |
---|
| 202 | } |
---|
[265] | 203 | |
---|
[462] | 204 | /** |
---|
| 205 | * initialization of Orxonox object |
---|
| 206 | * @param argc argument counter |
---|
| 207 | * @param argv list of arguments |
---|
| 208 | * @param path path to config (in home dir or something) |
---|
| 209 | */ |
---|
| 210 | void Orxonox::init(int argc, char **argv, std::string path) |
---|
| 211 | { |
---|
| 212 | //TODO: initialization with command line parameters |
---|
| 213 | //TODO: find config file (assuming executable directory) |
---|
| 214 | //TODO: read config file |
---|
| 215 | //TODO: give config file to Ogre |
---|
[534] | 216 | |
---|
[462] | 217 | if(argc >=2 && strcmp(argv[1], "server")==0) |
---|
| 218 | { |
---|
| 219 | serverInit(path); |
---|
| 220 | } |
---|
| 221 | else if(argc >=2 && strcmp(argv[1], "client")==0) |
---|
| 222 | { |
---|
| 223 | clientInit(path); |
---|
[534] | 224 | } |
---|
| 225 | else if(argc >=2 && strcmp(argv[1], "presentation")==0) |
---|
[531] | 226 | { |
---|
| 227 | playableServer(path); |
---|
[534] | 228 | } |
---|
| 229 | else |
---|
[531] | 230 | standalone(path); |
---|
[462] | 231 | } |
---|
[263] | 232 | |
---|
[462] | 233 | /** |
---|
| 234 | * start modules |
---|
| 235 | */ |
---|
| 236 | void Orxonox::start() |
---|
| 237 | { |
---|
| 238 | //TODO: start modules |
---|
[534] | 239 | ogre_->startRender(); |
---|
[462] | 240 | //TODO: run engine |
---|
[534] | 241 | createScene(); |
---|
| 242 | setupScene(); |
---|
| 243 | setupInputSystem(); |
---|
| 244 | createFrameListener(); |
---|
| 245 | Factory::createClassHierarchy(); |
---|
| 246 | startRenderLoop(); |
---|
[462] | 247 | } |
---|
[74] | 248 | |
---|
[462] | 249 | /** |
---|
| 250 | * @return singleton object |
---|
| 251 | */ |
---|
| 252 | Orxonox* Orxonox::getSingleton() |
---|
| 253 | { |
---|
| 254 | if (!singletonRef_) |
---|
| 255 | singletonRef_ = new Orxonox(); |
---|
| 256 | return singletonRef_; |
---|
| 257 | } |
---|
[74] | 258 | |
---|
[462] | 259 | /** |
---|
| 260 | * error kills orxonox |
---|
| 261 | */ |
---|
| 262 | void Orxonox::die(/* some error code */) |
---|
| 263 | { |
---|
| 264 | //TODO: destroy and destruct everything and print nice error msg |
---|
| 265 | } |
---|
[74] | 266 | |
---|
[462] | 267 | void Orxonox::standalone(std::string path) |
---|
| 268 | { |
---|
| 269 | ogre_->setConfigPath(path); |
---|
| 270 | ogre_->setup(); |
---|
[473] | 271 | root_ = ogre_->getRoot(); |
---|
[534] | 272 | if(!ogre_->load()) die(/* unable to load */); |
---|
[473] | 273 | |
---|
[534] | 274 | //defineResources(); |
---|
| 275 | //setupRenderSystem(); |
---|
| 276 | //createRenderWindow(); |
---|
| 277 | //initializeResourceGroups(); |
---|
| 278 | /*createScene(); |
---|
[473] | 279 | setupScene(); |
---|
| 280 | setupInputSystem(); |
---|
| 281 | createFrameListener(); |
---|
[496] | 282 | Factory::createClassHierarchy(); |
---|
[534] | 283 | startRenderLoop();*/ |
---|
[462] | 284 | } |
---|
[534] | 285 | |
---|
[531] | 286 | void Orxonox::playableServer(std::string path) |
---|
| 287 | { |
---|
| 288 | ogre_->setConfigPath(path); |
---|
| 289 | ogre_->setup(); |
---|
| 290 | root_ = ogre_->getRoot(); |
---|
| 291 | defineResources(); |
---|
| 292 | setupRenderSystem(); |
---|
| 293 | createRenderWindow(); |
---|
| 294 | initializeResourceGroups(); |
---|
| 295 | createScene(); |
---|
| 296 | setupScene(); |
---|
| 297 | setupInputSystem(); |
---|
| 298 | Factory::createClassHierarchy(); |
---|
| 299 | createFrameListener(); |
---|
| 300 | try{ |
---|
[534] | 301 | server_g = new network::Server(); // add port and bindadress |
---|
| 302 | server_g->open(); // open server and create listener thread |
---|
| 303 | if(ogre_ && ogre_->getRoot()) |
---|
| 304 | ogre_->getRoot()->addFrameListener(new network::ServerFrameListener()); // adds a framelistener for the server |
---|
| 305 | std::cout << "network framelistener added" << std::endl; |
---|
| 306 | } |
---|
[531] | 307 | catch(exception &e) |
---|
| 308 | { |
---|
| 309 | std::cout << "There was a problem initialising the server :(" << std::endl; |
---|
| 310 | } |
---|
| 311 | startRenderLoop(); |
---|
| 312 | } |
---|
[74] | 313 | |
---|
[462] | 314 | void Orxonox::serverInit(std::string path) |
---|
| 315 | { |
---|
| 316 | ogre_->setConfigPath(path); |
---|
| 317 | ogre_->setup(); |
---|
[473] | 318 | server_g = new network::Server(); // add some settings if wanted |
---|
[462] | 319 | if(!ogre_->load()) die(/* unable to load */); |
---|
[505] | 320 | ogre_->getRoot()->addFrameListener(new network::ServerFrameListener()); |
---|
[462] | 321 | ogre_->startRender(); |
---|
[389] | 322 | |
---|
[462] | 323 | createScene(); |
---|
| 324 | setupScene(); |
---|
| 325 | } |
---|
[164] | 326 | |
---|
[462] | 327 | void Orxonox::clientInit(std::string path) |
---|
| 328 | { |
---|
| 329 | ogre_->setConfigPath(path); |
---|
| 330 | ogre_->setup(); |
---|
[473] | 331 | client_g = new network::Client(); // address here |
---|
[462] | 332 | if(!ogre_->load()) die(/* unable to load */); |
---|
[505] | 333 | ogre_->getRoot()->addFrameListener(new network::ClientFrameListener()); |
---|
[462] | 334 | ogre_->startRender(); |
---|
[389] | 335 | |
---|
[462] | 336 | createScene(); |
---|
| 337 | setupScene(); |
---|
| 338 | setupInputSystem(); |
---|
| 339 | createFrameListener(); |
---|
| 340 | startRenderLoop(); |
---|
| 341 | } |
---|
[258] | 342 | |
---|
[473] | 343 | void Orxonox::defineResources() |
---|
| 344 | { |
---|
| 345 | Ogre::String secName, typeName, archName; |
---|
| 346 | Ogre::ConfigFile cf; |
---|
| 347 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
| 348 | cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); |
---|
| 349 | #else |
---|
| 350 | cf.load("resources.cfg"); |
---|
| 351 | #endif |
---|
| 352 | |
---|
| 353 | Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); |
---|
| 354 | while (seci.hasMoreElements()) |
---|
| 355 | { |
---|
| 356 | secName = seci.peekNextKey(); |
---|
| 357 | Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); |
---|
| 358 | Ogre::ConfigFile::SettingsMultiMap::iterator i; |
---|
| 359 | for (i = settings->begin(); i != settings->end(); ++i) |
---|
| 360 | { |
---|
| 361 | typeName = i->first; |
---|
| 362 | archName = i->second; |
---|
| 363 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
| 364 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName); |
---|
| 365 | #else |
---|
| 366 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); |
---|
| 367 | #endif |
---|
| 368 | } |
---|
| 369 | } |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | void Orxonox::setupRenderSystem() |
---|
| 373 | { |
---|
| 374 | if (!root_->restoreConfig() && !root_->showConfigDialog()) |
---|
| 375 | throw Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | void Orxonox::createRenderWindow() |
---|
| 379 | { |
---|
| 380 | root_->initialise(true, "OrxonoxV2"); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | void Orxonox::initializeResourceGroups() |
---|
| 384 | { |
---|
| 385 | TextureManager::getSingleton().setDefaultNumMipmaps(5); |
---|
| 386 | ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); |
---|
| 387 | } |
---|
| 388 | |
---|
[537] | 389 | /** |
---|
| 390 | * |
---|
| 391 | * @param |
---|
| 392 | */ |
---|
[462] | 393 | void Orxonox::createScene(void) |
---|
| 394 | { |
---|
[480] | 395 | // Init audio |
---|
[462] | 396 | auMan_ = new audio::AudioManager(); |
---|
[487] | 397 | |
---|
[480] | 398 | // load this file from config |
---|
| 399 | loader_ = new loader::LevelLoader("sample.oxw"); |
---|
| 400 | loader_->loadLevel(); |
---|
[337] | 401 | |
---|
[515] | 402 | |
---|
| 403 | |
---|
| 404 | |
---|
| 405 | |
---|
[480] | 406 | /* |
---|
[462] | 407 | auMan_->ambientAdd("a1"); |
---|
| 408 | auMan_->ambientAdd("a2"); |
---|
| 409 | auMan_->ambientAdd("a3"); |
---|
| 410 | //auMan->ambientAdd("ambient1"); |
---|
| 411 | auMan_->ambientStart(); |
---|
[480] | 412 | */ |
---|
[462] | 413 | } |
---|
[337] | 414 | |
---|
| 415 | |
---|
[537] | 416 | /** |
---|
| 417 | * |
---|
| 418 | */ |
---|
[462] | 419 | void Orxonox::setupScene() |
---|
| 420 | { |
---|
| 421 | SceneManager *mgr = ogre_->getSceneManager(); |
---|
[512] | 422 | |
---|
[515] | 423 | |
---|
[525] | 424 | SceneNode* node = (SceneNode*)mgr->getRootSceneNode()->getChild("OgreHeadNode"); |
---|
[541] | 425 | // SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0)); |
---|
[515] | 426 | |
---|
[337] | 427 | |
---|
[525] | 428 | steering_ = new SpaceshipSteering(500, 200, 200, 200); |
---|
| 429 | steering_->addNode(node); |
---|
[74] | 430 | |
---|
[537] | 431 | |
---|
| 432 | particle::ParticleInterface *e = new particle::ParticleInterface(mgr,"engine","Orxonox/strahl"); |
---|
[535] | 433 | e->particleSystem_->setParameter("local_space","true"); |
---|
[537] | 434 | e->setPositionOfEmitter(0, Vector3(0,-10,200)); |
---|
| 435 | e->setDirection(Vector3(0,0,-1)); |
---|
| 436 | e->addToSceneNode(node); |
---|
[535] | 437 | |
---|
[537] | 438 | particle::ParticleInterface *w = new particle::ParticleInterface(mgr,"schuss","Orxonox/schuss"); |
---|
| 439 | w->particleSystem_->setParameter("local_space","true"); |
---|
| 440 | w->newEmitter(); |
---|
| 441 | w->setDirection(Vector3(0,0,1)); |
---|
| 442 | w->setPositionOfEmitter(0, Vector3(10,10,0)); |
---|
| 443 | w->setPositionOfEmitter(1, Vector3(-10,10,0)); |
---|
| 444 | w->addToSceneNode(node); |
---|
[462] | 445 | } |
---|
[137] | 446 | |
---|
| 447 | |
---|
[462] | 448 | void Orxonox::setupInputSystem() |
---|
| 449 | { |
---|
| 450 | size_t windowHnd = 0; |
---|
| 451 | std::ostringstream windowHndStr; |
---|
| 452 | OIS::ParamList pl; |
---|
| 453 | Ogre::RenderWindow *win = ogre_->getRoot()->getAutoCreatedWindow(); |
---|
[137] | 454 | |
---|
[462] | 455 | win->getCustomAttribute("WINDOW", &windowHnd); |
---|
| 456 | windowHndStr << windowHnd; |
---|
| 457 | pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); |
---|
| 458 | inputManager_ = OIS::InputManager::createInputSystem(pl); |
---|
[265] | 459 | |
---|
[462] | 460 | try |
---|
[337] | 461 | { |
---|
[462] | 462 | keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, false)); |
---|
| 463 | mouse_ = static_cast<OIS::Mouse*>(inputManager_->createInputObject(OIS::OISMouse, true)); |
---|
[337] | 464 | } |
---|
[462] | 465 | catch (const OIS::Exception &e) |
---|
[459] | 466 | { |
---|
[462] | 467 | throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem"); |
---|
[459] | 468 | } |
---|
[462] | 469 | } |
---|
[137] | 470 | |
---|
[462] | 471 | // we actually want to do this differently... |
---|
| 472 | void Orxonox::createFrameListener() |
---|
[137] | 473 | { |
---|
[496] | 474 | TickFrameListener* TickFL = new TickFrameListener(); |
---|
| 475 | ogre_->getRoot()->addFrameListener(TickFL); |
---|
| 476 | |
---|
| 477 | TimerFrameListener* TimerFL = new TimerFrameListener(); |
---|
| 478 | ogre_->getRoot()->addFrameListener(TimerFL); |
---|
| 479 | |
---|
[519] | 480 | frameListener_ = new OrxListener(keyboard_, mouse_, auMan_, steering_); |
---|
[462] | 481 | ogre_->getRoot()->addFrameListener(frameListener_); |
---|
[137] | 482 | } |
---|
[462] | 483 | |
---|
| 484 | void Orxonox::startRenderLoop() |
---|
[137] | 485 | { |
---|
[511] | 486 | // this is a hack!!! |
---|
| 487 | // the call to reset the mouse clipping size should probably be somewhere |
---|
| 488 | // else, however this works for the moment. |
---|
[523] | 489 | unsigned int width, height, depth; |
---|
| 490 | int left, top; |
---|
| 491 | ogre_->getRoot()->getAutoCreatedWindow()->getMetrics(width, height, depth, left, top); |
---|
[511] | 492 | |
---|
[523] | 493 | const OIS::MouseState &ms = mouse_->getMouseState(); |
---|
| 494 | ms.width = width; |
---|
| 495 | ms.height = height; |
---|
[511] | 496 | |
---|
[462] | 497 | ogre_->getRoot()->startRendering(); |
---|
[74] | 498 | } |
---|
| 499 | } |
---|