[Orxonox-commit 5341] r10004 - in code/branches/turretFS14: data/levels data/levels/includes data/levels/templates src/modules/objects

muemart at orxonox.net muemart at orxonox.net
Thu Mar 27 13:36:50 CET 2014


Author: muemart
Date: 2014-03-27 13:36:50 +0100 (Thu, 27 Mar 2014)
New Revision: 10004

Added:
   code/branches/turretFS14/data/levels/includes/weaponSettingsTurretTest.oxi
   code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt
Modified:
   code/branches/turretFS14/data/levels/turretTest.oxw
   code/branches/turretFS14/src/modules/objects/Turret.cc
   code/branches/turretFS14/src/modules/objects/Turret.h
Log:
first experiments with the turret

Added: code/branches/turretFS14/data/levels/includes/weaponSettingsTurretTest.oxi
===================================================================
--- code/branches/turretFS14/data/levels/includes/weaponSettingsTurretTest.oxi	                        (rev 0)
+++ code/branches/turretFS14/data/levels/includes/weaponSettingsTurretTest.oxi	2014-03-27 12:36:50 UTC (rev 10004)
@@ -0,0 +1,22 @@
+    <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=" 3, 3,-2.2" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset=" 3,-3,-2.2" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="-3, 3,-2.2" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=0 material="Flares/point_lensflare" muzzleoffset="-3,-3,-2.2" />
+        </Weapon>
+      </WeaponPack>
+    </weapons>

Added: code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt
===================================================================
--- code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt	                        (rev 0)
+++ code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt	2014-03-27 12:36:50 UTC (rev 10004)
@@ -0,0 +1,60 @@
+<Template name=spaceshipturrettest>
+  <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/weaponSettingsTurretTest.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>

Modified: code/branches/turretFS14/data/levels/turretTest.oxw
===================================================================
--- code/branches/turretFS14/data/levels/turretTest.oxw	2014-03-20 14:46:06 UTC (rev 10003)
+++ code/branches/turretFS14/data/levels/turretTest.oxw	2014-03-27 12:36:50 UTC (rev 10004)
@@ -16,7 +16,7 @@
 <?lua
   include("templates/spaceshipAssff.oxt")
   include("templates/spaceshipPirate.oxt")
-  include("templates/spaceshipTurret.oxt")
+  include("templates/spaceshipTurretTest.oxt")
 ?>
 
 <Level>
@@ -47,7 +47,7 @@
 
 <Turret position="0,10,0" pitch="90" yaw="0" roll="0">
     <templates>
-        <Template link=spaceshipturret />
+        <Template link=spaceshipturrettest />
     </templates>
     <controller>
         <WaypointPatrolController alertnessradius=100 team=10>

Modified: code/branches/turretFS14/src/modules/objects/Turret.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/Turret.cc	2014-03-20 14:46:06 UTC (rev 10003)
+++ code/branches/turretFS14/src/modules/objects/Turret.cc	2014-03-27 12:36:50 UTC (rev 10004)
@@ -36,6 +36,8 @@
 {
     RegisterClass(Turret);
 
+
+
     /**
      * @brief Constructor
      */
@@ -43,6 +45,7 @@
     {
         RegisterObject(Turret);
         this->controller_ = new WaypointPatrolController(this->getContext());
+        gotOrient_ = false;
     }
 
     /**
@@ -56,15 +59,65 @@
 
     void Turret::rotatePitch(const Vector2& value)
     {
-        orxout()<< "Turret rotate Pitch"<< endl;
+        Radian currentPitch = this->getOrientation().getPitch();
+        Radian startPitch = startOrient_.getPitch();
+        Radian limit = Radian((Degree)45);
+        Radian upperBoundary = startPitch+limit;
+        if(upperBoundary > Radian(Degree(360)))
+        {
+            upperBoundary -= Radian(Degree(360));
+        }
+        Radian lowerBoundary = startPitch-limit;
+        if(lowerBoundary < Radian(Degree(0)))
+        {
+            lowerBoundary += Radian(Degree(360));
+        }
+        //orxout() << "Pitch:\t" << currentPitch << "\t" << startPitch << endl;
+        
+        if(currentPitch > upperBoundary && value.x > 0 ||
+           currentPitch < lowerBoundary && value.x < 0)
+        {
+            return;
+        }
+        
+        //SpaceShip::rotatePitch(value);
+    }
 
-        const Quaternion& orient = this->getOrientation();
-        Radian pitch = orient.getPitch();
+    void Turret::rotateYaw(const Vector2& value)
+    {
 
-        if((value.x > 0 && pitch < Radian(180)) || (value.x < 0 && pitch > Radian(0)))
-            SpaceShip::rotatePitch(value);
+        Radian currentYaw = this->getOrientation().getYaw();
+        Radian startYaw = startOrient_.getYaw();
+        Radian limit = Radian(Degree(45));
+        Radian upperBoundary = startYaw + limit;
+        Radian lowerBoundary = startYaw - limit;
+        orxout() << currentYaw << " " << this->getOrientation().getRoll() << endl;
+        /*if(upperBoundary >= Radian(Degree(180)));
+        {
+            upperBoundary -= Radian(Degree(180));
+            lowerBoundary -= Radian(Degree(180));
+            currentYaw -= Radian(Degree(180));
+        }
+        if(lowerBoundary <= Radian(Degree(-180)))
+        {
+            lowerBoundary += Radian(Degree(180));
+            upperBoundary += Radian(Degree(180));
+            currentYaw += Radian(Degree(180));
+        }*/
+        //orxout() << "Yaw:\t" << (Degree)currentYaw << "\t" << (Degree)upperBoundary << "\t" << (Degree)lowerBoundary << endl;
+        //if((currentYaw > upperBoundary && value.x > 0) ||
+        //   (currentYaw < lowerBoundary && value.x < 0))
+        if((currentYaw < Radian(1) && value.x < 0) || (currentYaw > Radian(3) && value.x>0))
+        {
+            //return;
+        }
+        SpaceShip::rotateYaw(value);
     }
 
+    void Turret::rotateRoll(const Vector2& value)
+    {
+        return;
+    }
 
     void Turret::setAlertnessRadius(float value)
     {
@@ -81,5 +134,14 @@
         XMLPortParam(Turret, "alertnessRadius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues("400");
     }
 
+    void Turret::tick(float dt)
+    {
+        if(!gotOrient_)
+        {
+            startOrient_ = this->getOrientation();
+            gotOrient_ = true;
+        }
+        SUPER(Turret, tick, dt);
+    }
 
 }

Modified: code/branches/turretFS14/src/modules/objects/Turret.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/Turret.h	2014-03-20 14:46:06 UTC (rev 10003)
+++ code/branches/turretFS14/src/modules/objects/Turret.h	2014-03-27 12:36:50 UTC (rev 10004)
@@ -36,6 +36,7 @@
 #define _Turret_H__
 
 #include "objects/ObjectsPrereqs.h"
+#include "OgreQuaternion.h"
 
 #include "worldentities/pawns/SpaceShip.h"
 
@@ -47,20 +48,23 @@
             Turret(Context* context);
             virtual ~Turret();
 
-            //virtual void tick(float dt);
-
             virtual void rotatePitch(const Vector2& value);
+            virtual void rotateYaw(const Vector2& value);
+            virtual void rotateRoll(const Vector2& value);
 
             void setAlertnessRadius(float value);
             float getAlertnessRadius();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
 
 
         protected:
             WaypointPatrolController* controller_;
         private:
-
+            bool gotOrient_;
+            Quaternion startOrient_;
+            Quaternion firstOrient_;
     };
 }
 




More information about the Orxonox-commit mailing list