Changeset 6111 for code/branches/presentation2/src/orxonox/controllers
- Timestamp:
- Nov 21, 2009, 12:33:37 AM (15 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2
- Property svn:mergeinfo changed
/code/branches/particles2 merged: 6109
- Property svn:mergeinfo changed
-
code/branches/presentation2/src/orxonox/controllers/Controller.h
r6108 r6111 54 54 virtual void changedControllableEntity() {} 55 55 56 virtual bool canFindTarget()57 { return false; }58 virtual Vector3 getTarget()59 { return Vector3::ZERO; }60 61 56 protected: 62 57 // don't use this directly, use getPlayer()->startControl(entity) (unless you know exactly what you do) -
code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
r6108 r6111 37 37 #include "core/ConsoleCommand.h" 38 38 #include "worldentities/ControllableEntity.h" 39 #include "worldentities/pawns/Pawn.h" 39 40 #include "infos/PlayerInfo.h" 40 41 #include "overlays/OrxonoxOverlay.h" … … 80 81 void NewHumanController::tick(float dt) 81 82 { 82 crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2)); 83 if( !this->controllableEntity_->isInMouseLook() ) 84 { 85 this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2)); 86 this->crossHairOverlay_->show(); 87 } 88 else 89 this->crossHairOverlay_->hide(); 90 // TODO: update aimPosition of Pawn 83 91 84 92 HumanController::tick(dt); … … 117 125 } 118 126 */ 127 if( !NewHumanController::localController_s->getControllableEntity()->isInMouseLook() ) 128 this->updateTarget(); 119 129 120 130 HumanController::localController_s->getControllableEntity()->fire(firemode); 121 131 } 122 132 123 Vector3 NewHumanController::getTarget()133 void NewHumanController::updateTarget() 124 134 { 125 135 Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray()); … … 140 150 141 151 Ogre::RaySceneQueryResult& result = rsq->execute(); 152 Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity()); 142 153 143 154 Ogre::RaySceneQueryResult::iterator itr; … … 154 165 continue; 155 166 } 167 168 this->getControllableEntity()->setTarget(wePtr); 156 169 157 170 itr->movable->getParentSceneNode()->showBoundingBox(true); 158 171 //std::cout << itr->movable->getParentSceneNode()->_getDerivedPosition() << endl; 159 return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition() 172 //return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition() 173 if ( pawn ) 174 { 175 pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance ); // or itr->movable->getParentSceneNode()->_getDerivedPosition() 176 pawn->setTarget( wePtr ); 177 } 178 return; 160 179 } 161 180 162 181 } 163 164 return mouseRay.getOrigin() + mouseRay.getDirection() * 1200; 182 if ( pawn ) 183 { 184 pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 1200 ); 185 pawn->setTarget( 0 ); 186 } 187 188 //return mouseRay.getOrigin() + mouseRay.getDirection() * 1200; 189 165 190 166 191 //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000); … … 189 214 190 215 void NewHumanController::changeMode() { 191 if (NewHumanController::localController_s->controlMode_ == 0) 192 NewHumanController::localController_s->controlMode_ = 1; 216 if (NewHumanController::localController_s && NewHumanController::localController_s->controlMode_ == 0) 217 { 218 if (NewHumanController::localController_s->controllableEntity_ && !NewHumanController::localController_s->controllableEntity_->isInMouseLook() ) 219 NewHumanController::localController_s->controlMode_ = 1; 220 } 193 221 else 194 222 NewHumanController::localController_s->controlMode_ = 0; -
code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
r6108 r6111 52 52 static void changeMode(); 53 53 54 virtual bool canFindTarget() { return true; }55 virtual Vector3 getTarget();56 57 54 protected: 55 void updateTarget(); 56 58 57 unsigned int controlMode_; 59 58 static NewHumanController* localController_s;
Note: See TracChangeset
for help on using the changeset viewer.