Changeset 10049
- Timestamp:
- May 8, 2014, 4:04:53 PM (11 years ago)
- Location:
- code/branches/turretFS14
- Files:
-
- 3 added
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/turretFS14/data/levels/includes/weaponSettingsTurret.oxi
r9664 r10049 11 11 </links> 12 12 <Weapon> 13 < attached>14 <Model mesh="sphere.mesh" position=" 3,3,-2.2" scale=0.6 />15 </attached> 16 <HsW01 mode=0 munitionpershot=0 delay=0 damage= 3.14159 material="Flares/point_lensflare" muzzleoffset=" 3, 3,-2.2" />17 <HsW01 mode=0 munitionpershot=0 delay=0 damage= 3.14159 material="Flares/point_lensflare" muzzleoffset=" 3,-3,-2.2" />18 <HsW01 mode=0 munitionpershot=0 delay=0 damage= 3.14159 material="Flares/point_lensflare" muzzleoffset="-3, 3,-2.2" />19 <HsW01 mode=0 munitionpershot=0 delay=0 damage= 3.14159 material="Flares/point_lensflare" muzzleoffset="-3,-3,-2.2" />13 <!-- <attached> 14 <Model mesh="sphere.mesh" position="1.7,1.7,-24.5" scale=0.6 /> 15 </attached> --> 16 <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="1.7, 1.7,-30" /> 17 <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="1.7, -1.7,-30" /> 18 <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="-1.7, 1.7,-30" /> 19 <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="-1.7, -1.7,-30" /> 20 20 </Weapon> 21 21 </WeaponPack> -
code/branches/turretFS14/data/levels/turretTest.oxw
r10044 r10049 16 16 <?lua 17 17 include("templates/spaceshipAssff.oxt") 18 include("templates/spaceship Pirate.oxt")19 include("templates/s paceshipTurretTest.oxt")18 include("templates/spaceshipTransporter.oxt") 19 include("templates/standardTurret.oxt") 20 20 ?> 21 21 … … 33 33 <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /> 34 34 35 36 <!-- <SpaceShip position="-100,0,0" yaw=0 pitch=0> 37 <attached> 38 <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" /> 39 <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" /> 40 <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" /> 41 <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" /> 42 <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" /> 43 44 <Turret position="0,10,0" pitch="90" yaw="0" roll="0" maxPitch=90 maxYaw=90 attackRadius=2000> 45 <templates> 46 <Template link=spaceshipturrettest /> 47 </templates> 48 <controller> 49 <TurretController team=10 /> 50 </controller> 51 </Turret> 52 53 <Model mesh="sphere.mesh" position="20,0,0" scale=1/> 54 55 <Model mesh="sphere.mesh" position="0,25,0" scale=1/> 56 57 <Model mesh="sphere.mesh" position="0,0,30" scale=1/> 58 59 </attached> 60 </SpaceShip> --> 61 62 63 <StaticEntity position="100,0,0"> 35 <SpaceShip> 64 36 <attached> 65 <Model mesh="sphere.mesh" position="20,0,0" scale=1/> 66 67 <Model mesh="sphere.mesh" position="0,25,0" scale=1.5/> 68 69 <Model mesh="sphere.mesh" position="0,0,30" scale=2/> 37 <Turret position="10,2,0" pitch="90" yaw="0" roll="0" scale3D="0.2,0.2,0.2"> 38 <templates> 39 <Template link=standardturret /> 40 </templates> 41 </Turret> 42 <Turret position="-10,2,0" pitch="90" yaw="0" roll="0" scale3D="0.2,0.2,0.2"> 43 <templates> 44 <Template link=standardturret /> 45 </templates> 46 </Turret> 47 <Turret position="0,2,0" pitch="90" yaw="0" roll="0" scale3D="0.2,0.2,0.2"> 48 <templates> 49 <Template link=standardturret /> 50 </templates> 51 </Turret> 70 52 </attached> 71 72 </StaticEntity> 73 <SpaceShip position="100,0,0" yaw=0 pitch=90> 74 <attached> 75 <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" /> 76 <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" /> 77 <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" /> 78 <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" /> 79 <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" /> 80 81 <Turret position="0,10,0" pitch="90" yaw="0" roll="0" maxPitch=90 maxYaw=90 attackRadius=2000> 82 <templates> 83 <Template link=spaceshipturrettest /> 84 </templates> 85 <controller> 86 <TurretController team=10 /> 87 </controller> 88 </Turret> 89 90 91 92 </attached> 53 <templates> 54 <Template link=spaceshipassff /> 55 </templates> 56 <!-- <controller> 57 <AIController /> 58 </controller> --> 93 59 </SpaceShip> 94 60 -
code/branches/turretFS14/src/modules/objects/Turret.cc
r10044 r10049 38 38 39 39 /** 40 * @brief Constructor 40 @brief 41 Sets default values for all variables. Also hides the turret from the radar. 42 43 @param context 44 The context 41 45 */ 42 46 Turret::Turret(Context* context) : Pawn(context) … … 48 52 this->localY_ = Vector3::UNIT_Y; 49 53 this->localX_ = Vector3::UNIT_X; 50 this->attackRadius_ = 200; 54 this->maxAttackRadius_ = 200; 55 this->minAttackRadius_ = 0; 51 56 this->maxPitch_ = 90; 52 57 this->maxYaw_ = 90; … … 58 63 59 64 /** 60 * @brief Destructor 65 @brief 66 Destructor. Nothing to see here. 61 67 */ 62 68 Turret::~Turret() … … 65 71 } 66 72 67 73 /** 74 @brief 75 Checks, if a (world)position is inside the turret's range. 76 77 This function is safe to use on turrets that are attached, rotated, etc. 78 The turret's range is determined with the maxPitch, maxYaw, and the two attackRadius'. 79 80 @param position 81 The position to check 82 */ 68 83 bool Turret::isInRange(const Vector3 &position) 69 84 { 70 85 //Check distance 71 86 Vector3 distance = position - this->getWorldPosition(); 72 if(distance.squaredLength() > (this->attackRadius_ * this->attackRadius_)) 87 float distanceVal = distance.squaredLength(); 88 if(distanceVal > (this->maxAttackRadius_ * this->maxAttackRadius_) || distanceVal < (this->minAttackRadius_ * this->minAttackRadius_)) 73 89 { 74 90 return false; … … 100 116 } 101 117 118 /** 119 @brief 120 Rotates the turret to make it aim at a certain position. 121 122 @note 123 There are no checks, if the position is valid (i.e. if the turret is allowed to aim there). 124 This function must be called again for every tick, or the turret will stop rotating. 125 126 @param position 127 The position to aim at 128 */ 102 129 void Turret::aimAtPosition(const Vector3& position) 103 130 { … … 106 133 107 134 this->rotation_ = currDir.getRotationTo(targetDir); 108 109 } 110 135 } 136 137 /** 138 @brief 139 Does currently nothing. 140 141 Should rotate the turret with the specified pitch. Contains a failed attempt at limiting said rotation. 142 */ 111 143 void Turret::rotatePitch(const Vector2& value) 112 144 { … … 127 159 } 128 160 161 /** 162 @brief 163 Does currently nothing. 164 165 Should rotate the turret with the specified yaw. Contains a failed attempt at limiting said rotation. 166 */ 129 167 void Turret::rotateYaw(const Vector2& value) 130 168 { … … 145 183 } 146 184 185 /** 186 @brief 187 Does currently nothing. 188 189 May be used to limit turret's rotation in the future. 190 */ 147 191 void Turret::rotateRoll(const Vector2& value) 148 192 { 149 193 } 150 194 195 /** 196 @brief 197 Loads parameters from xml 198 199 Parameters loaded are: rotationThrust, maxAttackRadius, minAttackRadius, maxYaw, maxPitch 200 */ 151 201 void Turret::XMLPort(Element& xmlelement, XMLPort::Mode mode) 152 202 { … … 154 204 155 205 XMLPortParamVariable(Turret, "rotationThrust", rotationThrust_, xmlelement, mode); 156 XMLPortParam(Turret, "attackRadius", setAttackRadius, getAttackRadius, xmlelement, mode); 206 XMLPortParam(Turret, "maxAttackRadius", setMaxAttackRadius, getMaxAttackRadius, xmlelement, mode); 207 XMLPortParam(Turret, "minAttackRadius", setMinAttackRadius, getMinAttackRadius, xmlelement, mode); 157 208 XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode); 158 209 XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode); 159 210 } 160 211 212 /** 213 @brief 214 The turret's actions are done here. 215 216 Every tick, the turret gets rotated if it should, and the local axes get updated with the parent's rotation. 217 */ 161 218 void Turret::tick(float dt) 162 219 { … … 166 223 if(!this->once_) 167 224 { 168 225 //Account for rotations done in xml 169 226 Quaternion startOrient = this->getOrientation(); 170 227 this->localXStart_ = startOrient * this->localX_; … … 198 255 if(this->rotation_ != Quaternion::IDENTITY) 199 256 { 200 //Don't make the rotation instantaneous 201 Quaternion drot = Quaternion:: Slerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);257 //Don't make the rotation instantaneous. Use an arbitrary interpolation, not that great... 258 Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_); 202 259 this->rotate(drot, WorldEntity::World); 203 260 this->rotation_ = Quaternion::IDENTITY; -
code/branches/turretFS14/src/modules/objects/Turret.h
r10044 r10049 21 21 * 22 22 * Author: 23 * Marian Runo 23 * Marian Runo, Martin Mueller 24 24 * Co-authors: 25 25 * ... … … 28 28 29 29 /** 30 @file Turret.h31 30 @brief Definition of the Turret class. 32 31 @ingroup Objects … … 41 40 namespace orxonox 42 41 { 42 /** 43 @brief 44 Creates a turret with limited rotation. The point of this class is to be able to attach 45 a turret to a spaceship or a spacestation which is more or less completely autonomous in 46 it's behaviour. 47 48 @note 49 The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target. 50 */ 43 51 class _ObjectsExport Turret : public Pawn 44 52 { … … 56 64 virtual void tick(float dt); 57 65 58 inline void setAttackRadius(float radius) 59 { this->attackRadius_ = radius; } 66 /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/ 67 inline void setMaxAttackRadius(float radius) 68 { this->maxAttackRadius_ = radius; } 60 69 70 /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/ 71 inline void setMinAttackRadius(float radius) 72 { this->minAttackRadius_ = radius; } 73 74 /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/ 61 75 inline void setMaxPitch(float pitch) 62 76 { this->maxPitch_ = pitch; } 63 77 78 /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/ 64 79 inline void setMaxYaw(float yaw) 65 80 { this->maxYaw_ = yaw; } 66 81 67 inline float getAttackRadius() const 68 { return this->attackRadius_; } 82 /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */ 83 inline float getMaxAttackRadius() const 84 { return this->maxAttackRadius_; } 69 85 86 /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */ 87 inline float getMinAttackRadius() const 88 { return this->minAttackRadius_; } 89 90 /** @brief Returns the maximum pitch the turret can have. @return The pitch */ 70 91 inline float getMaxPitch() const 71 92 { return this->maxPitch_; } 72 93 94 /** @brief Returns the maximum yaw the turret can have. @return The yaw */ 73 95 inline float getMaxYaw() const 74 96 { return this->maxYaw_; } 75 97 76 98 protected: 77 Vector3 startDir_; 78 Vector3 localZ_; 79 Vector3 localZStart_; 80 Vector3 localY_; 81 Vector3 localYStart_; 82 Vector3 localX_; 83 Vector3 localXStart_; 99 Vector3 startDir_; //!< The initial facing direction, in local coordinates. 100 Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml. 101 Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml. 102 Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml. 103 Quaternion rotation_; //!< The rotation to be done by the turret. 84 104 85 105 private: 86 bool once_; 106 bool once_; //!< Flag for executing code in the tick function only once. 87 107 88 float attackRadius_; 89 Ogre::Real maxPitch_; 90 Ogre::Real maxYaw_; 91 float rotationThrust_; 108 Vector3 localZStart_; //!< The local z-axis, without the parent's rotation. 109 Vector3 localYStart_; //!< The local y-axis, without the parent's rotation. 110 Vector3 localXStart_; //!< The local x-axis, without the parent's rotation. 111 float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot. 112 float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot. 113 Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side). 114 Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side). 115 float rotationThrust_; //!< The velocity the turret rotates with. 92 116 93 Quaternion rotation_;94 117 }; 95 118 } -
code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt
r10008 r10049 1 1 ADD_SOURCE_FILES(OBJECTS_SRC_FILES 2 2 TurretController.cc 3 TeamTargetProxy.cc 3 4 ) -
code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc
r10044 r10049 136 136 { 137 137 this->getControllableEntity()->fire(0); 138 orxout() << 42 << endl;139 138 } 140 139 } -
code/branches/turretFS14/src/modules/objects/controllers/TurretController.h
r10044 r10049 27 27 */ 28 28 29 #ifndef _TurretController_H__ 30 #define _TurretController_H__ 29 /** 30 @brief Definition for the controller for turrets. 31 */ 32 33 #ifndef _TurretController_H__ 34 #define _TurretController_H__ 31 35 32 36 #include "OrxonoxPrereqs.h" … … 35 39 namespace orxonox 36 40 { 41 /** 42 @brief 43 Controller for turrets. Chooses a target, and makes the turret aim/shoot at it. 44 45 The controllableEntity gets casted to Turret, so this controller won't work for anything else. 46 */ 37 47 class _OrxonoxExport TurretController : public ArtificialController, public Tickable 38 48 {
Note: See TracChangeset
for help on using the changeset viewer.