Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 31, 2015, 6:03:17 PM (9 years ago)
Author:
landauf
Message:

merged branch presentationFS14 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/objects/Turret.h

    r9667 r10216  
    2121 *
    2222 *   Author:
    23  *      Marian Runo
     23 *      Marian Runo, Martin Mueller
    2424 *   Co-authors:
    2525 *      ...
     
    2828
    2929/**
    30     @file Turret.h
    3130    @brief Definition of the Turret class.
    3231    @ingroup Objects
     
    3736
    3837#include "objects/ObjectsPrereqs.h"
    39 
    40 #include "worldentities/pawns/SpaceShip.h"
     38#include "worldentities/pawns/Pawn.h"
     39#include <OgreSceneQuery.h>
    4140
    4241namespace orxonox
    4342{
    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
    4558    {
    4659        public:
     
    4861            virtual ~Turret();
    4962
    50             //virtual void tick(float dt);
    51 
    5263            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);
    5668
    5769            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     70            virtual void tick(float dt);
    5871
     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_; }
    59103
    60104        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
    62111        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
    63123
    64124    };
     
    66126
    67127#endif
    68 
Note: See TracChangeset for help on using the changeset viewer.