Changeset 1272 for code/branches/merge/src/orxonox
- Timestamp:
- May 14, 2008, 11:44:17 AM (17 years ago)
- Location:
- code/branches/merge/src/orxonox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/merge/src/orxonox/Orxonox.cc
r1268 r1272 290 290 // The render window width and height are used to set up the mouse movement. 291 291 if (!InputManager::initialise(ogre_->getWindowHandle(), 292 ogre_->getWindowWidth(), ogre_->getWindowHeight() ))292 ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true)) 293 293 return false; 294 294 … … 495 495 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 496 496 it->tick((float)evt.timeSinceLastFrame * this->timefactor_); 497 orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_); 497 // Iterate through all TickableReals and call their tick(dt) function 498 for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it) 499 it->tick((float)evt.timeSinceLastFrame); 500 orxonoxConsole_->tick((float)evt.timeSinceLastFrame); 498 501 499 502 // don't forget to call _fireFrameStarted in ogre to make sure -
code/branches/merge/src/orxonox/objects/SpaceShip.cc
r1265 r1272 142 142 void SpaceShip::init() 143 143 { 144 145 146 147 148 149 150 151 144 if ((!network::Client::getSingleton() || network::Client::getSingleton()->getShipID()==objectID )) 145 { 146 if (!setMouseEventCallback_) 147 { 148 InputManager::addMouseHandler(this, "SpaceShip"); 149 setMouseEventCallback_ = true; 150 } 151 } 152 152 153 153 // START CREATING THRUSTER … … 233 233 234 234 COUT(4) << "Loader: Initialized spaceship steering with values " << maxSpeedForward_ << " " << maxSpeedRotateUpDown_ << " " << maxSpeedRotateRightLeft_ << " " << maxSpeedLoopRightLeft_ << " " << std::endl; 235 235 } 236 236 */ 237 237 if (xmlElem->Attribute("maxSpeed") && xmlElem->Attribute("maxSideAndBackSpeed") && xmlElem->Attribute("maxRotation") && xmlElem->Attribute("transAcc") && xmlElem->Attribute("rotAcc") && xmlElem->Attribute("transDamp") && xmlElem->Attribute("rotDamp")) … … 259 259 260 260 COUT(4) << "Loader: Initialized SpaceShip" << std::endl; 261 262 263 264 265 266 261 } 262 263 if (xmlElem->Attribute("camera")) 264 { 265 this->setCamera(); 266 } 267 267 } 268 268 … … 349 349 } 350 350 351 bool SpaceShip::mouseMoved(const OIS::MouseEvent &e)351 bool SpaceShip::mouseMoved(const MouseState& state) 352 352 { 353 353 /* … … 366 366 if (this->bRMousePressed_) 367 367 { 368 this->camNode_->roll(Degree(- e.state.X.rel * 0.10));369 this->camNode_->yaw(Degree( e.state.Y.rel * 0.10));370 } 371 else 372 { 373 float minDimension = e.state.height;374 if ( e.state.width < minDimension)375 minDimension = e.state.width;376 377 this->mouseX_ += e.state.X.rel;368 this->camNode_->roll(Degree(-state.X.rel * 0.10)); 369 this->camNode_->yaw(Degree(state.Y.rel * 0.10)); 370 } 371 else 372 { 373 float minDimension = state.height; 374 if (state.width < minDimension) 375 minDimension = state.width; 376 377 this->mouseX_ += state.X.rel; 378 378 if (this->mouseX_ < -minDimension) 379 379 this->mouseX_ = -minDimension; … … 381 381 this->mouseX_ = minDimension; 382 382 383 this->mouseY_ += e.state.Y.rel;383 this->mouseY_ += state.Y.rel; 384 384 if (this->mouseY_ < -minDimension) 385 385 this->mouseY_ = -minDimension; … … 409 409 } 410 410 411 bool SpaceShip::mouse Pressed(const OIS::MouseEvent &e, OIS::MouseButtonIDid)412 { 413 if (id == OIS::MB_Left)411 bool SpaceShip::mouseButtonPressed(const MouseState& state, MouseButton::Enum id) 412 { 413 if (id == MouseButton::Left) 414 414 this->bLMousePressed_ = true; 415 else if (id == OIS::MB_Right)415 else if (id == MouseButton::Right) 416 416 this->bRMousePressed_ = true; 417 417 … … 419 419 } 420 420 421 bool SpaceShip::mouse Released(const OIS::MouseEvent &e, OIS::MouseButtonIDid)422 { 423 if (id == OIS::MB_Left)421 bool SpaceShip::mouseButtonReleased(const MouseState& state, MouseButton::Enum id) 422 { 423 if (id == MouseButton::Left) 424 424 this->bLMousePressed_ = false; 425 else if (id == OIS::MB_Right)425 else if (id == MouseButton::Right) 426 426 { 427 427 this->bRMousePressed_ = false; … … 454 454 this->timeToReload_ = this->reloadTime_; 455 455 } 456 457 OIS::Keyboard* mKeyboard = InputManager::getKeyboard();458 456 459 457 … … 523 521 } 524 522 525 if( (network::Client::getSingleton() && network::Client::getSingleton()->getShipID() == objectID) || server_ ){ 526 COUT(4) << "steering our ship: " << objectID << " mkeyboard: " << mKeyboard << std::endl; 527 if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) 523 if( (network::Client::getSingleton() && network::Client::getSingleton()->getShipID() == objectID) || server_ ) 524 { 525 COUT(4) << "steering our ship: " << objectID << std::endl; 526 if (InputManager::isKeyDown(KeyCode::Up) || InputManager::isKeyDown(KeyCode::W)) 528 527 this->acceleration_.x = this->translationAcceleration_; 529 else if( mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))528 else if(InputManager::isKeyDown(KeyCode::Down) || InputManager::isKeyDown(KeyCode::S)) 530 529 this->acceleration_.x = -this->translationAcceleration_; 531 530 else 532 531 this->acceleration_.x = 0; 533 532 534 if ( mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))533 if (InputManager::isKeyDown(KeyCode::Right) || InputManager::isKeyDown(KeyCode::D)) 535 534 this->acceleration_.y = -this->translationAcceleration_; 536 else if ( mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))535 else if (InputManager::isKeyDown(KeyCode::Left) || InputManager::isKeyDown(KeyCode::A)) 537 536 this->acceleration_.y = this->translationAcceleration_; 538 537 else 539 538 this->acceleration_.y = 0; 540 539 541 if ( mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))540 if (InputManager::isKeyDown(KeyCode::Delete) || InputManager::isKeyDown(KeyCode::Q)) 542 541 this->momentum_ = Radian(-this->rotationAccelerationRadian_); 543 else if ( mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))542 else if (InputManager::isKeyDown(KeyCode::PageDown) || InputManager::isKeyDown(KeyCode::E)) 544 543 this->momentum_ = Radian(this->rotationAccelerationRadian_); 545 544 else -
code/branches/merge/src/orxonox/objects/SpaceShip.h
r1264 r1272 34 34 #include <OgrePrerequisites.h> 35 35 36 #include "core/Input Handler.h"36 #include "core/InputInterfaces.h" 37 37 #include "Camera.h" 38 38 #include "Model.h" … … 68 68 { SpaceShip::instance_s->setMaxSpeed(value); } 69 69 70 bool mouseMoved(const OIS::MouseEvent &e); 71 bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id); 72 bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id); 73 bool mouseHeld(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; } 70 bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id); 71 bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id); 72 bool mouseButtonHeld (const MouseState& state, MouseButton::Enum id) { return true; } 73 bool mouseMoved (const MouseState& state); 74 bool mouseScrolled (const MouseState& state) { return true; } 74 75 75 76
Note: See TracChangeset
for help on using the changeset viewer.