[Orxonox-commit 5338] r10001 - in code/branches/modularships: data/levels src/orxonox/collisionshapes src/orxonox/worldentities/pawns

noep at orxonox.net noep at orxonox.net
Thu Mar 13 15:52:23 CET 2014


Author: noep
Date: 2014-03-13 15:52:23 +0100 (Thu, 13 Mar 2014)
New Revision: 10001

Modified:
   code/branches/modularships/data/levels/emptyLevel.oxw
   code/branches/modularships/src/orxonox/collisionshapes/CollisionShape.h
   code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.h
   code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc
   code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h
Log:
Tried (and failed) to fix output of CollisionShape-structure

Modified: code/branches/modularships/data/levels/emptyLevel.oxw
===================================================================
--- code/branches/modularships/data/levels/emptyLevel.oxw	2014-03-13 12:39:51 UTC (rev 10000)
+++ code/branches/modularships/data/levels/emptyLevel.oxw	2014-03-13 14:52:23 UTC (rev 10001)
@@ -48,26 +48,37 @@
     </collisionShapes> 
     </MovableEntity>
     
-    <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,0" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Box 4" >
+    <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,-100" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Pawn 0" >
         <attached>
-            <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" />
-            <Model position="0,-30,0" mesh="cube.mesh" scale3D="15,15,15" />
-            <StaticEntity position="0,-60,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+            <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
+            <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
+            <StaticEntity position="0,-120,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
                 <attached> 
-                    <Model position="0,0,0" mesh="cube.mesh" scale3D="15,15,15" />
-                    <Model position="0,0,30" mesh="cube.mesh" scale3D="15,15,15" /> 
+                    <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
+                    <Model position="0,0,60" mesh="cube.mesh" scale3D="30,30,30" /> 
                 </attached> 
                 <collisionShapes> 
-                    <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" /> 
-                    <BoxCollisionShape position="0,0,30" halfExtents="15,15,15" /> 
+                    <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" /> 
+                    <BoxCollisionShape position="0,0,60" halfExtents="30,30,30" /> 
                 </collisionShapes> 
             </StaticEntity>
         </attached>
         <collisionShapes>
-            <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" />
-            <BoxCollisionShape position="0,-30,0" halfExtents="15,15,15" />
+            <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+            <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
         </collisionShapes>
     </Pawn>
+
+    <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,100" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Pawn 1" >
+        <attached>
+            <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
+            <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+            <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
+        </collisionShapes>
+    </Pawn>
     
   </Scene>
 </Level>

Modified: code/branches/modularships/src/orxonox/collisionshapes/CollisionShape.h
===================================================================
--- code/branches/modularships/src/orxonox/collisionshapes/CollisionShape.h	2014-03-13 12:39:51 UTC (rev 10000)
+++ code/branches/modularships/src/orxonox/collisionshapes/CollisionShape.h	2014-03-13 14:52:23 UTC (rev 10001)
@@ -169,9 +169,12 @@
             bool notifyBeingAttached(CompoundCollisionShape* newParent); // Notifies the CollisionShape of being attached to a CompoundCollisionShape.
             void notifyDetached(); // Notifies the CollisionShape of being detached from a CompoundCollisionShape.
 
-            inline unsigned int getparentID()
+            inline unsigned int getParentID()
                 { return this->parentID_; }
 
+            inline CompoundCollisionShape* getParent()
+                { return this->parent_; }
+
         protected:
             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.

Modified: code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.h
===================================================================
--- code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.h	2014-03-13 12:39:51 UTC (rev 10000)
+++ code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.h	2014-03-13 14:52:23 UTC (rev 10001)
@@ -72,6 +72,11 @@
             virtual void changedScale();
             int getNumChildShapes();
 
+            inline std::map<CollisionShape*, btCollisionShape*> getShapesMap()
+            {
+                return attachedShapes_;
+            }
+
         private:
             void updatePublicShape();
             inline virtual btCollisionShape* createNewShape() const

Modified: code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc	2014-03-13 12:39:51 UTC (rev 10000)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc	2014-03-13 14:52:23 UTC (rev 10001)
@@ -50,6 +50,7 @@
 #include "controllers/FormationController.h"
 
 #include "collisionshapes/WorldEntityCollisionShape.h"
+#include <BulletCollision/CollisionShapes/btCollisionShape.h>
 
 namespace orxonox
 {
@@ -277,6 +278,8 @@
 
     void Pawn::customDamage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
     {
+        orxout() << "damage(): Collision detected on " << this->getRadarName() << ", btCS*: " << cs << endl;
+
         int collisionShapeIndex = this->isMyCollisionShape(cs);
         orxout() << collisionShapeIndex << endl;
 
@@ -284,8 +287,6 @@
         if (originator)
             damage *= originator->getDamageMultiplier();
 
-        orxout() << "damage(): Custom collision detected on " << this->getRadarName() << ", CS: " << cs << endl;
-
         if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
         {
             if (shielddamage >= this->getShieldHealth())
@@ -623,15 +624,19 @@
         WorldEntityCollisionShape* ownWECS = this->getWorldEntityCollisionShape();
 
         // e.g. "Box 4: Searching for CS 0x1ad49200"
-        orxout() << this->getRadarName() << ": Searching for CS " << cs << endl;
+        orxout() << this->getRadarName() << ": Searching for btCS* " << cs << endl;
         // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060"
-        orxout() << "  " << this->getRadarName() << " is WorldEntityCollisionShape " << ownWECS << endl;
+        orxout() << "  " << this->getRadarName() << " is WorldEntityCollisionShape* " << ownWECS << endl;
+        // e.g. "Box 4 is btCollisionShape 0x126dd060"
+        orxout() << "  " << this->getRadarName() << " is btCollisionShape* " << ownWECS->getCollisionShape() << endl;
         // e.g. "Box 4 is objectID 943"
         orxout() << "  " << this->getRadarName() << " is objectID " << this->getObjectID() << endl;
 
         // print child shapes of this WECS
-        printChildShapes(ownWECS, 2, 0);
+        // printChildShapes(ownWECS, 2, 0);
+        printChildShapeMap(ownWECS->getShapesMap());
 
+
         // end
         orxout() << "  " << this->getRadarName() << ": no matching CS found." << endl;
         return -1;
@@ -639,29 +644,69 @@
 
     void Pawn::printChildShapes(CompoundCollisionShape* cs, int indent, int subshape)
     {
+        for (int i=0; i < cs->getNumChildShapes(); i++)
+        {
+            orxout() << "" << endl;
+        }
+        /*
         // e.g. "  Childshape 1 (WECS 0x126dc8c0) has 2 childshapes:"
-        printSpaces(indent);  orxout() << "Childshape " << subshape << " (WECS " << cs << ") has " << cs->getNumChildShapes() << " childshapes:" << endl;
+        printSpaces(indent);  orxout() << "Childshape " << subshape << " (CS* " << cs << ") has " << cs->getNumChildShapes() << " childshapes:" << endl;
 
+        // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060"
+        printSpaces(indent);  orxout() << "Childshape " << subshape << " is btCollisionShape* " << cs->getCollisionShape() << endl;
+
         for (int i=0; i < cs->getNumChildShapes(); i++)
         {
+            printSpaces(indent+2);  orxout() << "- " << i << " - - -" << endl;
+            printSpaces(indent+2);  orxout() << "This Shape is a ";
+            if (orxonox_cast<WorldEntityCollisionShape*>(cs->getAttachedShape(i)))
+                orxout() << "WECS ";
+            if (orxonox_cast<CompoundCollisionShape*>(cs->getAttachedShape(i)))
+                orxout() << "CCS ";
+            if (orxonox_cast<CollisionShape*>(cs->getAttachedShape(i)))
+                orxout() << "CS ";
+            orxout() << endl;
+
             // For each childshape, print:
+
+            // parentID of the CollisionShape
+            printSpaces(indent+2);  orxout() << "ParentID: " << cs->getAttachedShape(i)->getObjectID() << endl;
+
+            // parentID of the CollisionShape
+            printSpaces(indent+2);  orxout() << "ParentID: " << cs->getAttachedShape(i)->getParentID() << endl;
+
+            // parent of the CollisionShape
+            printSpaces(indent+2);  orxout() << "ParentCCS*: " << cs->getAttachedShape(i)->getParent() << endl;
+
             // pointer to the btCollisionShape
-            printSpaces(indent+2);  orxout() << "Bt-Childshape " << i << ": " << cs->getAttachedShape(i)->getCollisionShape() << endl;
+            printSpaces(indent+2);  orxout() << "btCollisionShape*: " << cs->getAttachedShape(i)->getCollisionShape() << endl;
 
             // pointer to the CollisionShape
-            printSpaces(indent+2);  orxout() << "Orx-Childshape " << i << ": " << cs->getAttachedShape(i) << endl;
+            printSpaces(indent+2);  orxout() << "CollisionShape*: " << cs->getAttachedShape(i) << endl;
 
-            // parentID of the CollisionShape
-            printSpaces(indent+2);  orxout() << "ParentID of CS " << i << ": " << cs->getAttachedShape(i)->getparentID() << endl;
+            if (cs->getAttachedShape(i)->getCollisionShape() != NULL)
+            {
+                // pointer to the user of the btCollisionShape
+                printSpaces(indent+2);  orxout() << "bt: getUserPointer: " << cs->getAttachedShape(i)->getCollisionShape()->getUserPointer() << endl;
 
+                //
+                printSpaces(indent+2);  orxout() << "bt: isCompound: " << cs->getAttachedShape(i)->getCollisionShape()->isCompound() << endl;
+            }
+
             // if the childshape is a CompoundCollisionShape, print its children.
             if (orxonox_cast<CompoundCollisionShape*>(cs->getAttachedShape(i)))
             {
                 printChildShapes((CompoundCollisionShape*)(cs->getAttachedShape(i)), indent+2, i);
             }
+            */
         }
     }
 
+    void Pawn::printChildShapeMap(std::map<CollisionShape*, btCollisionShape*> map)
+    {
+        orxout() << endl;
+    }
+
     void Pawn::printSpaces(int number)
     {
         for(int i=0; i<number; i++)

Modified: code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h	2014-03-13 12:39:51 UTC (rev 10000)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h	2014-03-13 14:52:23 UTC (rev 10001)
@@ -234,6 +234,7 @@
             virtual int isMyCollisionShape(const btCollisionShape* cs);
             void printChildShapes(CompoundCollisionShape* cs, int indent, int subshape);
             void printSpaces(int num);
+            void printChildShapeMap(std::map<CollisionShape*, btCollisionShape*> map);
 
         private:
             void registerVariables();




More information about the Orxonox-commit mailing list