Changeset 6111 for code/branches/presentation2/src
- Timestamp:
- Nov 21, 2009, 12:33:37 AM (15 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 8 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; -
code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
r6108 r6111 202 202 this->muzzlePosition_ = this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_; 203 203 204 Controller* controller = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getController();205 if (controller->canFindTarget())206 {207 Vector3 muzzleDirection(controller->getTarget() - this->muzzlePosition_);208 this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();204 Pawn* pawn = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn(); 205 Vector3 muzzleDirection; 206 if ( pawn->getTarget() ) 207 { 208 muzzleDirection = pawn->getTarget()->getWorldPosition() - this->muzzlePosition_; 209 209 } 210 210 else 211 this->muzzleOrientation_ = this->weapon_->getWorldOrientation(); 211 muzzleDirection = pawn->getAimPosition() - this->muzzlePosition_; 212 // COUT(0) << "muzzleDirection " << muzzleDirection << endl; 213 //this->muzzleOrientation_ = this->weapon_->getWorldOrientation(); 214 this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation(); 212 215 } 213 216 else -
code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h
r6108 r6111 145 145 inline void setController(Controller* val) 146 146 { this->controller_ = val; } 147 148 virtual void setTarget( WorldEntity* target ) 149 { this->target_ = target; } 150 virtual WorldEntity* getTarget() 151 { return this->target_.get(); } 147 152 148 153 protected: … … 209 214 Controller* controller_; 210 215 CameraPosition* reverseCamera_; 216 WeakPtr<WorldEntity> target_; 211 217 }; 212 218 } -
code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc
r6107 r6111 67 67 68 68 this->spawnparticleduration_ = 3.0f; 69 70 this->aimPosition_ = Vector3::ZERO; 69 71 70 72 this->getPickups().setOwner(this); -
code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h
r6107 r6111 116 116 117 117 virtual void startLocalHumanControl(); 118 119 void setAimPosition( Vector3 position ) 120 { this->aimPosition_ = position; } 121 Vector3 getAimPosition() 122 { return this->aimPosition_; } 118 123 119 124 protected: … … 146 151 inline void setWeaponSystem(WeaponSystem* weaponsystem) 147 152 { this->weaponSystem_ = weaponsystem; } 153 154 Vector3 aimPosition_; 148 155 }; 149 156 }
Note: See TracChangeset
for help on using the changeset viewer.