Changeset 10216 for code/trunk/src/modules/objects/Turret.h
- Timestamp:
- Jan 31, 2015, 6:03:17 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/objects/Turret.h
r9667 r10216 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 … … 37 36 38 37 #include "objects/ObjectsPrereqs.h" 39 40 #include "worldentities/pawns/SpaceShip.h"38 #include "worldentities/pawns/Pawn.h" 39 #include <OgreSceneQuery.h> 41 40 42 41 namespace orxonox 43 42 { 44 class _ObjectsExport Turret : public SpaceShip 43 /** 44 @brief 45 Creates a turret with limited rotation. The point of this class is to be able to attach 46 a turret to a spaceship or a spacestation which is more or less completely autonomous in 47 it's behaviour. 48 49 This class also contains a custom local coordinate system, which gets initially rotated through xml, and 50 afterwards is updated with the parent's rotation (if there is one). This allows for almost trivialal calculation 51 of pitch, yaw and roll through coordinate transformation. (TODO: Ogre should do something like this already, investigate...) 52 53 54 @note 55 The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target. 56 */ 57 class _ObjectsExport Turret : public Pawn 45 58 { 46 59 public: … … 48 61 virtual ~Turret(); 49 62 50 //virtual void tick(float dt);51 52 63 virtual void rotatePitch(const Vector2& value); 53 54 void setAlertnessRadius(float value); 55 float getAlertnessRadius(); 64 virtual void rotateYaw(const Vector2& value); 65 virtual void rotateRoll(const Vector2& value); 66 virtual float isInRange(const WorldEntity* target); 67 virtual void aimAtPosition(const Vector3 &position); 56 68 57 69 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 70 virtual void tick(float dt); 58 71 72 /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/ 73 inline void setMaxAttackRadius(float radius) 74 { this->maxAttackRadius_ = radius; } 75 76 /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/ 77 inline void setMinAttackRadius(float radius) 78 { this->minAttackRadius_ = radius; } 79 80 /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/ 81 inline void setMaxPitch(float pitch) 82 { this->maxPitch_ = pitch; } 83 84 /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/ 85 inline void setMaxYaw(float yaw) 86 { this->maxYaw_ = yaw; } 87 88 /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */ 89 inline float getMaxAttackRadius() const 90 { return this->maxAttackRadius_; } 91 92 /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */ 93 inline float getMinAttackRadius() const 94 { return this->minAttackRadius_; } 95 96 /** @brief Returns the maximum pitch the turret can have. @return The pitch */ 97 inline float getMaxPitch() const 98 { return this->maxPitch_; } 99 100 /** @brief Returns the maximum yaw the turret can have. @return The yaw */ 101 inline float getMaxYaw() const 102 { return this->maxYaw_; } 59 103 60 104 protected: 61 WaypointPatrolController* controller_; 105 Vector3 startDir_; //!< The initial facing direction, in local coordinates. 106 Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml. 107 Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml. 108 Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml. 109 Quaternion rotation_; //!< The rotation to be done by the turret. 110 62 111 private: 112 bool once_; //!< Flag for executing code in the tick function only once. 113 114 Vector3 localZStart_; //!< The local z-axis, without the parent's rotation. 115 Vector3 localYStart_; //!< The local y-axis, without the parent's rotation. 116 Vector3 localXStart_; //!< The local x-axis, without the parent's rotation. 117 float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot. 118 float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot. 119 Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side). 120 Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side). 121 float rotationThrust_; //!< The velocity the turret rotates with. 122 Ogre::RaySceneQuery* rayTest_; //!< Used to perform a raytest, currently unused @see isInRange 63 123 64 124 }; … … 66 126 67 127 #endif 68
Note: See TracChangeset
for help on using the changeset viewer.