Changeset 6091 for code/branches/steering
- Timestamp:
- Nov 18, 2009, 4:39:56 PM (15 years ago)
- Location:
- code/branches/steering
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/steering/data/defaultConfig/keybindings.ini
r5929 r6091 122 122 KeyStop= 123 123 KeySystemRequest= 124 KeyT= 125 KeyTab=" cycleNavigationFocus"126 KeyU= 124 KeyT="" 125 KeyTab="NewHumanController changeMode" 126 KeyU="" 127 127 KeyUP="scale 1 moveFrontBack" 128 128 KeyUnassigned="openConsole" -
code/branches/steering/src/orxonox/controllers/NewHumanController.cc
r6058 r6091 45 45 namespace orxonox 46 46 { 47 SetConsoleCommand(NewHumanController, changeMode, false).keybindMode(KeybindMode::OnPress); 48 47 49 CreateUnloadableFactory(NewHumanController); 50 51 NewHumanController* NewHumanController::localController_s = 0; 48 52 49 53 NewHumanController::NewHumanController(BaseObject* creator) : HumanController(creator) … … 63 67 this->targetMask_.include(ClassByString("WorldEntity")); 64 68 this->targetMask_.exclude(ClassByString("Projectile")); 69 70 NewHumanController::localController_s = this; 65 71 } 66 72 … … 119 125 Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray()); 120 126 121 //std::cout << "X: " << static_cast<float>(this->currentYaw_)/2*-1+.5 << " Y: " << static_cast<float>(this->currentPitch_)/2*-1+.5 << endl;122 123 127 Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5, static_cast<float>(this->currentPitch_)/2*-1+.5); 124 128 … … 140 144 for (itr = result.begin(); itr != result.end(); ++itr) 141 145 { 142 //std::cout << "distance: " << itr->distance << " name: " << itr->movable->getName() << " type: " << itr->movable->getMovableType();143 146 if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500) 144 147 { … … 151 154 continue; 152 155 } 153 //std::cout << " TAGGED"; 156 154 157 itr->movable->getParentSceneNode()->showBoundingBox(true); 155 std::cout << itr->movable->getParentSceneNode()->_getDerivedPosition() << endl;156 return itr->movable->getParentSceneNode()->_getDerivedPosition();158 //std::cout << itr->movable->getParentSceneNode()->_getDerivedPosition() << endl; 159 return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition() 157 160 } 158 //std::cout << endl; 161 159 162 } 160 163 161 //if (result.front().movable->isInScene()) std::cout << "in scene" << endl; 162 // && result.front().movable->getParentSceneNode() != NULL) result.front().movable->getParentSceneNode()->showBoundingBox(true); 163 //result.front().movable->setVisible(false); 164 return mouseRay.getOrigin() + mouseRay.getDirection() * 1200; 164 165 165 //std::cout << endl; 166 /* 167 if (!result.empty()) { 168 Ogre::RaySceneQueryResultEntry obj = result.front(); 169 std::cout << "distance: " << obj.distance << " name: " << obj.movable->getName() << endl; 170 } 171 */ 172 return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 800); 166 //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000); 173 167 //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getOgreCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z); 174 168 } … … 177 171 { 178 172 // SUPER(NewHumanController, yaw, value); 179 HumanController::yaw(value); 173 if (this->controlMode_ == 0) 174 HumanController::yaw(value); 180 175 181 176 this->currentYaw_ = value.x; … … 186 181 { 187 182 // SUPER(NewHumanController, pitch, value); 188 HumanController::pitch(value); 189 183 if (this->controlMode_ == 0) 184 HumanController::pitch(value); 185 190 186 this->currentPitch_ = value.x; 191 187 //std::cout << "Y: " << static_cast<float>(this->currentPitch_) << " X: " << static_cast<float>(this->currentYaw_) << endl; 192 188 } 189 190 void NewHumanController::changeMode() { 191 if (NewHumanController::localController_s->controlMode_ == 0) 192 NewHumanController::localController_s->controlMode_ = 1; 193 else 194 NewHumanController::localController_s->controlMode_ = 0; 195 } 193 196 } -
code/branches/steering/src/orxonox/controllers/NewHumanController.h
r6055 r6091 27 27 */ 28 28 29 #ifndef _NewNewHumanController_H__ 29 #ifndef _NewNewHumanController_H__ 30 30 #define _NewNewHumanController_H__ 31 31 … … 50 50 virtual void doFire(unsigned int firemode); 51 51 52 void changeMode(unsigned int controleMode);52 static void changeMode(); 53 53 54 54 virtual bool canFindTarget() { return true; } 55 55 virtual Vector3 getTarget(); 56 56 57 protected: 58 unsigned int controlMode_; 59 static NewHumanController* localController_s; 57 60 private: 58 61 float currentYaw_; … … 60 63 OrxonoxOverlay* crossHairOverlay_; 61 64 float overlaySize_; 62 unsigned int controlMode_;63 65 ClassTreeMask targetMask_; 64 66 };
Note: See TracChangeset
for help on using the changeset viewer.