[Orxonox-commit 3882] r8556 - in code/branches/presentation: . data/levels data/levels/includes data/levels/templates src/libraries/util src/modules/objects/collisionshapes src/modules/pickup src/modules/pickup/items src/orxonox/collisionshapes src/orxonox/worldentities

dafrick at orxonox.net dafrick at orxonox.net
Mon May 23 23:40:58 CEST 2011


Author: dafrick
Date: 2011-05-23 23:40:58 +0200 (Mon, 23 May 2011)
New Revision: 8556

Added:
   code/branches/presentation/src/modules/pickup/items/ShrinkPickup.cc
   code/branches/presentation/src/modules/pickup/items/ShrinkPickup.h
Modified:
   code/branches/presentation/
   code/branches/presentation/data/levels/includes/pickups.oxi
   code/branches/presentation/data/levels/pickups.oxw
   code/branches/presentation/data/levels/templates/pickupRepresentationTemplates.oxt
   code/branches/presentation/src/libraries/util/SubString.h
   code/branches/presentation/src/modules/objects/collisionshapes/BoxCollisionShape.cc
   code/branches/presentation/src/modules/objects/collisionshapes/BoxCollisionShape.h
   code/branches/presentation/src/modules/objects/collisionshapes/ConeCollisionShape.cc
   code/branches/presentation/src/modules/objects/collisionshapes/ConeCollisionShape.h
   code/branches/presentation/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
   code/branches/presentation/src/modules/objects/collisionshapes/PlaneCollisionShape.h
   code/branches/presentation/src/modules/objects/collisionshapes/SphereCollisionShape.cc
   code/branches/presentation/src/modules/objects/collisionshapes/SphereCollisionShape.h
   code/branches/presentation/src/modules/pickup/PickupPrereqs.h
   code/branches/presentation/src/modules/pickup/items/CMakeLists.txt
   code/branches/presentation/src/orxonox/collisionshapes/CollisionShape.cc
   code/branches/presentation/src/orxonox/collisionshapes/CollisionShape.h
   code/branches/presentation/src/orxonox/collisionshapes/CompoundCollisionShape.cc
   code/branches/presentation/src/orxonox/collisionshapes/CompoundCollisionShape.h
   code/branches/presentation/src/orxonox/worldentities/WorldEntity.cc
Log:
Merging pickup branch into presentation branch.



Property changes on: code/branches/presentation
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/steering:5949-6091
/code/branches/tetris:8100-8107
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
   + /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/steering:5949-6091
/code/branches/tetris:8100-8107
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890

Modified: code/branches/presentation/data/levels/includes/pickups.oxi
===================================================================
--- code/branches/presentation/data/levels/includes/pickups.oxi	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/data/levels/includes/pickups.oxi	2011-05-23 21:40:58 UTC (rev 8556)
@@ -201,7 +201,7 @@
 
 <PickupRepresentation
     pickupName = "Drone Pickup"
-    pickupDescription = "Adds a Drone to the Players Spaceship"
+    pickupDescription = "Adds a Drone to the Player's Spaceship"
     spawnerTemplate = "dronepickupRepresentation"
 >
     <pickup>
@@ -209,3 +209,35 @@
     </pickup>
 </PickupRepresentation>
 
+<!-- Shrink Pickup -->
+
+<PickupRepresentation
+    pickupName = "Small Shrink"
+    pickupDescription = "Shrinks the Ship by a bit"
+    spawnerTemplate = "smallshrinkpickupRepresentation"
+>
+    <pickup>
+        <ShrinkPickup template=smallshrinkpickup />
+    </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+    pickupName = "Medium Shrink"
+    pickupDescription = "Shrinks the Ship"
+    spawnerTemplate = "mediumshrinkpickupRepresentation"
+>
+    <pickup>
+        <ShrinkPickup template=mediumshrinkpickup />
+    </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+    pickupName = "Huge Shrink"
+    pickupDescription = "Shrinks the Ship considerably"
+    spawnerTemplate = "hugeshrinkpickupRepresentation"
+>
+    <pickup>
+        <ShrinkPickup template=hugeshrinkpickup />
+    </pickup>
+</PickupRepresentation>
+

Modified: code/branches/presentation/data/levels/pickups.oxw
===================================================================
--- code/branches/presentation/data/levels/pickups.oxw	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/data/levels/pickups.oxw	2011-05-23 21:40:58 UTC (rev 8556)
@@ -189,5 +189,32 @@
       </pickup>
     </PickupSpawner>
 
+    <PickupSpawner position="-25,-50,-125" respawnTime="60" triggerDistance="20" maxSpawnedItems="5">
+      <pickup>
+        <ShrinkPickup template ="smallshrinkpickup"/>
+      </pickup>
+    </PickupSpawner>
+
+    <PickupSpawner position="0,-50,-125" respawnTime="60" triggerDistance="20" maxSpawnedItems="5">
+      <pickup>
+        <ShrinkPickup template ="mediumshrinkpickup"/>
+      </pickup>
+    </PickupSpawner>
+
+    <PickupSpawner position="25,-50,-125" respawnTime="60" triggerDistance="20" maxSpawnedItems="5">
+      <pickup>
+        <ShrinkPickup template ="hugeshrinkpickup"/>
+      </pickup>
+    </PickupSpawner>
+
+    <!--StaticEntity position="0,-200,0" direction="0,-1,0" collisionType=static mass=500 friction=0.01 >
+      <attached>
+        <Model position="0,0,0" mesh="cube.mesh" scale3D="10,10,10" />
+      </attached>
+      <collisionShapes>
+        <BoxCollisionShape position="0,0,0" halfExtents="10,10,10" />
+      </collisionShapes>
+  </StaticEntity-->
+
   </Scene>
 </Level>

Modified: code/branches/presentation/data/levels/templates/pickupRepresentationTemplates.oxt
===================================================================
--- code/branches/presentation/data/levels/templates/pickupRepresentationTemplates.oxt	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/data/levels/templates/pickupRepresentationTemplates.oxt	2011-05-23 21:40:58 UTC (rev 8556)
@@ -395,6 +395,81 @@
   />
 </Template>
 
+<Template name=smallshrinkpickupRepresentation>
+    <PickupRepresentation>
+        <spawner-representation>
+            <StaticEntity>
+                <attached>
+                    <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Sphere2" scale=0.1>
+                        <attached>
+                            <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=0.4 />
+                        </attached>
+                    </Billboard>
+                </attached>
+            </StaticEntity>
+        </spawner-representation>
+    </PickupRepresentation>
+</Template>
+
+<Template name=smallshrinkpickup>
+  <InvisiblePickup 
+    duration = 10.0
+    shrinkFactor = 2.5
+    activaionType = "immediate"
+    durationType = "continuous"
+  />
+</Template>
+
+<Template name=mediumshrinkpickupRepresentation>
+    <PickupRepresentation>
+        <spawner-representation>
+            <StaticEntity>
+                <attached>
+                    <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Sphere2" scale=0.1>
+                        <attached>
+                            <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=0.7 />
+                        </attached>
+                    </Billboard>
+                </attached>
+            </StaticEntity>
+        </spawner-representation>
+    </PickupRepresentation>
+</Template>
+
+<Template name=mediumshrinkpickup>
+  <InvisiblePickup 
+    duration = 30.0
+    shrinkFactor = 5.0
+    activaionType = "immediate"
+    durationType = "continuous"
+  />
+</Template>
+
+<Template name=hugeshrinkpickupRepresentation>
+    <PickupRepresentation>
+        <spawner-representation>
+            <StaticEntity>
+                <attached>
+                    <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Sphere2" scale=0.1>
+                        <attached>
+                            <Billboard position="0,0,0" colour="1.0,0.55,1.0" material="Shrink" scale=1.0 />
+                        </attached>
+                    </Billboard>
+                </attached>
+            </StaticEntity>
+        </spawner-representation>
+    </PickupRepresentation>
+</Template>
+
+<Template name=hugeshrinkpickup>
+  <InvisiblePickup 
+    duration = 60.0
+    shrinkFactor = 10.0
+    activaionType = "immediate"
+    durationType = "continuous"
+  />
+</Template>
+
 <!-- Pickup Collection pickups -->
 
 <Template name=triplehealthspeedinvisibilitypickupRepresentation>

Modified: code/branches/presentation/src/libraries/util/SubString.h
===================================================================
--- code/branches/presentation/src/libraries/util/SubString.h	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/libraries/util/SubString.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -168,7 +168,7 @@
         inline bool empty() const { return this->tokens_.empty(); }
         /// Returns the number of tokens stored in this SubString
         inline unsigned int size() const { return this->tokens_.size(); }
-        /// Returns the i'th token from the subset of strings @param index The index of the requested doken
+        /// Returns the i'th token from the subset of strings @param index The index of the requested token
         inline const std::string& operator[](unsigned int index) const { return this->tokens_[index]; }
         /// Returns the i'th token from the subset of strings @param index The index of the requested token
         inline const std::string& getString(unsigned int index) const { return (*this)[index]; }

Modified: code/branches/presentation/src/modules/objects/collisionshapes/BoxCollisionShape.cc
===================================================================
--- code/branches/presentation/src/modules/objects/collisionshapes/BoxCollisionShape.cc	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/objects/collisionshapes/BoxCollisionShape.cc	2011-05-23 21:40:58 UTC (rev 8556)
@@ -26,6 +26,11 @@
  *
  */
 
+/**
+    @file BoxCollisionShape.cc
+    @brief Implementation of the BoxCollisionShape class.
+*/
+
 #include "BoxCollisionShape.h"
 
 #include <BulletCollision/CollisionShapes/btBoxShape.h>
@@ -38,18 +43,23 @@
 {
     CreateFactory(BoxCollisionShape);
 
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
     BoxCollisionShape::BoxCollisionShape(BaseObject* creator) : CollisionShape(creator)
     {
         RegisterObject(BoxCollisionShape);
 
         this->halfExtents_ = Vector3(1, 1, 1);
-        updateShape();
+        this->updateShape();
 
         this->registerVariables();
     }
 
     BoxCollisionShape::~BoxCollisionShape()
     {
+        // TODO: Move to CollisionShape?
         if (this->isInitialized())
             delete this->collisionShape_;
     }
@@ -69,6 +79,32 @@
         XMLPortParamLoadOnly(BoxCollisionShape, "length", setLength, xmlelement, mode);
     }
 
+    /**
+    @brief
+        Is called when the scale of the BoxCollisionShape has changed.
+    */
+    void BoxCollisionShape::changedScale()
+    {
+        CollisionShape::changedScale();
+
+        // Resize the internal collision shape
+        // TODO: Assuming setLocalScaling works.
+        // this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
+        if(!this->hasUniformScaling())
+        {
+            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
+            return;
+        }
+
+        this->setHalfExtents(this->halfExtents_ * this->getScale());
+    }
+
+    /**
+    @brief
+        Creates a new internal collision shape for the BoxCollisionShape.
+    @return
+        Returns a pointer to the newly created btBoxShape.
+    */
     btCollisionShape* BoxCollisionShape::createNewShape() const
     {
         return new btBoxShape(multi_cast<btVector3>(this->halfExtents_));

Modified: code/branches/presentation/src/modules/objects/collisionshapes/BoxCollisionShape.h
===================================================================
--- code/branches/presentation/src/modules/objects/collisionshapes/BoxCollisionShape.h	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/objects/collisionshapes/BoxCollisionShape.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -42,6 +42,17 @@
 
 namespace orxonox
 {
+
+    /**
+    @brief
+        Wrapper for the bullet box collision shape class btBoxShape.
+
+    @author
+        Reto Grieder
+
+    @see btBoxShape
+    @ingroup Collisionshapes
+    */
     class _ObjectsExport BoxCollisionShape : public CollisionShape
     {
         public:
@@ -50,32 +61,75 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            inline void setHalfExtents(const Vector3& extents)
-                { this->halfExtents_ = extents; updateShape(); }
+            /**
+            @brief Set the half extents of the BoxCollisionShape.
+                   If the half extent changes, this causes the internal collision shape to be recreated.
+            @param extents A vector with the half extents.
+                   The x-component is half the length, the y-component is half the height and the z-component is half the width.
+            @return Returns true if the half extent has changed, false if not.
+            */
+            inline bool setHalfExtents(const Vector3& extents)
+                { if(this->halfExtents_ == extents) return false; this->halfExtents_ = extents; updateShape(); return true; }
+            /**
+            @brief Get the half extents of the BoxCollisionShape.
+            @return Returns a vector containing the half extents.
+            */
             inline const Vector3& getHalfExtents() const
                 { return halfExtents_;}
 
-            inline void setWidth(float value)
-                { this->halfExtents_.z = value / 2; updateShape(); }
+            /**
+            @brief Set the width of the BoxCollisionShape.
+                   If the width changes, this causes the internal collision shape to be recreated.
+            @param value The width to be set.
+            @return Returns true if the width has changed, false if not.
+            */
+            inline bool setWidth(float value)
+                { if(this->halfExtents_.z == value/2.0f) return false; this->halfExtents_.z = value / 2.0f; updateShape(); return true; }
+            /**
+            @brief Get the width of the BoxCollisionShape.
+            @return Returns the width of the BoxCollisionShape.
+            */
             inline float getWidth() const
-                { return this->halfExtents_.z * 2; }
+                { return this->halfExtents_.z * 2.0f; }
 
-            inline void setHeight(float value)
-                { this->halfExtents_.y = value / 2; updateShape(); }
+            /**
+            @brief Set the height of the BoxCollisionShape.
+                   If the height changes, this causes the internal collision shape to be recreated.
+            @param value The height to be set.
+            @return Returns true if the height has changed, false if not.
+            */
+            inline bool setHeight(float value)
+                { if(this->halfExtents_.y == value/2.0f) return false; this->halfExtents_.y = value / 2.0f; updateShape(); return true; }
+            /**
+            @brief Get the height of the BoxCollisionShape.
+            @return Returns the height of the BoxCollisionShape.
+            */
             inline float getHeight() const
-                { return this->halfExtents_.y * 2; }
+                { return this->halfExtents_.y * 2.0f; }
 
-            inline void setLength(float value)
-                { this->halfExtents_.x = value / 2; updateShape(); }
+            /**
+            @brief Set the length of the BoxCollisionShape.
+                   If the length changes, this causes the internal collision shape to be recreated.
+            @param value The length to be set.
+            @return Returns true if the length has changed, false if not.
+            */
+            inline bool setLength(float value)
+                { if(this->halfExtents_.x == value/2.0f) return false; this->halfExtents_.x = value / 2.0f; updateShape(); return true; }
+            /**
+            @brief Get the length of the BoxCollisionShape.
+            @return Returns the length of the BoxCollisionShape.
+            */
             inline float getLength() const
-                { return this->halfExtents_.x * 2; }
+                { return this->halfExtents_.x * 2.0f; }
 
+            virtual void changedScale(); // Is called when the scale of the BoxCollisionShape has changed.
+
         private:
             void registerVariables();
 
-            btCollisionShape* createNewShape() const;
+            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the BoxCollisionShape.
 
-            Vector3 halfExtents_;
+            Vector3 halfExtents_; //!< The half extents of the BoxCollisionShape. The x-component is half the length, the y-component is half the height and the z-component is half the width.
      };
 }
 

Modified: code/branches/presentation/src/modules/objects/collisionshapes/ConeCollisionShape.cc
===================================================================
--- code/branches/presentation/src/modules/objects/collisionshapes/ConeCollisionShape.cc	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/objects/collisionshapes/ConeCollisionShape.cc	2011-05-23 21:40:58 UTC (rev 8556)
@@ -26,17 +26,27 @@
  *
  */
 
+/**
+    @file ConeCollisionShape.cc
+    @brief Implementation of the ConeCollisionShape class.
+*/
+
 #include "ConeCollisionShape.h"
 
 #include <BulletCollision/CollisionShapes/btConeShape.h>
 
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
+#include "tools/BulletConversions.h"
 
 namespace orxonox
 {
     CreateFactory(ConeCollisionShape);
 
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
     ConeCollisionShape::ConeCollisionShape(BaseObject* creator) : CollisionShape(creator)
     {
         RegisterObject(ConeCollisionShape);
@@ -68,6 +78,34 @@
         XMLPortParam(ConeCollisionShape, "height", setHeight, getHeight, xmlelement, mode);
     }
 
+    /**
+    @brief
+        Is called when the scale of the ConeCollisionShape has changed.
+    */
+    void ConeCollisionShape::changedScale()
+    {
+        CollisionShape::changedScale();
+
+        // Resize the internal collision shape
+        // TODO: Assuming setLocalScaling works.
+        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
+        if(!this->hasUniformScaling())
+        {
+            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
+            return;
+        }
+
+        this->radius_ *= this->getScale();
+        this->height_ *= this->getScale();
+        this->updateShape();
+    }
+
+    /**
+    @brief
+        Creates a new internal collision shape for the ConeCollisionShape.
+    @return
+        Returns a pointer to the newly created btConeShape.
+    */
     btCollisionShape* ConeCollisionShape::createNewShape() const
     {
         return new btConeShape(this->radius_, this->height_);

Modified: code/branches/presentation/src/modules/objects/collisionshapes/ConeCollisionShape.h
===================================================================
--- code/branches/presentation/src/modules/objects/collisionshapes/ConeCollisionShape.h	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/objects/collisionshapes/ConeCollisionShape.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -40,6 +40,17 @@
 
 namespace orxonox
 {
+
+    /**
+    @brief
+        Wrapper for the bullet cone collision shape class btConeShape.
+
+    @author
+        Reto Grieder
+
+    @see btConeShape
+    @ingroup Collisionshapes
+    */
     class _ObjectsExport ConeCollisionShape : public CollisionShape
     {
         public:
@@ -48,23 +59,45 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            inline void setRadius(float value)
-                { this->radius_ = value; updateShape(); }
+            /**
+            @brief Set the radius of the ConeCollisionShape.
+                   If the radius changes, this causes the internal collision shape to be recreated.
+            @param value The radius to be set.
+            @return Returns true if the radius has changed, false if not.
+            */
+            inline bool setRadius(float value)
+                { if(this->radius_ == value) return false; this->radius_ = value; updateShape(); return true; }
+            /**
+            @brief Get the radius of the ConeCollisionShape.
+            @return Returns the radius of the ConeCollisionShape.
+            */
             inline float getRadius() const
                 { return radius_; }
 
-            inline void setHeight(float value)
-                { this->height_ = value; updateShape(); }
+            /**
+            @brief Set the height of the ConeCollisionShape.
+                   If the height changes, this causes the internal collision shape to be recreated.
+            @param value The height to be set.
+            @return Returns true if the height has changed, false if not.
+            */
+            inline bool setHeight(float value)
+                { if(this->height_ == value) return false; this->height_ = value; updateShape(); return true; }
+            /**
+            @brief Get the height of the ConeCollisionShape.
+            @return Returns the height of the ConeCollisionShape.
+            */
             inline float getHeight() const
                 { return this->height_; }
 
+            virtual void changedScale(); // Is called when the scale of the ConeCollisionShape has changed.
+
         private:
             void registerVariables();
 
-            btCollisionShape* createNewShape() const;
+            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the ConeCollisionShape.
 
-            float radius_;
-            float height_;
+            float radius_; //!< The radius of the ConeCollisionShape.
+            float height_; //!< The height of the ConeCollisionShape.
      };
 }
 

Modified: code/branches/presentation/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
===================================================================
--- code/branches/presentation/src/modules/objects/collisionshapes/PlaneCollisionShape.cc	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/objects/collisionshapes/PlaneCollisionShape.cc	2011-05-23 21:40:58 UTC (rev 8556)
@@ -26,6 +26,11 @@
  *
  */
 
+/**
+    @file PlaneCollisionShape.cc
+    @brief Implementation of the PlaneCollisionShape class.
+*/
+
 #include "PlaneCollisionShape.h"
 
 #include <BulletCollision/CollisionShapes/btStaticPlaneShape.h>
@@ -38,6 +43,10 @@
 {
     CreateFactory(PlaneCollisionShape);
 
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
     PlaneCollisionShape::PlaneCollisionShape(BaseObject* creator) : CollisionShape(creator)
     {
         RegisterObject(PlaneCollisionShape);
@@ -69,6 +78,32 @@
         XMLPortParam(PlaneCollisionShape, "offset", setOffset, getOffset, xmlelement, mode);
     }
 
+    /**
+    @brief
+        Is called when the scale of the PlaneCollisionShape has changed.
+    */
+    void PlaneCollisionShape::changedScale()
+    {
+        CollisionShape::changedScale();
+
+        // Resize the internal collision shape
+        // TODO: Assuming setLocalScaling works.
+        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
+        if(!this->hasUniformScaling())
+        {
+            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
+            return;
+        }
+
+        this->setOffset(this->offset_*this->getScale());
+    }
+
+    /**
+    @brief
+        Creates a new internal collision shape for the PlaneCollisionShape.
+    @return
+        Returns a pointer to the newly created btStaticPlaneShape.
+    */
     btCollisionShape* PlaneCollisionShape::createNewShape() const
     {
         return new btStaticPlaneShape(multi_cast<btVector3>(this->normal_), this->offset_);

Modified: code/branches/presentation/src/modules/objects/collisionshapes/PlaneCollisionShape.h
===================================================================
--- code/branches/presentation/src/modules/objects/collisionshapes/PlaneCollisionShape.h	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/objects/collisionshapes/PlaneCollisionShape.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -42,6 +42,17 @@
 
 namespace orxonox
 {
+
+    /**
+    @brief
+        Wrapper for the bullet plane collision shape class btStaticPlaneShape.
+
+    @author
+        Martin Stypinski
+
+    @see btStaticPlaneShape
+    @ingroup Collisionshapes
+    */
     class _ObjectsExport PlaneCollisionShape : public CollisionShape
     {
         public:
@@ -50,23 +61,45 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            inline void setNormal(const Vector3& normal)
-                { this->normal_ = normal; updateShape(); }
-            inline const Vector3& getNormal()
+            /**
+            @brief Set the normal of the PlaneCollisionShape.
+                   If the normal changes, this causes the internal collision shape to be recreated.
+            @param normal The normal vector to be set.
+            @return Returns true if the normal has changed, false if not.
+            */
+            inline bool setNormal(const Vector3& normal)
+                { if(this->normal_ == normal) return false; this->normal_ = normal; updateShape(); return true; }
+            /**
+            @brief Get the normal of the PlaneCollisionShape.
+            @return Returns the normal vector of the PlaneCollisionShape.
+            */
+            inline const Vector3& getNormal() const
                 { return normal_;}
 
-            inline void setOffset(float offset)
-                { this->offset_ = offset; updateShape(); }
-            inline float getOffset()
+            /**
+            @brief Set the offset of the PlaneCollisionShape.
+                   If the offset changes, this causes the internal collision shape to be recreated.
+            @param offset The offset to be set.
+            @return Returns true if the offset has changed, false if not.
+            */
+            inline bool setOffset(float offset)
+                { if(this->offset_ == offset) return false; this->offset_ = offset; updateShape(); return true; }
+            /**
+            @brief Get the offset of the PlaneCollisionShape.
+            @return Returns the offset of the PlaneCollisionShape.
+            */
+            inline float getOffset() const
                 { return this->offset_;}
 
+            virtual void changedScale(); // Is called when the scale of the PlaneCollisionShape has changed.
+
         private:
             void registerVariables();
 
-            btCollisionShape* createNewShape()const;
+            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the PlaneCollisionShape.
 
-            Vector3 normal_;
-            float   offset_;
+            Vector3 normal_; //!< The normal vector of the PlaneCollisionShape.
+            float   offset_; //!< The offset of the PlaneCollisionShape.
      };
 }
 

Modified: code/branches/presentation/src/modules/objects/collisionshapes/SphereCollisionShape.cc
===================================================================
--- code/branches/presentation/src/modules/objects/collisionshapes/SphereCollisionShape.cc	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/objects/collisionshapes/SphereCollisionShape.cc	2011-05-23 21:40:58 UTC (rev 8556)
@@ -26,17 +26,27 @@
  *
  */
 
+/**
+    @file SphereCollisionShape.cc
+    @brief Implementation of the SphereCollisionShape class.
+*/
+
 #include "SphereCollisionShape.h"
 
 #include <BulletCollision/CollisionShapes/btSphereShape.h>
 
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
+#include "tools/BulletConversions.h"
 
 namespace orxonox
 {
     CreateFactory(SphereCollisionShape);
 
+    /**
+    @brief
+        Constructor. registers and initializes the object.
+    */
     SphereCollisionShape::SphereCollisionShape(BaseObject* creator) : CollisionShape(creator)
     {
         RegisterObject(SphereCollisionShape);
@@ -65,6 +75,32 @@
         XMLPortParam(SphereCollisionShape, "radius", setRadius, getRadius, xmlelement, mode);
     }
 
+    /**
+    @brief
+        Is called when the scale of the SphereCollisionShape has changed.
+    */
+    void SphereCollisionShape::changedScale()
+    {
+        CollisionShape::changedScale();
+
+        // Resize the internal collision shape
+        // TODO: Assuming setLocalScaling works.
+        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
+        if(!this->hasUniformScaling())
+        {
+            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
+            return;
+        }
+
+        this->setRadius(this->radius_*this->getScale());
+    }
+
+    /**
+    @brief
+        Creates a new internal collision shape for the SphereCollisionShape.
+    @return
+        Returns a pointer to the newly created btSphereShape.
+    */
     btCollisionShape* SphereCollisionShape::createNewShape() const
     {
         return new btSphereShape(this->radius_);

Modified: code/branches/presentation/src/modules/objects/collisionshapes/SphereCollisionShape.h
===================================================================
--- code/branches/presentation/src/modules/objects/collisionshapes/SphereCollisionShape.h	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/objects/collisionshapes/SphereCollisionShape.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -40,6 +40,17 @@
 
 namespace orxonox
 {
+
+    /**
+    @brief
+        Wrapper for the bullet sphere collision shape class btSphereShape.
+
+    @author
+        Reto Grieder
+
+    @see btSphereShape
+    @ingroup Collisionshapes
+    */
     class _ObjectsExport SphereCollisionShape : public CollisionShape
     {
         public:
@@ -48,17 +59,29 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            inline void setRadius(float radius)
-                { this->radius_ = radius; updateShape(); }
+            /**
+            @brief Set the radius of the SphereCollisionShape.
+                   If the radius changes, this causes the internal collision shape to be recreated.
+            @param radius The radius to be set.
+            @return Returns true if the radius has changed, false if not.
+            */
+            inline bool setRadius(float radius)
+                { if(this->radius_ == radius) return false; this->radius_ = radius; updateShape(); return true; }
+            /**
+            @brief Get the radius of the SphereCollisionShape.
+            @return Returns the radius of the SphereCollisionShape.
+            */
             inline float getRadius() const
                 { return this->radius_; }
 
+            virtual void changedScale(); // Is called when the scale of the SphereCollisionShape has changed.
+
         private:
             void registerVariables();
 
             btCollisionShape* createNewShape() const;
 
-            float radius_;
+            float radius_; //!< The radius of the SphereCollisionShape.
     };
 }
 

Modified: code/branches/presentation/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/presentation/src/modules/pickup/PickupPrereqs.h	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/pickup/PickupPrereqs.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -84,6 +84,7 @@
     class MetaPickup;
     class SpeedPickup;
     class ShieldPickup;
+    class ShrinkPickup;
 
 }
 

Modified: code/branches/presentation/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/branches/presentation/src/modules/pickup/items/CMakeLists.txt	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/modules/pickup/items/CMakeLists.txt	2011-05-23 21:40:58 UTC (rev 8556)
@@ -5,4 +5,5 @@
   DronePickup.cc
   SpeedPickup.cc
   ShieldPickup.cc
+  ShrinkPickup.cc
 )

Copied: code/branches/presentation/src/modules/pickup/items/ShrinkPickup.cc (from rev 8554, code/branches/pickup/src/modules/pickup/items/ShrinkPickup.cc)
===================================================================
--- code/branches/presentation/src/modules/pickup/items/ShrinkPickup.cc	                        (rev 0)
+++ code/branches/presentation/src/modules/pickup/items/ShrinkPickup.cc	2011-05-23 21:40:58 UTC (rev 8556)
@@ -0,0 +1,278 @@
+/*
+ *   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:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+/**
+    @file ShrinkPickup.cc
+    @brief Implementation of the HealthPickup class.
+*/
+
+
+#include "ShrinkPickup.h"
+
+#include <sstream>
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "pickup/PickupIdentifier.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weaponsystem/WeaponSlot.h"
+#include "weaponsystem/Weapon.h"
+#include "worldentities/CameraPosition.h"
+
+namespace orxonox
+{
+    CreateFactory(ShrinkPickup);
+
+        /**
+    @brief
+        Constructor: Initializes the Pickup.
+    */
+    ShrinkPickup::ShrinkPickup(BaseObject* creator) : Pickup(creator)
+    {
+        RegisterObject(ShrinkPickup);
+
+        this->initialize();
+        this->shrinkFactor_ = 5.0f;
+        this->shrinkSpeed_ = 5.0f;
+        this->duration_ = 5.0f;
+        this->isActive_ = false;
+        this->isTerminating_ = false;
+
+        this->size_ = 0;
+        this->defaultCameraPos_ = 0.0f;
+        this->defaultScale_ = Vector3::UNIT_SCALE;
+        this->actualScale_ = Vector3::UNIT_SCALE;
+        this->smallScale_ = Vector3::UNIT_SCALE;
+        this->defaultMass_ = 1.0f;
+        this->actualMass_ = 1.0f;
+        this->smallMass_ = 1.0f;
+        this->pawn_ = NULL;
+    }
+
+    ShrinkPickup::~ShrinkPickup()
+    {
+
+    }
+
+    void ShrinkPickup::initializeIdentifier(void)
+    {
+        std::stringstream stream;
+        stream << this->getShrinkFactor();
+        std::string type1 = "shrinkFactor";
+        std::string val1 = stream.str();
+        this->pickupIdentifier_->addParameter(type1, val1);
+
+        stream.clear();
+        stream << this->getDuration();
+        std::string val2 = stream.str();
+        std::string type2 = "duration";
+        this->pickupIdentifier_->addParameter(type2, val2);
+
+        stream.clear();
+        stream << this->getShrinkSpeed();
+        std::string val3 = stream.str();
+        std::string type3 = "shrinkSpeed";
+        this->pickupIdentifier_->addParameter(type3, val3);
+    }
+
+   /**
+    @brief
+        Method for creating a ShrinkhPickup object through XML.
+    */
+    void ShrinkPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
+    {
+        SUPER(ShrinkPickup, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ShrinkPickup, "shrinkFactor", setShrinkFactor, getShrinkFactor, xmlelement, mode);
+        XMLPortParam(ShrinkPickup, "duration", setDuration, getDuration, xmlelement, mode);
+        XMLPortParam(ShrinkPickup, "shrinkSpeed", setShrinkSpeed, getShrinkSpeed, xmlelement, mode);
+
+        this->initializeIdentifier();
+    }
+
+    /**
+    @brief
+        Sets the shrinking factor.
+    @param factor
+        The factor.
+    */
+    void ShrinkPickup::setShrinkFactor(float factor)
+    {
+        this->shrinkFactor_ = factor;
+    }
+
+    /**
+    @brief
+        Sets the duration.
+    @param duration
+        The duration.
+    */
+    void ShrinkPickup::setDuration(float duration)
+    {
+        this->duration_ = duration;
+    }
+
+    /**
+    @brief
+        Sets the shrinking speed.
+    @param speed
+        The speed.
+    */
+    void ShrinkPickup::setShrinkSpeed(float speed)
+    {
+        this->shrinkSpeed_ = speed;
+    }
+
+    void ShrinkPickup::initialize(void)
+    {
+        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
+    }
+
+    /**
+    @brief
+        Prepares for shrinking (collecting several informations).
+    */
+    void ShrinkPickup::changedUsed(void)
+    {
+        SUPER(ShrinkPickup, changedUsed);
+
+        if(this->isUsed())
+        {
+            this->pawn_ = this->carrierToPawnHelper();
+            if(this->pawn_ == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+                this->Pickupable::destroy();
+
+            //Collect scaling information.
+            this->defaultScale_ = this->pawn_->getScale3D();
+            this->defaultMass_ = this->pawn_->getMass();
+
+            this->smallScale_ = this->defaultScale_ / this->shrinkFactor_;
+            this->smallMass_ = this->defaultMass_ / this->shrinkFactor_;
+
+            this->actualScale_ = this->defaultScale_;
+            this->actualMass_ = this->defaultMass_;
+
+            this->cameraPositions_ = this->pawn_->getCameraPositions();
+            this->size_ = this->cameraPositions_.size();
+            this->isActive_ = true;    //start shrinking now.
+            this->durationTimer_.setTimer(this->duration_, false, createExecutor(createFunctor(&ShrinkPickup::terminate, this)));    //Set timer for termination.
+        }
+    }
+
+    /**
+    @brief
+        Updates the scales of the ship.
+    @param dt
+        Time since last call.
+    */
+    void ShrinkPickup::tick(float dt)
+    {
+        if(this->isActive_ == true && this->actualScale_ > this->smallScale_)    //if the ship has not reached the target scale, continue shrinking
+        {
+            float factor = 1 + dt*this->shrinkSpeed_;
+
+            this->actualScale_ /= factor;
+            this->actualMass_ /= factor;
+
+            this->pawn_->setScale3D(this->actualScale_);
+            this->pawn_->setMass(this->actualMass_);
+
+            for(int index = 0; index < this->size_; index++)
+            {
+                CameraPosition* cameraPos = this->pawn_->getCameraPosition(index);
+                if(cameraPos == NULL)
+                continue;
+                cameraPos->setPosition(cameraPos->getPosition()*factor);
+            }
+        }
+        else this->isActive_ = false;
+
+        if(this->isTerminating_ == true && this->actualScale_ < this->defaultScale_)    //grow until the ship reaches its default scale.
+        {
+            float factor = 1 + dt*this->shrinkSpeed_;
+
+            this->actualScale_ *= factor;
+            this->actualMass_ *= factor;
+
+            this->pawn_->setScale3D(this->actualScale_);
+            this->pawn_->setMass(this->actualMass_);
+
+            for(int index = 0; index < this->size_; index++)
+            {
+                CameraPosition* cameraPos = this->pawn_->getCameraPosition(index);
+                if(cameraPos == NULL)
+                continue;
+                cameraPos->setPosition(cameraPos->getPosition()/factor);
+            }
+        }
+        else if(this->isTerminating_ == true)
+            this->Pickupable::destroy();
+
+    }
+
+    /**
+    @brief
+        Initializes the termination.
+    */
+    void ShrinkPickup::terminate(void)
+    {
+        this->isActive_ = false;
+        this->isTerminating_ = true;
+        setUsed(false);
+    }
+
+    Pawn* ShrinkPickup::carrierToPawnHelper(void)
+    {
+        PickupCarrier* carrier = this->getCarrier();
+        Pawn* pawn = dynamic_cast<Pawn*>(carrier);
+
+        return pawn;
+    }
+
+    /**
+    @brief
+        Creates a duplicate of the input OrxonoxClass.
+    @param item
+        A pointer to the Orxonox class.
+    */
+    void ShrinkPickup::clone(OrxonoxClass*& item)
+    {
+        if(item == NULL)
+            item = new ShrinkPickup(this);
+
+        SUPER(ShrinkPickup, clone, item);
+        ShrinkPickup* pickup = dynamic_cast<ShrinkPickup*>(item);
+        pickup->setShrinkFactor(this->getShrinkFactor());
+        pickup->setDuration(this->getDuration());
+        pickup->setShrinkSpeed(this->getShrinkSpeed());
+
+        pickup->initializeIdentifier();
+    }
+}

Copied: code/branches/presentation/src/modules/pickup/items/ShrinkPickup.h (from rev 8554, code/branches/pickup/src/modules/pickup/items/ShrinkPickup.h)
===================================================================
--- code/branches/presentation/src/modules/pickup/items/ShrinkPickup.h	                        (rev 0)
+++ code/branches/presentation/src/modules/pickup/items/ShrinkPickup.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -0,0 +1,124 @@
+/*
+ *   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:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ShrinkPickup.h
+    @brief Declaration of the ShrinkPickup class.
+    @ingroup PickupItems
+*/
+
+
+#ifndef _ShrinkPickup_H__
+#define _ShrinkPickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include <string>
+#include <vector>
+
+#include "pickup/Pickup.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox {
+
+    /**
+    @author
+        Sandro Sgier
+
+    @ingroup PickupItems
+    */
+
+    /**
+    @brief
+        The ShrinkPickup is a Pickupable that causes the pawn to shrink to a certain size for a certain time with a certain speed, all of them specified in the following variables:
+        - The @b shrinkFactor It determines how much the ship is going to shrink (e.g. the factor 2 would make the ship shrinking to half its size).
+        - The @b duration Specifies how long the ship will keep small.
+        - The @b shrinkSpeed Defines how fast the ship shrinks and grows.
+
+
+        An example of a XML implementation of a HealthPickup would be:
+        @code
+        <HealthPickup
+            shrinkFactor = "5.0"
+            duration = "5.0"
+            shrinkSpeed = "5.0"
+        />
+        @endcode
+
+    @author
+        Sandro Sgier
+
+    @ingroup PickupItems
+    */
+
+    class _PickupExport ShrinkPickup : public Pickup, public Tickable
+    {
+        public:
+            ShrinkPickup(BaseObject* creator); //!< Constructor.
+            virtual ~ShrinkPickup(); //!< Destructor.
+            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
+            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
+            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode);
+            inline float getShrinkFactor(void) const
+                { return this->shrinkFactor_; }
+            inline float getDuration(void) const
+                { return this->duration_; }
+            inline float getShrinkSpeed(void) const
+                { return this->shrinkSpeed_; }
+            void setShrinkFactor(float factor);
+            void setDuration(float duration);
+            void setShrinkSpeed(float speed);
+            void tick(float dt);
+
+        protected:
+            void initializeIdentifier(void);
+
+        private:
+            void initialize(void);
+            float duration_;            //!< determines how long the pickup will be active
+            float shrinkFactor_;        //shrink factor of the space ship
+            float shrinkSpeed_;         //speed of shrinking
+            bool isActive_;             //true if ship is shrinking or small
+            bool isTerminating_;        //true if ship is growing
+            int size_;                  //number of camera positions
+            std::list<SmartPtr<CameraPosition> > cameraPositions_;
+            float defaultCameraPos_;    //all default, actual and small values...
+            Ogre::Vector3 defaultScale_;
+            Ogre::Vector3 actualScale_;
+            Ogre::Vector3 smallScale_;
+            float defaultMass_;
+            float actualMass_;
+            float smallMass_;            
+            Pawn* carrierToPawnHelper(void);
+            Pawn* pawn_;
+            Timer durationTimer_;
+            void terminate(void);
+    };
+}
+
+#endif

Modified: code/branches/presentation/src/orxonox/collisionshapes/CollisionShape.cc
===================================================================
--- code/branches/presentation/src/orxonox/collisionshapes/CollisionShape.cc	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/orxonox/collisionshapes/CollisionShape.cc	2011-05-23 21:40:58 UTC (rev 8556)
@@ -26,6 +26,11 @@
  *
  */
 
+/**
+    @file CollisionShape.cc
+    @brief Implementation of the CollisionShape class.
+*/
+
 #include "CollisionShape.h"
 
 #include <BulletCollision/CollisionShapes/btCollisionShape.h>
@@ -38,6 +43,11 @@
 
 namespace orxonox
 {
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
     CollisionShape::CollisionShape(BaseObject* creator)
         : BaseObject(creator)
         , Synchronisable(creator)
@@ -50,13 +60,18 @@
         this->position_ = Vector3::ZERO;
         this->orientation_ = Quaternion::IDENTITY;
         this->scale_ = Vector3::UNIT_SCALE;
+        this->uniformScale_ = true;
 
         this->registerVariables();
     }
 
+    /**
+    @brief
+        Destructor. Detaches the CollisionShape from its parent.
+    */
     CollisionShape::~CollisionShape()
     {
-        // Detach from parent
+        // Detach from parent CompoundCollisionShape.
         if (this->isInitialized() && this->parent_)
             this->parent_->detach(this);
     }
@@ -74,81 +89,181 @@
         XMLPortParamLoadOnly(CollisionShape, "roll",  roll,  xmlelement, mode);
     }
 
+    /**
+    @brief
+        Register variables that need synchronizing over the network.
+    */
     void CollisionShape::registerVariables()
     {
+        // Keep the shape's parent (can be either a CompoundCollisionShape or a WorldEntity) consistent over the network.
         registerVariable(this->parentID_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
     }
 
-    void CollisionShape::parentChanged()
-    {
-        Synchronisable* parent = Synchronisable::getSynchronisable(this->parentID_);
-        // Parent can either be a WorldEntity or a CompoundCollisionShape. The reason is that the
-        // internal collision shape (which is compound) of a WE doesn't get synchronised.
-        CompoundCollisionShape* parentCCS = orxonox_cast<CompoundCollisionShape*>(parent);
-        if (parentCCS)
-            parentCCS->attach(this);
-        else
-        {
-            WorldEntity* parentWE = orxonox_cast<WorldEntity*>(parent);
-            if (parentWE)
-                parentWE->attachCollisionShape(this);
-        }
-    }
-
+    /**
+    @brief
+        Notifies the CollisionShape of being attached to a CompoundCollisionShape.
+    @param newParent
+        A pointer to the CompoundCollisionShape the CollisionShape was attached to.
+    @return
+        Returns 
+    */
     bool CollisionShape::notifyBeingAttached(CompoundCollisionShape* newParent)
     {
+        // If the CollisionShape is attached to a CompoundCollisionShapes, detach it.
         if (this->parent_)
             this->parent_->detach(this);
 
         this->parent_ = newParent;
 
+        // If the new parent is a WorldEntityCollisionShape, the parentID is set to the objectID of the WorldEntity that is its owner.
+        // TODO: Why?
         WorldEntityCollisionShape* parentWECCS = orxonox_cast<WorldEntityCollisionShape*>(newParent);
         if (parentWECCS)
             this->parentID_ = parentWECCS->getWorldEntityOwner()->getObjectID();
+        // Else it is set to the objectID of the CompoundCollisionShape.
         else
             this->parentID_ = newParent->getObjectID();
 
         return true;
     }
 
+    /**
+    @brief
+        Notifies the CollisionShape of being detached from a CompoundCollisionShape.
+    */
     void CollisionShape::notifyDetached()
     {
         this->parent_ = 0;
         this->parentID_ = OBJECTID_UNKNOWN;
     }
 
+    /**
+    @brief
+        Updates the CompoundCollisionShape the CollisionShape belongs to (if it belongs to one), after the CollisionShape has changed.
+    */
     void CollisionShape::updateParent()
     {
         if (this->parent_)
             this->parent_->updateAttachedShape(this);
     }
 
+    /**
+    @brief
+        Is called when the parentID of the CollisionShape has changed.
+        Attaches it to the object with the changed parentID, which can either be a CompoundCollisionShape or a WorldEntity.
+    */
+    void CollisionShape::parentChanged()
+    {
+        // Get the parent object from the network.
+        Synchronisable* parent = Synchronisable::getSynchronisable(this->parentID_);
+
+        // Parent can either be a WorldEntity or a CompoundCollisionShape. The reason is that the
+        // internal collision shape (which is compound) of a WE doesn't get synchronised.
+        CompoundCollisionShape* parentCCS = orxonox_cast<CompoundCollisionShape*>(parent);
+
+        // If the parent is a CompoundCollisionShape, attach the CollisionShape to it.
+        if (parentCCS)
+            parentCCS->attach(this);
+        else
+        {
+            // If the parent is a WorldEntity, attach the CollisionShape to its collision shapes.
+            WorldEntity* parentWE = orxonox_cast<WorldEntity*>(parent);
+            if (parentWE)
+                parentWE->attachCollisionShape(this);
+        }
+    }
+
+    /**
+    @brief
+        Check whether the CollisionShape has been either moved or rotated or both. (i.e. it doesn't have position zero and identity orientation any more)
+    @return
+        Returns true if it has been moved.
+    */
     bool CollisionShape::hasTransform() const
     {
         return (!this->position_.positionEquals(Vector3(0, 0, 0), 0.001f) ||
                 !this->orientation_.equals(Quaternion(1,0,0,0), Degree(0.1f)));
     }
 
+    /**
+    @brief
+        Set the scale of the CollisionShape.
+        Since the scale is a vector the CollisionShape can be scaled independently in each direction, allowing for linear distortions.
+        If the scale changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+        Beware, non-uniform scaling (i.e. distortions) might not be supported by all CollisionShapes.
+    @param scale
+        The new scale to be set. Vector3::UNIT_SCALE is the initial scale.
+    */
     void CollisionShape::setScale3D(const Vector3& scale)
     {
-        CCOUT(2) << "Warning: Cannot set the scale of a collision shape: Not yet implemented." << std::endl;
+        if(this->scale_ == scale)
+            return;
+
+        // If the vectors are not in the same direction, then this is no longer a uniform scaling.
+        if(scale_.crossProduct(scale).squaredLength() != 0.0f)
+        {
+            CCOUT(2) << "Warning: Non-uniform scaling is not yet supported." << endl;
+            return;
+        }
+
+        this->scale_ = scale;
+
+        this->changedScale();
+        this->updateParent();
     }
 
+    /**
+    @brief
+        Set the (uniform) scale of the CollisionShape.
+        If the scale changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+    @param scale
+        The scale to scale the CollisionShape with. 1.0f is the initial scale.
+    */
     void CollisionShape::setScale(float scale)
     {
-        CCOUT(2) << "Warning: Cannot set the scale of a collision shape: Not yet implemented." << std::endl;
+        if(this->scale_.length() == scale)
+            return;
+
+        this->scale_ = Vector3::UNIT_SCALE*scale;
+
+        this->changedScale();
+        this->updateParent();
     }
 
+    /**
+    @brief
+        Is called when the scale of the CollisionShape has changed.
+    */
+    void CollisionShape::changedScale()
+    {
+        // Adjust the position of the CollisionShape.
+        this->position_ *= this->getScale3D();
+    }
+
+    /**
+    @brief
+        Updates the shape.
+        Is called when the internal parameters of the shape have changed such that a new shape needs to be created.
+    */
     void CollisionShape::updateShape()
     {
         btCollisionShape* oldShape = this->collisionShape_;
         this->collisionShape_ = this->createNewShape();
+        // If the CollisionShape has been rescaled, scale the shape to fit the current scale.
+        if(this->scale_ != Vector3::UNIT_SCALE)
+            this->changedScale();
         // When we recreate the shape, we have to inform the parent about this to update the shape
         this->updateParent();
         if (oldShape)
             delete oldShape;
     }
 
+    /**
+    @brief
+        Calculates the local inertia of the collision shape.
+    @todo
+        Document.
+    */
     void CollisionShape::calculateLocalInertia(float mass, btVector3& inertia) const
     {
         if (this->collisionShape_)

Modified: code/branches/presentation/src/orxonox/collisionshapes/CollisionShape.h
===================================================================
--- code/branches/presentation/src/orxonox/collisionshapes/CollisionShape.h	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/orxonox/collisionshapes/CollisionShape.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -26,6 +26,12 @@
  *
  */
 
+/**
+    @file CollisionShape.h
+    @brief Definition of the CollisionShape class.
+    @ingroup Collisionshapes
+*/
+
 #ifndef _CollisionShape_H__
 #define _CollisionShape_H__
 
@@ -37,6 +43,17 @@
 
 namespace orxonox
 {
+
+    /**
+    @brief
+        Wrapper for bullet collision shape class btCollisionShape.
+
+    @author
+        Reto Grieder
+
+    @see btCollisionShape
+    @ingroup Collisionshapes
+    */
     class _OrxonoxExport CollisionShape : public BaseObject, public Synchronisable
     {
         public:
@@ -45,52 +62,134 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
+            /**
+            @brief Set the position of the CollisionShape.
+                   If the position changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+            @param position A vector indicating the new position.
+            */
             inline void setPosition(const Vector3& position)
-                { this->position_ = position; this->updateParent(); }
+                { if(this->position_ == position) return; this->position_ = position; this->updateParent(); }
+            /**
+            @brief Get the position of the CollisionShape.
+            @return Returns the position of the CollisionShape as a vector.
+            */
             inline const Vector3& getPosition() const
                 { return this->position_; }
 
+            /**
+            @brief Set the orientation of the CollisionShape.
+                   If the orientation changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+            @param orientation A quaternion indicating the new orientation.
+            */
             inline void setOrientation(const Quaternion& orientation)
-                { this->orientation_ = orientation; this->updateParent(); }
+                { if(this->orientation_ == orientation) return; this->orientation_ = orientation; this->updateParent(); }
+            /**
+            @brief Get the orientation of the CollisionShape.
+            @return Returns the orientation of the CollisionShape as a quaternion.
+            */
             inline const Quaternion& getOrientation() const
                 { return this->orientation_; }
 
-            void yaw(const Degree& angle)   { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Y)); }
-            void pitch(const Degree& angle) { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_X)); }
-            void roll(const Degree& angle)  { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Z)); }
+            /**
+            @brief Rotate the CollisionShape around the y-axis by the specified angle.
+                   If the orientation changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+            @param angle The angle by which the CollisionShape is rotated.
+            */
+            void yaw(const Degree& angle)
+                { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Y)); }
+            /**
+            @brief Rotate the CollisionShape around the x-axis by the specified angle.
+                   If the orientation changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+            @param angle The angle by which the CollisionShape is rotated.
+            */
+            void pitch(const Degree& angle)
+                { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_X)); }
+            /**
+            @brief Rotate the CollisionShape around the z-axis by the specified angle.
+                   If the orientation changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+            @param angle The angle by which the CollisionShape is rotated.
+            */
+            void roll(const Degree& angle)
+                { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Z)); }
 
-            virtual void setScale3D(const Vector3& scale);
-            virtual void setScale(float scale);
+            /**
+            @brief Scale the CollisionShape by the input vector.
+                   Since the scale is a vector the CollisionShape can be scaled independently in each direction, allowing for linear distortions.
+                   If the scale changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+                   Beware, non-uniform scaling (i.e. distortions) might not be supported by all CollisionShapes.
+            @param scale The scaling vector by which the CollisionShape is scaled.
+            */
+            inline void scale3D(const Vector3& scale)
+                { this->setScale3D(this->getScale3D()*scale); }
+            void setScale3D(const Vector3& scale); // Set the scale of the CollisionShape.
+            /**
+            @brief Get the scale of the CollisionShape.
+            @return Returns a vector indicating the scale of the CollisionShape.
+            */
             inline const Vector3& getScale3D() const
                 { return this->scale_; }
 
-            void updateShape();
+            /**
+            @brief (Uniformly) scale the CollisionShape by the input scale.
+                   If the scale changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
+            @param scale The value by which the CollisionShape is scaled.
+            */
+            inline void scale(float scale)
+                { this->setScale3D(this->getScale3D()*scale); }
+            void setScale(float scale); // Set the (uniform) scale of the CollisionShape.
+            /**
+            @brief Get the (uniform) scale of the CollisionShape.
+                   This is only meaningful if the CollisionShape has uniform scaling.
+            @return Returns the (uniform) scale of the CollisionShape. Returns 0.0f if the scaling is non-uniform.
+            */
+            inline float getScale()
+                { if(this->hasUniformScaling()) return this->scale_.x; return 0.0f; }
 
-            void calculateLocalInertia(float mass, btVector3& inertia) const;
+            /**
+            @brief Check whether the CollisionShape is uniformly scaled.
+            @return Returns true if the CollisionShape is uniformly scaled, false if not.
+            */
+            inline bool hasUniformScaling()
+                { return this->uniformScale_; }
+            virtual void changedScale(); // Is called when the scale of the CollisionShape has changed.
 
+            void updateShape(); // Updates the shape.
+
+            void calculateLocalInertia(float mass, btVector3& inertia) const; // Calculates the local inertia of the collision shape.
+
+            /**
+            @brief Get the bullet collision shape of this CollisionShape.
+            @return Returns a pointer to the bullet collision shape of this CollisionShape.
+            */
             inline btCollisionShape* getCollisionShape() const
                 { return this->collisionShape_; }
 
-            bool hasTransform() const;
+            bool hasTransform() const; // Check whether the CollisionShape has been either moved or rotated or both.
 
-            bool notifyBeingAttached(CompoundCollisionShape* newParent);
-            void notifyDetached();
+            bool notifyBeingAttached(CompoundCollisionShape* newParent); // Notifies the CollisionShape of being attached to a CompoundCollisionShape.
+            void notifyDetached(); // Notifies the CollisionShape of being detached from a CompoundCollisionShape.
 
         protected:
-            virtual void updateParent();
-            virtual void parentChanged();
+            virtual void updateParent(); // Updates the CompoundCollisionShape the CollisionShape belongs to, after the CollisionShape has changed.
+            virtual void parentChanged(); // Is called when the parentID of the CollisionShape has changed.
+
+            /**
+            @brief Create a new bullet collision shape depending on the internal parameters of the specific CollisionShape.
+            @return Returns a pointer to the new bullet collision shape.
+            */
             virtual btCollisionShape* createNewShape() const = 0;
 
-            btCollisionShape*       collisionShape_;
-            CompoundCollisionShape* parent_;
-            unsigned int            parentID_;
+            btCollisionShape*       collisionShape_; //!< The bullet collision shape of this CollisionShape.
+            CompoundCollisionShape* parent_; //!< The CompoundCollisionShape this CollisionShape belongs to, NULL if it doesn't belong to one.
+            unsigned int            parentID_; //!< The objectID of the parent of this CollisionShape, which can either be a CompoundCollisionShape or a WorldEntity.
 
         private:
             void registerVariables();
 
-            Vector3                 position_;
-            Quaternion              orientation_;
-            Vector3                 scale_;
+            Vector3                 position_; //!< The position of the CollisionShape.
+            Quaternion              orientation_; //!< The orientation of the CollisionShape.
+            Vector3                 scale_; //!< The scale of the CollisionShape.
+            bool                    uniformScale_; //!< Whether the scale is uniform.
     };
 }
 

Modified: code/branches/presentation/src/orxonox/collisionshapes/CompoundCollisionShape.cc
===================================================================
--- code/branches/presentation/src/orxonox/collisionshapes/CompoundCollisionShape.cc	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/orxonox/collisionshapes/CompoundCollisionShape.cc	2011-05-23 21:40:58 UTC (rev 8556)
@@ -26,6 +26,11 @@
  *
  */
 
+/**
+    @file CompoundCollisionShape.cc
+    @brief Implementation of the CompoundCollisionShape class.
+*/
+
 #include "CompoundCollisionShape.h"
 
 #include <BulletCollision/CollisionShapes/btCompoundShape.h>
@@ -38,6 +43,10 @@
 {
     CreateFactory(CompoundCollisionShape);
 
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
     CompoundCollisionShape::CompoundCollisionShape(BaseObject* creator) : CollisionShape(creator)
     {
         RegisterObject(CompoundCollisionShape);
@@ -45,6 +54,11 @@
         this->compoundShape_  = new btCompoundShape();
     }
 
+    /**
+    @brief
+        Destructor.
+        Deletes all its children.
+    */
     CompoundCollisionShape::~CompoundCollisionShape()
     {
         if (this->isInitialized())
@@ -69,38 +83,56 @@
         XMLPortObject(CompoundCollisionShape, CollisionShape, "", attach, detach, xmlelement, mode);
     }
 
+    /**
+    @brief
+        Attach the input CollisionShape to the CompoundCollisionShape.
+    @param shape
+        A pointer to the CollisionShape that is to be attached.
+    */
     void CompoundCollisionShape::attach(CollisionShape* shape)
     {
+        // If either the input shape is NULL or we try to attach the CollisionShape to itself.
         if (!shape || static_cast<CollisionShape*>(this) == shape)
             return;
+
         if (this->attachedShapes_.find(shape) != this->attachedShapes_.end())
         {
             CCOUT(2) << "Warning: Attaching a CollisionShape twice is not yet supported." << std::endl;
             return;
         }
 
+        // Notify the CollisionShape that it is being attached to the CompoundCollisionShape.
         if (!shape->notifyBeingAttached(this))
             return;
 
+        // Attach it.
         this->attachedShapes_[shape] = shape->getCollisionShape();
 
+        // Only actually attach if we didn't pick a CompoundCollisionShape with no content.
         if (shape->getCollisionShape())
         {
-            // Only actually attach if we didn't pick a CompoundCollisionShape with no content
             btTransform transf(multi_cast<btQuaternion>(shape->getOrientation()), multi_cast<btVector3>(shape->getPosition()));
+            // Add the btCollisionShape of the CollisionShape as a child shape to the btCompoundShape of the CompoundCollisionShape.
             this->compoundShape_->addChildShape(transf, shape->getCollisionShape());
 
             this->updatePublicShape();
         }
     }
 
+    /**
+    @brief
+        Detach the input CollisionShape form the CompoundCollisionShape.
+    @param shape
+        A pointer to the CollisionShape to be detached.
+    */
     void CompoundCollisionShape::detach(CollisionShape* shape)
     {
+        // If the input CollisionShape is actually attached.
         if (this->attachedShapes_.find(shape) != this->attachedShapes_.end())
         {
             this->attachedShapes_.erase(shape);
             if (shape->getCollisionShape())
-                this->compoundShape_->removeChildShape(shape->getCollisionShape());
+                this->compoundShape_->removeChildShape(shape->getCollisionShape()); // TODO: Apparently this is broken?
             shape->notifyDetached();
 
             this->updatePublicShape();
@@ -109,17 +141,30 @@
             CCOUT(2) << "Warning: Cannot detach non child collision shape" << std::endl;
     }
 
+    /**
+    @brief
+        Detach all attached CollisionShapes.
+    */
     void CompoundCollisionShape::detachAll()
     {
         while (this->attachedShapes_.size() > 0)
             this->detach(this->attachedShapes_.begin()->first);
     }
 
+    /**
+    @brief
+        Update the input CollisionShape that is attached to the CompoundCollisionShape.
+        This is called when the input shape's internal collision shape (a btCollisionShape) has changed.
+    @param shape
+        A pointer to the CollisionShape to be updated.
+    */
     void CompoundCollisionShape::updateAttachedShape(CollisionShape* shape)
     {
         if (!shape)
             return;
+
         std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.find(shape);
+        // Check whether the input shape belongs to this CompoundCollisionShape.
         if (it == this->attachedShapes_.end())
         {
             CCOUT(2) << "Warning: Cannot update child shape: Instance not a child." << std::endl;
@@ -128,10 +173,11 @@
 
         // Remove old btCollisionShape, stored in the children map
         if (it->second)
-            this->compoundShape_->removeChildShape(it->second);
+            this->compoundShape_->removeChildShape(it->second); // TODO: Apparently this is broken?
+
+        // Only actually attach if we didn't pick a CompoundCollisionShape with no content
         if (shape->getCollisionShape())
         {
-            // Only actually attach if we didn't pick a CompoundCollisionShape with no content
             btTransform transf(multi_cast<btQuaternion>(shape->getOrientation()), multi_cast<btVector3>(shape->getPosition()));
             this->compoundShape_->addChildShape(transf, shape->getCollisionShape());
             it->second = shape->getCollisionShape();
@@ -140,44 +186,59 @@
         this->updatePublicShape();
     }
 
+    /**
+    @brief
+        Updates the public shape, the collision shape this CompoundCollisionShape has to the outside.
+    */
     void CompoundCollisionShape::updatePublicShape()
     {
-        btCollisionShape* primitive = 0;
-        bool bPrimitive = true;
-        bool bEmpty = true;
+        btCollisionShape* primitive = 0; // The primitive shape, if there is one.
+        bool bPrimitive = true; // Whether the CompoundCollisionShape has just one non-empty CollisionShape. And that shape also has no transformation.
+        bool bEmpty = true; // Whether the CompoundCollisionShape is empty.
+        // Iterate over all CollisionShapes that belong to this CompoundCollisionShape.
         for (std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)
         {
+            // TODO: Make sure this is correct.
             if (it->second)
             {
                 bEmpty = false;
-                if (!it->first->hasTransform() && !bPrimitive)
+                if (!it->first->hasTransform() && bPrimitive)
                     primitive = it->second;
                 else
+                {
                     bPrimitive = false;
+                    break;
+                }
             }
         }
+
+        // If there is no non-empty CollisionShape.
         if (bEmpty)
         {
+            // If there was none all along, nothing needs to be changed.
             if (this->collisionShape_ == 0)
-            {
-                this->collisionShape_ = 0;
                 return;
-            }
             this->collisionShape_ = 0;
         }
+        // If the CompoundCollisionShape is just a primitive.
+        // Only one shape to be added, no transform; return it directly.
         else if (bPrimitive)
-        {
-            // --> Only one shape to be added, no transform; return it directly
             this->collisionShape_ = primitive;
-        }
+        // Make sure we use the compound shape when returning a btCollisionShape.
         else
-        {
-            // Make sure we use the compound shape when returning a btCollisionShape
             this->collisionShape_ = this->compoundShape_;
-        }
+
         this->updateParent();
     }
 
+    /**
+    @brief
+        Get the attached CollisionShape at the given index.
+    @param index
+        The index of the desired CollisionShape.
+    @return
+        Returns a pointer to the attached CollisionShape at the given index.
+    */
     CollisionShape* CompoundCollisionShape::getAttachedShape(unsigned int index) const
     {
         unsigned int i = 0;
@@ -189,4 +250,50 @@
         }
         return 0;
     }
+
+    /**
+    @brief
+        Is called when the scale of the CompoundCollisionShape has changed.
+        Iterates over all attached CollisionShapes and scales them, then recomputes their compound shape.
+    */
+    void CompoundCollisionShape::changedScale()
+    {
+        CollisionShape::changedScale();
+
+        std::vector<CollisionShape*> shapes;
+        // Iterate through all attached CollisionShapes and add them to the list of shapes.
+        for(std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)
+            shapes.push_back(it->first);
+
+        // Delete the compound shape and create a new one.
+        delete this->compoundShape_;
+        this->compoundShape_ = new btCompoundShape();
+
+        // Re-attach all CollisionShapes.
+        for(std::vector<CollisionShape*>::iterator it = shapes.begin(); it != shapes.end(); it++)
+        {
+            CollisionShape* shape = *it;
+            shape->setScale3D(this->getScale3D());
+            // Only actually attach if we didn't pick a CompoundCollisionShape with no content.
+            if (shape->getCollisionShape())
+            {
+                btTransform transf(multi_cast<btQuaternion>(shape->getOrientation()), multi_cast<btVector3>(shape->getPosition()));
+                // Add the btCollisionShape of the CollisionShape as a child shape to the btCompoundShape of the CompoundCollisionShape.
+                this->compoundShape_->addChildShape(transf, shape->getCollisionShape());
+            }
+        }
+
+        this->updatePublicShape();
+
+        /*
+        // Iterate through all attached CollisionShapes
+        for(std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)
+        {
+            // Rescale the CollisionShape.
+            it->first->setScale3D(this->getScale3D());
+            this->updateAttachedShape(it->first);
+        }
+
+        this->updatePublicShape();*/
+    }
 }

Modified: code/branches/presentation/src/orxonox/collisionshapes/CompoundCollisionShape.h
===================================================================
--- code/branches/presentation/src/orxonox/collisionshapes/CompoundCollisionShape.h	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/orxonox/collisionshapes/CompoundCollisionShape.h	2011-05-23 21:40:58 UTC (rev 8556)
@@ -26,6 +26,12 @@
  *
  */
 
+/**
+    @file CompoundCollisionShape.h
+    @brief Definition of the CompoundCollisionShape class.
+    @ingroup Collisionshapes
+*/
+
 #ifndef _CompoundCollisionShape_H__
 #define _CompoundCollisionShape_H__
 
@@ -37,6 +43,17 @@
 
 namespace orxonox
 {
+
+    /**
+    @brief
+        Wrapper for the bullet compound collision shape class btCompoundShape.
+
+    @author
+        Reto Grieder
+
+    @see btCompoundShape
+    @ingroup Collisionshapes
+    */
     class _OrxonoxExport CompoundCollisionShape : public CollisionShape
     {
         public:
@@ -52,6 +69,8 @@
 
             void updateAttachedShape(CollisionShape* shape);
 
+            virtual void changedScale();
+
         private:
             void updatePublicShape();
             inline virtual btCollisionShape* createNewShape() const

Modified: code/branches/presentation/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/WorldEntity.cc	2011-05-23 21:37:17 UTC (rev 8555)
+++ code/branches/presentation/src/orxonox/worldentities/WorldEntity.cc	2011-05-23 21:40:58 UTC (rev 8556)
@@ -641,15 +641,12 @@
     */
     void WorldEntity::setScale3D(const Vector3& scale)
     {
-/*
-HACK HACK HACK
-        if (bScalePhysics && this->hasPhysics() && scale != Vector3::UNIT_SCALE)
+        // If physics is enabled scale the attached CollisionShape.
+        /*if (this->hasPhysics() && this->collisionShape_ != NULL)
         {
-            CCOUT(2) << "Warning: Cannot set the scale of a physical object: Not yet implemented. Ignoring scaling." << std::endl;
-            return;
-        }
-HACK HACK HACK
-*/
+            this->collisionShape_->setScale3D(scale);
+        }*/
+
         this->node_->setScale(scale);
 
         this->changedScale();




More information about the Orxonox-commit mailing list