Changeset 6055 for code/branches/steering/src/orxonox/weaponsystem
- Timestamp:
- Nov 13, 2009, 11:21:40 AM (15 years ago)
- Location:
- code/branches/steering/src/orxonox/weaponsystem
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/steering/src/orxonox/weaponsystem/WeaponMode.cc
r5929 r6055 32 32 #include "core/CoreIncludes.h" 33 33 #include "core/XMLPort.h" 34 #include "controllers/Controller.h" 35 #include "worldentities/pawns/Pawn.h" 34 36 35 37 #include "Munition.h" … … 194 196 } 195 197 196 Vector3 WeaponMode::getMuzzlePosition() const198 void WeaponMode::computeMuzzleParameters() 197 199 { 198 200 if (this->weapon_) 199 return (this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_); 200 else 201 return this->muzzleOffset_; 202 } 203 204 const Quaternion& WeaponMode::getMuzzleOrientation() const 201 { 202 this->muzzlePosition_ = this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_; 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() * (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection); 209 } 210 else 211 this->muzzleOrientation_ = this->weapon_->getWorldOrientation(); 212 } 213 else 214 { 215 this->muzzlePosition_ = this->muzzleOffset_; 216 this->muzzleOrientation_ = Quaternion::IDENTITY; 217 } 218 } 219 220 Vector3 WeaponMode::getMuzzleDirection() const 205 221 { 206 222 if (this->weapon_) 207 return this->weapon_->getWorldOrientation(); 208 else 209 return Quaternion::IDENTITY; 210 } 211 212 Vector3 WeaponMode::getMuzzleDirection() const 213 { 214 if (this->weapon_) 215 return (this->weapon_->getWorldOrientation() * WorldEntity::FRONT); 223 return (this->getMuzzleOrientation() * WorldEntity::FRONT); 216 224 else 217 225 return WorldEntity::FRONT; -
code/branches/steering/src/orxonox/weaponsystem/WeaponMode.h
r6045 r6055 38 38 #include "core/SubclassIdentifier.h" 39 39 #include "tools/Timer.h" 40 41 #include "weaponsystem/Weapon.h"42 #include "weaponsystem/WeaponPack.h"43 #include "weaponsystem/WeaponSystem.h"44 #include "worldentities/pawns/Pawn.h"45 #include "controllers/Controller.h"46 40 47 41 namespace orxonox … … 115 109 { return this->muzzleOffset_; } 116 110 117 Vector3 getMuzzlePosition() const; 118 const Quaternion& getMuzzleOrientation() const; 111 void computeMuzzleParameters(); 112 const Vector3& getMuzzlePosition() const 113 { return this->muzzlePosition_; } 114 const Quaternion& getMuzzleOrientation() const 115 { return this->muzzleOrientation_; } 119 116 Vector3 getMuzzleDirection() const; 120 117 … … 131 128 { return this->mode_; } 132 129 133 inline Vector3 getTarget() 134 { return this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getController()->getTarget(); } 130 Vector3 getTarget(); 135 131 136 132 protected: … … 161 157 Timer reloadTimer_; 162 158 bool bReloading_; 159 160 Vector3 muzzlePosition_; 161 Quaternion muzzleOrientation_; 163 162 }; 164 163 }
Note: See TracChangeset
for help on using the changeset viewer.