[Orxonox-commit 5386] r10049 - in code/branches/turretFS14: data/levels data/levels/includes data/levels/templates src/modules/objects src/modules/objects/controllers

muemart at orxonox.net muemart at orxonox.net
Thu May 8 16:04:54 CEST 2014


Author: muemart
Date: 2014-05-08 16:04:53 +0200 (Thu, 08 May 2014)
New Revision: 10049

Added:
   code/branches/turretFS14/data/levels/templates/standardTurret.oxt
   code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc
   code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h
Removed:
   code/branches/turretFS14/data/levels/includes/weaponSettingsTurretTest.oxi
   code/branches/turretFS14/data/levels/templates/spaceshipTurret.oxt
   code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt
Modified:
   code/branches/turretFS14/data/levels/includes/weaponSettingsTurret.oxi
   code/branches/turretFS14/data/levels/turretTest.oxw
   code/branches/turretFS14/src/modules/objects/Turret.cc
   code/branches/turretFS14/src/modules/objects/Turret.h
   code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt
   code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc
   code/branches/turretFS14/src/modules/objects/controllers/TurretController.h
Log:
Delete the old turret templates and make new ones. Adjust the weapon positions for the turret. Add a proxy controller for teams and targets. Add comments

Modified: code/branches/turretFS14/data/levels/includes/weaponSettingsTurret.oxi
===================================================================
--- code/branches/turretFS14/data/levels/includes/weaponSettingsTurret.oxi	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/data/levels/includes/weaponSettingsTurret.oxi	2014-05-08 14:04:53 UTC (rev 10049)
@@ -10,13 +10,13 @@
           <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
         </links>
         <Weapon>
-          <attached>
-            <Model mesh="sphere.mesh" position="3,3,-2.2" scale=0.6 />
-          </attached>
-          <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 3, 3,-2.2" />
-          <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 3,-3,-2.2" />
-          <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-3, 3,-2.2" />
-          <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-3,-3,-2.2" />
+          <!-- <attached>
+            <Model mesh="sphere.mesh" position="1.7,1.7,-24.5" scale=0.6 />
+          </attached> -->
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="1.7, 1.7,-30" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="1.7, -1.7,-30" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="-1.7, 1.7,-30" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="-1.7, -1.7,-30" />
         </Weapon>
       </WeaponPack>
     </weapons>

Deleted: code/branches/turretFS14/data/levels/includes/weaponSettingsTurretTest.oxi
===================================================================
--- code/branches/turretFS14/data/levels/includes/weaponSettingsTurretTest.oxi	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/data/levels/includes/weaponSettingsTurretTest.oxi	2014-05-08 14:04:53 UTC (rev 10049)
@@ -1,22 +0,0 @@
-    <weaponslots>
-      <WeaponSlot position="0,0,0" />
-    </weaponslots>
-    <weaponsets>
-      <WeaponSet firemode=0 />
-    </weaponsets>
-    <weapons>
-      <WeaponPack>
-        <links>
-          <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
-        </links>
-        <Weapon>
-          <attached>
-            <Model mesh="sphere.mesh" position="3,3,-2.2" scale=0.6 />
-          </attached>
-          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset=" 30, 3,-2.2" />
-          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset=" 30,-3,-2.2" />
-          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="-30, 3,-2.2" />
-          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="-30,-3,-2.2" />
-        </Weapon>
-      </WeaponPack>
-    </weapons>

Deleted: code/branches/turretFS14/data/levels/templates/spaceshipTurret.oxt
===================================================================
--- code/branches/turretFS14/data/levels/templates/spaceshipTurret.oxt	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/data/levels/templates/spaceshipTurret.oxt	2014-05-08 14:04:53 UTC (rev 10049)
@@ -1,60 +0,0 @@
-<Template name=spaceshipturret>
-  <SpaceShip
-   hudtemplate            = spaceshiphud
-   camerapositiontemplate = spaceshipturretcameras
-   spawnparticlesource    = "Orxonox/fairytwirl"
-   spawnparticleduration  = 3
-   explosionchunks        = 6
-
-   health            = 100
-   maxhealth         = 200
-   initialhealth     = 100
-
-   shieldhealth        = 30
-   initialshieldhealth = 30
-   maxshieldhealth     = 50
-   shieldabsorption    = 0.8
-   reloadrate          = 1
-   reloadwaittime      = 1
-
-   primaryThrust     = 100
-   auxilaryThrust    = 30
-   rotationThrust    = 50
-
-   lift = 1;
-   stallSpeed = 220;
-
-   boostPower            = 15
-   boostPowerRate        = 1
-   boostRate             = 5
-   boostCooldownDuration = 10
-
-   shakeFrequency = 15
-   shakeAmplitude = 9
-
-   collisionType     = "dynamic"
-   mass              = 100
-   linearDamping     = 0.7
-   angularDamping    = 0.9999999
-  >
-    <attached>
-        <Model position="0,0,0" yaw="90" roll="-90" mesh="turretHead.mesh" scale3D="10,10,10"/>
-    </attached>
-    <collisionShapes>
-        <SphereCollisionShape radius="10"   position = "0,0,0"/>
-    </collisionShapes>
-<?lua
-  include("../includes/weaponSettingsTurret.oxi")
-?>
-  </SpaceShip>
-</Template>
-
-<Template name=spaceshipturretcameras defaults=0>
-  <SpaceShip>
-    <camerapositions>
-      <CameraPosition position="0,10, 40" drag=true mouselook=true />
-      <CameraPosition position="0,20, 80" drag=true mouselook=true />
-      <CameraPosition position="0,30,120" drag=true mouselook=true />
-    </camerapositions>
-  </SpaceShip>
-</Template>

Deleted: code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt
===================================================================
--- code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt	2014-05-08 14:04:53 UTC (rev 10049)
@@ -1,23 +0,0 @@
-<Template name=spaceshipturrettest>
-  <Turret position="0,0,0" collisionType="dynamic" angularDamping=0.999999 mass=100>
-    <attached>
-        <Model position="0,0,0" pitch="-90" roll="0" mesh="turretHead.mesh" scale3D="10,10,10"/>
-    </attached>
-    <collisionShapes>
-        <SphereCollisionShape radius="10"   position = "0,0,0"/>
-    </collisionShapes>
-<?lua
-  include("../includes/weaponSettingsTurretTest.oxi")
-?>
-  </Turret>
-</Template>
-
-<Template name=spaceshipturretcameras defaults=0>
-  <SpaceShip>
-    <camerapositions>
-      <CameraPosition position="0,10, 40" drag=true mouselook=true />
-      <CameraPosition position="0,20, 80" drag=true mouselook=true />
-      <CameraPosition position="0,30,120" drag=true mouselook=true />
-    </camerapositions>
-  </SpaceShip>
-</Template>
\ No newline at end of file

Added: code/branches/turretFS14/data/levels/templates/standardTurret.oxt
===================================================================
--- code/branches/turretFS14/data/levels/templates/standardTurret.oxt	                        (rev 0)
+++ code/branches/turretFS14/data/levels/templates/standardTurret.oxt	2014-05-08 14:04:53 UTC (rev 10049)
@@ -0,0 +1,40 @@
+<Template name=standardturret>
+  <Turret collisionType="dynamic">
+    <attached>
+      <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" pitch=-90/>
+      <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" pitch=-90/>
+      <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" pitch=-90/>
+      <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" pitch=-90/>
+      <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" pitch=-90/>
+
+      <Turret position="0,0,-10" collisionType="dynamic" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=2000 minAttackRadius=30>
+        <attached>
+          <Model position="0,0,0" pitch="-90" roll="0" mesh="turretHead.mesh" scale3D="10,10,10"/>
+        </attached>
+        <collisionShapes>
+          <SphereCollisionShape radius="10"   position = "0,0,0"/>
+        </collisionShapes>
+        <controller>
+          <TurretController/>
+        </controller>
+        <?lua
+          include("../includes/weaponSettingsTurret.oxi")
+        ?>
+      </Turret>
+    </attached>
+    
+    <controller>
+      <TeamTargetProxy/>
+    </controller>
+  </Turret>
+</Template>
+
+<Template name=spaceshipturretcameras defaults=0>
+  <SpaceShip>
+    <camerapositions>
+      <CameraPosition position="0,10, 40" drag=true mouselook=true />
+      <CameraPosition position="0,20, 80" drag=true mouselook=true />
+      <CameraPosition position="0,30,120" drag=true mouselook=true />
+    </camerapositions>
+  </SpaceShip>
+</Template>
\ No newline at end of file

Modified: code/branches/turretFS14/data/levels/turretTest.oxw
===================================================================
--- code/branches/turretFS14/data/levels/turretTest.oxw	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/data/levels/turretTest.oxw	2014-05-08 14:04:53 UTC (rev 10049)
@@ -15,8 +15,8 @@
 
 <?lua
   include("templates/spaceshipAssff.oxt")
-  include("templates/spaceshipPirate.oxt")
-  include("templates/spaceshipTurretTest.oxt")
+  include("templates/spaceshipTransporter.oxt")
+  include("templates/standardTurret.oxt")
 ?>
 
 <Level>
@@ -32,64 +32,30 @@
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
     <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
 
-
-<!-- <SpaceShip position="-100,0,0" yaw=0 pitch=0>
-    <attached>
-        <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" />
-        <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" />
-        <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" />
-        <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" />
-        <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" />
-
-        <Turret position="0,10,0" pitch="90" yaw="0" roll="0" maxPitch=90 maxYaw=90 attackRadius=2000>
-            <templates>
-              <Template link=spaceshipturrettest />
-            </templates>
-            <controller>
-              <TurretController team=10 />
-            </controller>
-        </Turret>
-
-        <Model mesh="sphere.mesh" position="20,0,0" scale=1/>
-
-        <Model mesh="sphere.mesh" position="0,25,0" scale=1/>
-
-        <Model mesh="sphere.mesh" position="0,0,30" scale=1/>
-
-    </attached>
-</SpaceShip> -->
-
-
-<StaticEntity position="100,0,0">
+<SpaceShip>
   <attached>
-    <Model mesh="sphere.mesh" position="20,0,0" scale=1/>
-
-    <Model mesh="sphere.mesh" position="0,25,0" scale=1.5/>
-
-    <Model mesh="sphere.mesh" position="0,0,30" scale=2/>
+    <Turret position="10,2,0" pitch="90" yaw="0" roll="0" scale3D="0.2,0.2,0.2">
+      <templates>
+        <Template link=standardturret />
+      </templates>
+    </Turret>    
+    <Turret position="-10,2,0" pitch="90" yaw="0" roll="0" scale3D="0.2,0.2,0.2">
+      <templates>
+        <Template link=standardturret />
+      </templates>
+    </Turret>    
+    <Turret position="0,2,0" pitch="90" yaw="0" roll="0" scale3D="0.2,0.2,0.2">
+      <templates>
+        <Template link=standardturret />
+      </templates>
+    </Turret>    
   </attached>
-  
-</StaticEntity>
-<SpaceShip position="100,0,0" yaw=0 pitch=90>
-    <attached>
-        <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" />
-        <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" />
-        <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" />
-        <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" />
-        <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" />
-
-        <Turret position="0,10,0" pitch="90" yaw="0" roll="0" maxPitch=90 maxYaw=90 attackRadius=2000>
-            <templates>
-              <Template link=spaceshipturrettest />
-            </templates>
-            <controller>
-              <TurretController team=10 />
-            </controller>
-        </Turret>
-
-
-
-    </attached>
+  <templates>
+    <Template link=spaceshipassff />
+  </templates>
+<!--   <controller>
+    <AIController />
+  </controller> -->
 </SpaceShip>
 
 

Modified: code/branches/turretFS14/src/modules/objects/Turret.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/Turret.cc	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/src/modules/objects/Turret.cc	2014-05-08 14:04:53 UTC (rev 10049)
@@ -37,7 +37,11 @@
 
 
     /**
-     * @brief Constructor
+        @brief 
+        Sets default values for all variables. Also hides the turret from the radar.
+
+        @param context
+        The context
      */
     Turret::Turret(Context* context) : Pawn(context)
     {
@@ -47,7 +51,8 @@
         this->localZ_ = Vector3::UNIT_Z;
         this->localY_ = Vector3::UNIT_Y;
         this->localX_ = Vector3::UNIT_X;
-        this->attackRadius_ = 200;
+        this->maxAttackRadius_ = 200;
+        this->minAttackRadius_ = 0;
         this->maxPitch_ = 90;
         this->maxYaw_ = 90;
         this->once_ = false;
@@ -57,19 +62,30 @@
     }
 
     /**
-     * @brief Destructor
+        @brief 
+        Destructor. Nothing to see here.
      */
     Turret::~Turret()
     {
 
     }
 
+    /**
+        @brief
+        Checks, if a (world)position is inside the turret's range.
 
+        This function is safe to use on turrets that are attached, rotated, etc.
+        The turret's range is determined with the maxPitch, maxYaw, and the two attackRadius'.
+
+        @param position
+        The position to check
+    */
     bool Turret::isInRange(const Vector3 &position)
     {
         //Check distance
         Vector3 distance = position - this->getWorldPosition();
-        if(distance.squaredLength() > (this->attackRadius_ * this->attackRadius_))
+        float distanceVal = distance.squaredLength();
+        if(distanceVal > (this->maxAttackRadius_ * this->maxAttackRadius_) || distanceVal < (this->minAttackRadius_ * this->minAttackRadius_))
         {
             return false;
         }
@@ -99,15 +115,31 @@
         return true;
     }
 
+    /**
+        @brief
+        Rotates the turret to make it aim at a certain position.
+
+        @note
+        There are no checks, if the position is valid (i.e. if the turret is allowed to aim there).
+        This function must be called again for every tick, or the turret will stop rotating.
+
+        @param position
+        The position to aim at
+    */
     void Turret::aimAtPosition(const Vector3& position)
     {
         Vector3 currDir = this->getWorldOrientation() * WorldEntity::FRONT;
         Vector3 targetDir = position - this->getWorldPosition();
 
         this->rotation_ = currDir.getRotationTo(targetDir);
-
     }
 
+    /**
+        @brief
+        Does currently nothing.
+
+        Should rotate the turret with the specified pitch. Contains a failed attempt at limiting said rotation.
+    */
     void Turret::rotatePitch(const Vector2& value)
     {    
         //This is a failed attempt at limiting the turret's rotation. It's handled in the controller (for now?)
@@ -126,6 +158,12 @@
         */
     }
 
+    /**
+        @brief
+        Does currently nothing.
+
+        Should rotate the turret with the specified yaw. Contains a failed attempt at limiting said rotation.
+    */
     void Turret::rotateYaw(const Vector2& value)
     {
         //This is a failed attempt at limiting the turret's rotation. It's handled in the controller (for now?)
@@ -144,20 +182,39 @@
         */
     }
 
+    /**
+        @brief
+        Does currently nothing.
+
+        May be used to limit turret's rotation in the future.
+    */
     void Turret::rotateRoll(const Vector2& value)
     {
     }
 
+    /**
+        @brief
+        Loads parameters from xml
+
+        Parameters loaded are: rotationThrust, maxAttackRadius, minAttackRadius, maxYaw, maxPitch
+    */
     void Turret::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(Turret, XMLPort, xmlelement, mode);
         
         XMLPortParamVariable(Turret, "rotationThrust", rotationThrust_, xmlelement, mode);
-        XMLPortParam(Turret, "attackRadius", setAttackRadius, getAttackRadius, xmlelement, mode);
+        XMLPortParam(Turret, "maxAttackRadius", setMaxAttackRadius, getMaxAttackRadius, xmlelement, mode);
+        XMLPortParam(Turret, "minAttackRadius", setMinAttackRadius, getMinAttackRadius, xmlelement, mode);
         XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode);
         XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode);
     }
 
+    /**
+        @brief
+        The turret's actions are done here.
+
+        Every tick, the turret gets rotated if it should, and the local axes get updated with the parent's rotation.
+    */
     void Turret::tick(float dt)
     {
         SUPER(Turret, tick, dt);
@@ -165,7 +222,7 @@
 
         if(!this->once_)
         {
-
+            //Account for rotations done in xml
             Quaternion startOrient = this->getOrientation();
             this->localXStart_ = startOrient * this->localX_;
             this->localXStart_.normalise();
@@ -197,8 +254,8 @@
         //rotate
         if(this->rotation_ != Quaternion::IDENTITY)
         {
-            //Don't make the rotation instantaneous
-            Quaternion drot = Quaternion::Slerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
+            //Don't make the rotation instantaneous. Use an arbitrary interpolation, not that great...
+            Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
             this->rotate(drot, WorldEntity::World);
             this->rotation_ = Quaternion::IDENTITY;
         }

Modified: code/branches/turretFS14/src/modules/objects/Turret.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/Turret.h	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/src/modules/objects/Turret.h	2014-05-08 14:04:53 UTC (rev 10049)
@@ -20,14 +20,13 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Marian Runo
+ *      Marian Runo, Martin Mueller
  *   Co-authors:
  *      ...
  *
  */
 
 /**
-    @file Turret.h
     @brief Definition of the Turret class.
     @ingroup Objects
 */
@@ -40,6 +39,15 @@
 
 namespace orxonox
 {
+    /**
+    @brief
+        Creates a turret with limited rotation. The point of this class is to be able to attach
+        a turret to a spaceship or a spacestation which is more or less completely autonomous in
+        it's behaviour.
+
+    @note
+        The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target.
+    */
     class _ObjectsExport Turret : public Pawn
     {
         public:
@@ -55,42 +63,57 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void tick(float dt);
 
-            inline void setAttackRadius(float radius)
-                { this->attackRadius_ = radius; }
+            /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/
+            inline void setMaxAttackRadius(float radius)
+                { this->maxAttackRadius_ = radius; }
 
+            /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/
+            inline void setMinAttackRadius(float radius)
+                { this->minAttackRadius_ = radius; }
+
+            /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/
             inline void setMaxPitch(float pitch)
                 { this->maxPitch_ = pitch; }
 
+            /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/
             inline void setMaxYaw(float yaw)
                 { this->maxYaw_ = yaw; }
 
-            inline float getAttackRadius() const
-                { return this->attackRadius_; }                
+            /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */
+            inline float getMaxAttackRadius() const
+                { return this->maxAttackRadius_; }                
 
+            /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */
+            inline float getMinAttackRadius() const
+                { return this->minAttackRadius_; }   
+
+            /** @brief Returns the maximum pitch the turret can have. @return The pitch */
             inline float getMaxPitch() const
                 { return this->maxPitch_; }
 
+            /** @brief Returns the maximum yaw the turret can have. @return The yaw */
             inline float getMaxYaw() const
                 { return this->maxYaw_; }
 
         protected:
-            Vector3 startDir_;
-            Vector3 localZ_;
-            Vector3 localZStart_;
-            Vector3 localY_;
-            Vector3 localYStart_;
-            Vector3 localX_;
-            Vector3 localXStart_;           
+            Vector3 startDir_; //!< The initial facing direction, in local coordinates.
+            Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml.
+            Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml.
+            Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml.      
+            Quaternion rotation_; //!< The rotation to be done by the turret.
 
         private:
-            bool once_;
+            bool once_; //!< Flag for executing code in the tick function only once.
 
-            float attackRadius_;
-            Ogre::Real maxPitch_;
-            Ogre::Real maxYaw_;
-            float rotationThrust_;
+            Vector3 localZStart_; //!< The local z-axis, without the parent's rotation.
+            Vector3 localYStart_; //!< The local y-axis, without the parent's rotation.
+            Vector3 localXStart_; //!< The local x-axis, without the parent's rotation.
+            float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot.
+            float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot.
+            Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side).
+            Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side).
+            float rotationThrust_;  //!< The velocity the turret rotates with.
 
-            Quaternion rotation_;
     };
 }
 

Modified: code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt	2014-05-08 14:04:53 UTC (rev 10049)
@@ -1,3 +1,4 @@
 ADD_SOURCE_FILES(OBJECTS_SRC_FILES
   TurretController.cc
+  TeamTargetProxy.cc
 )

Added: code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc	                        (rev 0)
+++ code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc	2014-05-08 14:04:53 UTC (rev 10049)
@@ -0,0 +1,87 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Mueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "TeamTargetProxy.h"
+#include "worldentities/pawns/Pawn.h"
+
+ namespace orxonox
+ {
+ 	RegisterClass(TeamTargetProxy);
+
+ 	TeamTargetProxy::TeamTargetProxy(Context* context) : FormationController(context)
+ 	{
+ 		RegisterObject(TeamTargetProxy);
+
+ 		this->once_ = false;
+ 	}
+
+ 	TeamTargetProxy::~TeamTargetProxy()
+ 	{
+ 	}
+
+ 	void TeamTargetProxy::tick(float dt)
+ 	{
+	    if (!this->isActive() || !this->getControllableEntity())
+	        return;
+
+        ControllableEntity* parent = orxonox_cast<ControllableEntity*> (this->getControllableEntity()->getParent());
+ 		
+
+
+        if(parent)
+        {
+
+            if(!this->once_)
+            {
+                //Set the same team
+                if(parent)
+                {
+                    Controller* parentcontroller = parent->getController();
+                    if(parentcontroller)
+                    {
+                        this->setTeam(parentcontroller->getTeam());
+                    }
+                    else
+                    {
+                        this->setTeam(parent->getTeam());
+                    }
+                    this->getControllableEntity()->setTeam(parent->getTeam());
+                }
+                this->once_ = true;
+            }
+
+            Pawn* parenttarget = orxonox_cast<Pawn*>(parent->getTarget());
+            if(parenttarget)
+            {
+                this->setTarget(parenttarget);
+                this->getControllableEntity()->setTarget(parenttarget);
+            }
+        }
+
+ 	}
+ }
\ No newline at end of file

Added: code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h	                        (rev 0)
+++ code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h	2014-05-08 14:04:53 UTC (rev 10049)
@@ -0,0 +1,50 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Mueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TeamTargetProxy_H__
+#define _TeamTargetProxy_H__
+
+#include "OrxonoxPrereqs.h"
+#include "controllers/FormationController.h"
+
+ namespace orxonox
+ {
+ 	class _OrxonoxExport TeamTargetProxy : public FormationController, public Tickable
+ 	{
+ 		public:
+ 			TeamTargetProxy(Context* context);
+ 			virtual ~TeamTargetProxy();
+
+ 			virtual void tick(float dt);
+
+ 		private:
+ 			bool once_;
+ 	};
+ }
+
+ #endif
\ No newline at end of file

Modified: code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc	2014-05-08 14:04:53 UTC (rev 10049)
@@ -135,7 +135,6 @@
  			if(this->isLookingAtTargetNew(Degree(5).valueRadians()))
  			{
  				this->getControllableEntity()->fire(0);
- 				orxout() << 42 << endl;
  			}
  		}
  	}

Modified: code/branches/turretFS14/src/modules/objects/controllers/TurretController.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TurretController.h	2014-05-08 13:59:26 UTC (rev 10048)
+++ code/branches/turretFS14/src/modules/objects/controllers/TurretController.h	2014-05-08 14:04:53 UTC (rev 10049)
@@ -26,14 +26,24 @@
  *
  */
 
- #ifndef _TurretController_H__
- #define _TurretController_H__
+/**
+    @brief Definition for the controller for turrets.
+*/
 
+#ifndef _TurretController_H__
+#define _TurretController_H__
+
 #include "OrxonoxPrereqs.h"
 #include "controllers/ArtificialController.h"
 
  namespace orxonox
  {
+ 	/**
+ 		@brief
+ 		Controller for turrets. Chooses a target, and makes the turret aim/shoot at it.
+
+ 		The controllableEntity gets casted to Turret, so this controller won't work for anything else.
+ 	*/
  	class _OrxonoxExport TurretController : public ArtificialController, public Tickable
  	{
  		public:




More information about the Orxonox-commit mailing list