[Orxonox-commit 471] r3046 - branches/pickups2/src/orxonox/objects/pickup

bknecht at orxonox.net bknecht at orxonox.net
Sun May 24 23:53:09 CEST 2009


Author: bknecht
Date: 2009-05-24 23:53:09 +0200 (Sun, 24 May 2009)
New Revision: 3046

Modified:
   branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.cc
   branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.h
Log:
introducing the bouncing pickup

Modified: branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.cc	2009-05-24 21:27:14 UTC (rev 3045)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.cc	2009-05-24 21:53:09 UTC (rev 3046)
@@ -43,6 +43,10 @@
 
 namespace orxonox
 {
+    const float PickupSpawner::bounceSpeed_s = 6.0f;
+    const float PickupSpawner::rotationSpeed_s = 1.0f;
+    const float PickupSpawner::bounceDistance_s = 4.0f;
+
     CreateFactory(PickupSpawner);
 
     /**
@@ -56,6 +60,7 @@
         this->itemTemplate_ = 0;
         this->triggerDistance_ = 20;
         this->respawnTime_ = 0.0f;
+        this->tickSum_ = 0.0f;
     }
     //! Deconstructor.
     PickupSpawner::~PickupSpawner()
@@ -107,6 +112,11 @@
                 if (distance.length() < this->triggerDistance_)
                     this->trigger(*it);
             }
+            this->yaw(Radian(rotationSpeed_s*dt));
+            this->tickSum_ += bounceSpeed_s*dt;
+            this->translate(Vector3(0,bounceDistance_s*dt*sin(this->tickSum_),0));
+            if (this->tickSum_ > 2*Ogre::Math::PI)
+                this->tickSum_ -= 2*Ogre::Math::PI;
         }
     }
     /**

Modified: branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.h	2009-05-24 21:27:14 UTC (rev 3045)
+++ branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.h	2009-05-24 21:53:09 UTC (rev 3046)
@@ -108,6 +108,12 @@
 
         float triggerDistance_;                 //!< Distance in which this gets triggered.
 
+        /* Pickup animation */
+        float tickSum_;                         //!< Adds up tick to use in sine movement
+        static const float bounceSpeed_s;       //!< Speed of pickup to bounce up and down
+        static const float bounceDistance_s;    //!< Distance the pickup bounces up and down
+        static const float rotationSpeed_s;     //!< Rotation speed of pickup
+
         float respawnTime_;                     //!< Time after which this gets re-actived.
         Timer<PickupSpawner> respawnTimer_;     //!< Timer used for re-activating.
     };




More information about the Orxonox-commit mailing list