- Timestamp:
- May 23, 2008, 4:02:03 PM (16 years ago)
- Location:
- code/branches/network
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/bin/keybindings.ini
r1379 r1391 17 17 KeyTAB= 18 18 KeyQ= 19 KeyW= 20 KeyE= 21 KeyR= 19 KeyW=scale -1 moveRoll 20 KeyE=moveLongitudinal 21 KeyR=moveRoll 22 22 KeyT= 23 23 KeyY= … … 31 31 KeyLCONTROL= 32 32 KeyA= 33 KeyS= 34 KeyD= 35 KeyF= 33 KeyS=scale -1 moveLateral 34 KeyD=scale -1 moveLongitudinal 35 KeyF=moveLateral 36 36 KeyG= 37 KeyH= 38 KeyJ= 39 KeyK= 40 KeyL= 37 KeyH=scale -0.3 moveYaw 38 KeyJ=scale -0.3 movePitch 39 KeyK=scale 0.3 movePitch 40 KeyL=scale 0.3 moveYaw 41 41 KeySEMICOLON= 42 42 KeyAPOSTROPHE= … … 146 146 KeyMAIL= 147 147 KeyMEDIASELECT= 148 MouseLeft= 149 MouseRight= 150 MouseMiddle= 151 MouseButton3= 152 MouseButton4= 153 MouseButton5= 154 MouseButton6= 155 MouseButton7= 156 MouseWheel1Up= AxisAmp0.1 slomo157 MouseWheel1Down= AxisAmp0.1 slomo148 MouseLeft=fire 149 MouseRight=fire 150 MouseMiddle=fire 151 MouseButton3=fire 152 MouseButton4=fire 153 MouseButton5=fire 154 MouseButton6=fire 155 MouseButton7=fire 156 MouseWheel1Up=scale 0.1 slomo 157 MouseWheel1Down=scale 0.1 slomo 158 158 MouseWheel2Up= 159 159 MouseWheel2Down= 160 MouseXPos= #exit | ButtonThreshold 0.85161 MouseXNeg= 162 MouseYPos= 163 MouseYNeg= 160 MouseXPos=scale 1 moveYaw 161 MouseXNeg=scale -1 moveYaw 162 MouseYPos=scale 1 movePitch 163 MouseYNeg=scale -1 movePitch 164 164 Empty1Pos= 165 165 Empty1Neg= 166 166 Empty2Pos= 167 167 Empty2Neg= 168 JoyAxis1Pos= 169 JoyAxis1Neg= 168 JoyAxis1Pos=scale -1 movePitch 169 JoyAxis1Neg=scale 1 movePitch 170 170 JoyAxis2Pos= 171 171 JoyAxis2Neg= … … 175 175 JoyAxis4Neg= 176 176 JoyAxis5Pos= 177 JoyAxis5Neg= #AxisAmp 10 slomo | ButtonThreshold 0.9 | onPress exit178 JoyAxis6Pos= #AxisAmp 10 slomo177 JoyAxis5Neg= 178 JoyAxis6Pos= 179 179 JoyAxis6Neg= 180 180 JoyAxis7Pos= … … 182 182 JoyAxis8Pos= 183 183 JoyAxis8Neg= 184 JoyAxis9Pos= 185 JoyAxis9Neg= 184 JoyAxis9Pos=scale 1 moveYaw 185 JoyAxis9Neg=scale -1 moveYaw 186 186 JoyAxis10Pos= 187 187 JoyAxis10Neg= 188 JoyAxis11Pos= 189 JoyAxis11Neg= 190 JoyAxis12Pos= 191 JoyAxis12Neg= 188 JoyAxis11Pos=scale -1 moveLongitudinal 189 JoyAxis11Neg=scale 1 moveLongitudinal 190 JoyAxis12Pos=scale 1 moveLateral 191 JoyAxis12Neg=scale -1 moveLateral 192 192 JoyAxis13Pos= 193 193 JoyAxis13Neg= … … 214 214 JoyAxis24Pos= 215 215 JoyAxis24Neg= 216 JoyButton0= 216 JoyButton0=cycleFocus 217 217 JoyButton1= 218 218 JoyButton2= … … 220 220 JoyButton4= 221 221 JoyButton5= 222 JoyButton6= 223 JoyButton7= 222 JoyButton6=scale 1 moveRoll 223 JoyButton7=scale -1 moveRoll 224 224 JoyButton8= 225 JoyButton9= 225 JoyButton9=fire 226 226 JoyButton10= 227 227 JoyButton11= -
code/branches/network/src/core/CommandExecutor.cc
r1349 r1391 403 403 if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_) 404 404 { 405 std::cout << "CE_execute (evaluation): " << evaluation.evaluatedExecutor_->getName() << " " << evaluation.param_[0] << " " << evaluation.param_[1] << " " << evaluation.param_[2] << " " << evaluation.param_[3] << " " << evaluation.param_[4] << std::endl;405 //std::cout << "CE_execute (evaluation): " << evaluation.evaluatedExecutor_->getName() << " " << evaluation.param_[0] << " " << evaluation.param_[1] << " " << evaluation.param_[2] << " " << evaluation.param_[3] << " " << evaluation.param_[4] << std::endl; 406 406 (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]); 407 407 return true; 408 408 } 409 409 410 std::cout << "CE_execute: " << evaluation.processedCommand_ << "\n";410 //std::cout << "CE_execute: " << evaluation.processedCommand_ << "\n"; 411 411 switch (evaluation.state_) 412 412 { -
code/branches/network/src/core/InputHandler.cc
r1349 r1391 159 159 // default amplitude is 1.0f 160 160 float paramModifier = 1.0f; 161 if (getLowercase(tokens[iToken]) == " axisamp")161 if (getLowercase(tokens[iToken]) == "scale") 162 162 { 163 163 iToken++; … … 307 307 KeyBinder::KeyBinder() : deriveTime_(0.0f) 308 308 { 309 mouseRelative_[0] = 0; 310 mouseRelative_[1] = 0; 311 mousePosition_[0] = 0; 312 mousePosition_[1] = 0; 313 309 314 RegisterObject(KeyBinder); 310 315 … … 477 482 { 478 483 SetConfigValue(analogThreshold_, 0.01f) .description("Threshold for analog axes until which the state is 0."); 484 SetConfigValue(mouseSensitivity_, 1.0f) .description("Mouse sensitivity."); 479 485 SetConfigValue(bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value."); 480 SetConfigValue(derivePeriod_, 0.1f) 481 SetConfigValue(mouseSensitivity _, 1.0f) .description("Mouse sensitivity.");486 SetConfigValue(derivePeriod_, 0.1f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier."); 487 SetConfigValue(mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived."); 482 488 483 489 float oldThresh = buttonThreshold_; … … 574 580 if (halfAxes_[i].relVal_ > analogThreshold_ || halfAxes_[i].absVal_ > analogThreshold_) 575 581 { 582 COUT(3) << halfAxes_[i].name_ << "\t" << halfAxes_[i].absVal_ << std::endl; 576 583 halfAxes_[i].execute(); 577 584 } … … 588 595 if (mouseRelative_[i] > 0) 589 596 { 590 halfAxes_[2*i + 0].absVal_ = mouseRelative_[i] * derivePeriod_ / 500 * mouseSensitivity_;597 halfAxes_[2*i + 0].absVal_ = mouseRelative_[i] / derivePeriod_ / 5000 * mouseSensitivityDerived_; 591 598 halfAxes_[2*i + 1].absVal_ = 0.0f; 592 599 } 593 else if (mouseRelative_[ 0] < 0)600 else if (mouseRelative_[i] < 0) 594 601 { 595 602 halfAxes_[2*i + 0].absVal_ = 0.0f; 596 halfAxes_[2*i + 1].absVal_ = -mouseRelative_[i] * derivePeriod_ / 500 * mouseSensitivity_; 603 halfAxes_[2*i + 1].absVal_ = -mouseRelative_[i] / derivePeriod_ / 5000 * mouseSensitivityDerived_; 604 } 605 else 606 { 607 halfAxes_[2*i + 0].absVal_ = 0.0f; 608 halfAxes_[2*i + 1].absVal_ = 0.0f; 597 609 } 598 610 //COUT(3) << mouseRelative_[i] << " | "; … … 672 684 } 673 685 else 674 halfAxes_[ 1+ 2*i].absVal_ = ((float)mousePosition_[i])/1024 * mouseSensitivity_;686 halfAxes_[0 + 2*i].absVal_ = ((float)mousePosition_[i])/1024 * mouseSensitivity_; 675 687 } 676 688 else … … 687 699 halfAxes_[1 + 2*i].absVal_ = -((float)mousePosition_[i])/1024 * mouseSensitivity_; 688 700 } 701 //COUT(3) << "half axis 0: " << halfAxes_[0].absVal_ << std::endl; 702 //COUT(3) << "half axis 1: " << halfAxes_[1].absVal_ << std::endl; 703 //COUT(3) << "half axis 2: " << halfAxes_[2].absVal_ << std::endl; 704 //COUT(3) << "half axis 3: " << halfAxes_[3].absVal_ << std::endl; 689 705 690 706 // relative … … 722 738 { 723 739 // TODO: check whether 16 bit integer as general axis value is a good idea (works under windows) 724 CCOUT(3) << halfAxes_[8 + axis].name_ << std::endl;740 int i = 8 + axis * 2; 725 741 if (value >= 0) 726 742 { 727 halfAxes_[8 + axis].absVal_ = ((float)value)/0x8000; 728 halfAxes_[8 + axis].relVal_ = ((float)value)/0x8000; 729 halfAxes_[8 + axis].hasChanged_ = true; 743 //if (value > 10000) 744 //{ CCOUT(3) << halfAxes_[i].name_ << std::endl; } 745 746 halfAxes_[i].absVal_ = ((float)value)/0x8000; 747 halfAxes_[i].relVal_ = ((float)value)/0x8000; 748 halfAxes_[i].hasChanged_ = true; 749 if (halfAxes_[i + 1].absVal_ > 0) 750 { 751 halfAxes_[i + 1].absVal_ = -0.0f; 752 halfAxes_[i + 1].relVal_ = -0.0f; 753 halfAxes_[i + 1].hasChanged_ = true; 754 } 730 755 } 731 756 else 732 757 { 733 halfAxes_[8 + axis + 1].absVal_ = -((float)value)/0x8000; 734 halfAxes_[8 + axis + 1].relVal_ = -((float)value)/0x8000; 735 halfAxes_[8 + axis + 1].hasChanged_ = true; 758 //if (value < -10000) 759 //{ CCOUT(3) << halfAxes_[i + 1].name_ << std::endl; } 760 761 halfAxes_[i + 1].absVal_ = -((float)value)/0x8000; 762 halfAxes_[i + 1].relVal_ = -((float)value)/0x8000; 763 halfAxes_[i + 1].hasChanged_ = true; 764 if (halfAxes_[i].absVal_ > 0) 765 { 766 halfAxes_[i].absVal_ = -0.0f; 767 halfAxes_[i].relVal_ = -0.0f; 768 halfAxes_[i].hasChanged_ = true; 769 } 736 770 } 737 771 } -
code/branches/network/src/core/InputHandler.h
r1349 r1391 208 208 209 209 //! Keeps track of the absolute mouse value (incl. scroll wheel) 210 int mousePosition_[ 3];210 int mousePosition_[2]; 211 211 //! Used to derive mouse input if requested 212 212 int mouseRelative_[2]; … … 224 224 //! mouse sensitivity 225 225 float mouseSensitivity_; 226 //! mouse sensitivity if mouse input is derived 227 float mouseSensitivityDerived_; 226 228 }; 227 229 -
code/branches/network/src/core/InputManager.cc
r1349 r1391 603 603 604 604 // check whether the button already is in the list (can happen when focus was lost) 605 std::vector<int> buttonsDown = joyStickButtonsDown_[iJoyStick];605 std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick]; 606 606 unsigned int iButton = 0; 607 607 while (iButton < buttonsDown.size() && buttonsDown[iButton] != button) … … 625 625 626 626 // remove the button from the joyStickButtonsDown_ list 627 std::vector<int> buttonsDown = joyStickButtonsDown_[iJoyStick];627 std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick]; 628 628 for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++) 629 629 { … … 643 643 bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis) 644 644 { 645 //CCOUT(3) << arg.state.mAxes[axis].abs << std::endl; 645 //if (arg.state.mAxes[axis].abs > 10000 || arg.state.mAxes[axis].abs < -10000) 646 //{ CCOUT(3) << "axis " << axis << " moved" << arg.state.mAxes[axis].abs << std::endl;} 646 647 // use the device to identify which one called the method 647 648 OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device; … … 659 660 bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id) 660 661 { 662 //if (arg.state.mSliders[id].abX > 10000 || arg.state.mSliders[id].abX < -10000) 663 //{CCOUT(3) << "slider " << id << " moved" << arg.state.mSliders[id].abX << std::endl;} 661 664 //CCOUT(3) << arg.state.mSliders[id].abX << "\t |" << arg.state.mSliders[id].abY << std::endl; 662 665 // use the device to identify which one called the method -
code/branches/network/src/orxonox/Orxonox.cc
r1379 r1391 517 517 // again, just to be sure ogre works fine 518 518 ogreRoot._fireFrameEnded(evt); 519 //msleep(100); 519 520 } 520 521 -
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.