Changeset 1391 for code/branches/network/src/orxonox/objects
- Timestamp:
- May 23, 2008, 4:02:03 PM (16 years ago)
- Location:
- code/branches/network/src/orxonox/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/objects/SpaceShip.cc
r1386 r1391 53 53 ConsoleCommand(SpaceShip, setMaxSpeedTest, AccessLevel::Debug, false); 54 54 ConsoleCommand(SpaceShip, whereAmI, AccessLevel::User, true); 55 ConsoleCommand(SpaceShip, moveLongitudinal, AccessLevel::User, true).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 56 ConsoleCommand(SpaceShip, moveLateral, AccessLevel::User, true).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 57 ConsoleCommand(SpaceShip, moveYaw, AccessLevel::User, true).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 58 ConsoleCommand(SpaceShip, movePitch, AccessLevel::User, true).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 59 ConsoleCommand(SpaceShip, moveRoll, AccessLevel::User, true).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold); 60 ConsoleCommand(SpaceShip, fire, AccessLevel::User, true).setKeybindMode(KeybindMode::OnHold); 55 61 ConsoleCommandGeneric(test1, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed", AccessLevel::Debug), false); 56 62 ConsoleCommandGeneric(test2, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber", AccessLevel::Debug), false); … … 308 314 } 309 315 310 void SpaceShip::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)311 {312 /*313 this->mouseX += e.state.X.rel;314 if (this->bInvertMouse_)315 this->mouseY += e.state.Y.rel;316 else317 this->mouseY -= e.state.Y.rel;318 319 // if(mouseX>maxMouseX) maxMouseX = mouseX;320 // if(mouseX<minMouseX) minMouseX = mouseX;321 // cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;322 323 this->moved = true;324 */325 if (this->bRMousePressed_)326 {327 this->camNode_->roll(Degree(-rel.x * 0.10));328 this->camNode_->yaw(Degree(rel.y * 0.10));329 }330 else331 {332 float minDimension = clippingSize.y;333 if (clippingSize.x < minDimension)334 minDimension = clippingSize.x;335 336 this->mouseX_ += rel.x;337 if (this->mouseX_ < -minDimension)338 this->mouseX_ = -minDimension;339 if (this->mouseX_ > minDimension)340 this->mouseX_ = minDimension;341 342 this->mouseY_ += rel.y;343 if (this->mouseY_ < -minDimension)344 this->mouseY_ = -minDimension;345 if (this->mouseY_ > minDimension)346 this->mouseY_ = minDimension;347 348 float xRotation = this->mouseX_ / minDimension;349 xRotation = xRotation*xRotation * sgn(xRotation);350 xRotation *= -this->rotationAcceleration_;351 if (xRotation > this->maxRotation_)352 xRotation = this->maxRotation_;353 if (xRotation < -this->maxRotation_)354 xRotation = -this->maxRotation_;355 this->mouseXRotation_ = Radian(xRotation);356 357 float yRotation = this->mouseY_ / minDimension;358 yRotation = yRotation*yRotation * sgn(yRotation);359 yRotation *= this->rotationAcceleration_;360 if (yRotation > this->maxRotation_)361 yRotation = this->maxRotation_;362 if (yRotation < -this->maxRotation_)363 yRotation = -this->maxRotation_;364 this->mouseYRotation_ = Radian(yRotation);365 }366 }367 368 316 void SpaceShip::mouseButtonPressed(MouseButton::Enum id) 369 317 { 370 if (id == MouseButton::Left) 371 this->bLMousePressed_ = true; 372 else if (id == MouseButton::Right) 318 if (id == MouseButton::Right) 373 319 this->bRMousePressed_ = true; 374 320 } … … 376 322 void SpaceShip::mouseButtonReleased(MouseButton::Enum id) 377 323 { 378 if (id == MouseButton::Left) 379 this->bLMousePressed_ = false; 380 else if (id == MouseButton::Right) 324 if (id == MouseButton::Right) 381 325 { 382 326 this->bRMousePressed_ = false; … … 495 439 } 496 440 497 if( (network::Client::getSingleton() && network::Client::getSingleton()->getShipID() == objectID) || server_ )498 {499 COUT(4) << "steering our ship: " << objectID << std::endl;500 if (InputManager::isKeyDown(KeyCode::Up) || InputManager::isKeyDown(KeyCode::W))501 this->acceleration_.x = this->translationAcceleration_;502 else if(InputManager::isKeyDown(KeyCode::Down) || InputManager::isKeyDown(KeyCode::S))503 this->acceleration_.x = -this->translationAcceleration_;504 else505 this->acceleration_.x = 0;506 507 if (InputManager::isKeyDown(KeyCode::Right) || InputManager::isKeyDown(KeyCode::D))508 this->acceleration_.y = -this->translationAcceleration_;509 else if (InputManager::isKeyDown(KeyCode::Left) || InputManager::isKeyDown(KeyCode::A))510 this->acceleration_.y = this->translationAcceleration_;511 else512 this->acceleration_.y = 0;513 514 if (InputManager::isKeyDown(KeyCode::Delete) || InputManager::isKeyDown(KeyCode::Q))515 this->momentum_ = Radian(-this->rotationAccelerationRadian_);516 else if (InputManager::isKeyDown(KeyCode::PageDown) || InputManager::isKeyDown(KeyCode::E))517 this->momentum_ = Radian(this->rotationAccelerationRadian_);518 else519 this->momentum_ = 0;520 }/*else521 COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/522 441 523 442 WorldEntity::tick(dt); … … 533 452 else 534 453 this->tt_->setRate(0); 535 } 536 454 455 if( (network::Client::getSingleton() && network::Client::getSingleton()->getShipID() == objectID) || server_ ) 456 { 457 COUT(4) << "steering our ship: " << objectID << std::endl; 458 this->acceleration_.x = 0; 459 this->acceleration_.y = 0; 460 this->momentum_ = 0; 461 this->mouseXRotation_ = Radian(0); 462 this->mouseYRotation_ = Radian(0); 463 this->bLMousePressed_ = false; 464 }/*else 465 COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/ 466 } 467 void SpaceShip::movePitch(float val) 468 { 469 SpaceShip* this_ = getLocalShip(); 470 val = -val * val * sgn(val) * this_->rotationAcceleration_; 471 if (val > this_->maxRotation_) 472 val = this_->maxRotation_; 473 if (val < -this_->maxRotation_) 474 val = -this_->maxRotation_; 475 this_->mouseYRotation_ = Radian(val); 476 } 477 478 void SpaceShip::moveYaw(float val) 479 { 480 SpaceShip* this_ = getLocalShip(); 481 val = -val * val * sgn(val) * this_->rotationAcceleration_; 482 if (val > this_->maxRotation_) 483 val = this_->maxRotation_; 484 if (val < -this_->maxRotation_) 485 val = -this_->maxRotation_; 486 this_->mouseXRotation_ = Radian(val); 487 } 488 489 void SpaceShip::moveRoll(float val) 490 { 491 SpaceShip* this_ = getLocalShip(); 492 this_->momentum_ = Radian(-this_->rotationAccelerationRadian_ * val); 493 } 494 495 void SpaceShip::moveLongitudinal(float val) 496 { 497 SpaceShip* this_ = getLocalShip(); 498 COUT(3) << val << std::endl; 499 this_->acceleration_.x = this_->translationAcceleration_ * val; 500 } 501 502 void SpaceShip::moveLateral(float val) 503 { 504 SpaceShip* this_ = getLocalShip(); 505 this_->acceleration_.y = -this_->translationAcceleration_ * val; 506 } 507 508 void SpaceShip::fire() 509 { 510 SpaceShip* this_ = getLocalShip(); 511 this_->bLMousePressed_ = true; 512 } 537 513 } -
code/branches/network/src/orxonox/objects/SpaceShip.h
r1362 r1391 66 66 67 67 void getFocus(); 68 static SpaceShip* instance_s;69 68 static Vector3 getSPosition(); 70 69 static Quaternion getSOrientation(); … … 73 72 { SpaceShip::instance_s->setMaxSpeed(value); } 74 73 74 static void movePitch(float value); 75 static void moveYaw(float value); 76 static void moveRoll(float value); 77 static void moveLongitudinal(float value); 78 static void moveLateral(float value); 79 static void fire(); 80 75 81 void mouseButtonPressed (MouseButton::Enum id); 76 82 void mouseButtonReleased(MouseButton::Enum id); 77 83 void mouseButtonHeld (MouseButton::Enum id) { } 78 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) ;84 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) { } 79 85 void mouseScrolled (int abs, int rel) { } 80 86 … … 131 137 float emitterRate_; 132 138 bool server_; 139 140 static SpaceShip* instance_s; 133 141 }; 134 142 }
Note: See TracChangeset
for help on using the changeset viewer.