Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 27, 2014, 3:49:50 PM (11 years ago)
Author:
noep
Message:

More research done on collisionshape-entity-structure, and started cleaning up the debug-output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc

    r10003 r10007  
    5353#include <BulletCollision/CollisionShapes/btCollisionShape.h>
    5454#include <BulletCollision/CollisionShapes/btCompoundShape.h>
     55#include "graphics/Model.h"
    5556
    5657
     
    638639        orxout() << "  " << this->getRadarName() << " has the following Objects attached:" << endl;
    639640        for (int i=0; i<10; i++)
    640             orxout() << " " << i << ": " << this->getAttachedObject(i) << endl;
     641        {
     642            if (this->getAttachedObject(i)==NULL)
     643                break;
     644            orxout() << " " << i << ": " << this->getAttachedObject(i);
     645            if(!orxonox_cast<Model*>(this->getAttachedObject(i)))
     646                orxout() << " (SE)";
     647            orxout() << endl;
     648        }
     649
     650        if (this->health_ < 800)
     651            this->detach(this->getAttachedObject(2));
    641652
    642653        // print child shapes of this WECS
    643         // printChildShapes(ownWECS, 2, 0);
    644654        printBtChildShapes((btCompoundShape*)(ownWECS->getCollisionShape()), 2, 0);
    645655
     656        int temp = entityOfCollisionShape(cs);
     657        if (temp==0)
     658            orxout() << this->getRadarName() << " has been hit on it's main body." << endl;
     659        else
     660            orxout() << this->getRadarName() << " has been hit on the attached entity no. " << temp << endl;
    646661
    647662        // end
    648         orxout() << "  " << this->getRadarName() << ": no matching CS found." << endl;
    649663        return -1;
    650     }
    651 
    652     void Pawn::printChildShapes(CompoundCollisionShape* cs, int indent, int subshape)
    653     {
    654         for (int i=0; i < cs->getNumChildShapes(); i++)
    655         {
    656             orxout() << "" << endl;
    657         }
    658         /*
    659         // e.g. "  Childshape 1 (WECS 0x126dc8c0) has 2 childshapes:"
    660         printSpaces(indent);  orxout() << "Childshape " << subshape << " (CS* " << cs << ") has " << cs->getNumChildShapes() << " childshapes:" << endl;
    661 
    662         // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060"
    663         printSpaces(indent);  orxout() << "Childshape " << subshape << " is btCollisionShape* " << cs->getCollisionShape() << endl;
    664 
    665         for (int i=0; i < cs->getNumChildShapes(); i++)
    666         {
    667             printSpaces(indent+2);  orxout() << "- " << i << " - - -" << endl;
    668             printSpaces(indent+2);  orxout() << "This Shape is a ";
    669             if (orxonox_cast<WorldEntityCollisionShape*>(cs->getAttachedShape(i)))
    670                 orxout() << "WECS ";
    671             if (orxonox_cast<CompoundCollisionShape*>(cs->getAttachedShape(i)))
    672                 orxout() << "CCS ";
    673             if (orxonox_cast<CollisionShape*>(cs->getAttachedShape(i)))
    674                 orxout() << "CS ";
    675             orxout() << endl;
    676 
    677             // For each childshape, print:
    678 
    679             // parentID of the CollisionShape
    680             printSpaces(indent+2);  orxout() << "ParentID: " << cs->getAttachedShape(i)->getObjectID() << endl;
    681 
    682             // parentID of the CollisionShape
    683             printSpaces(indent+2);  orxout() << "ParentID: " << cs->getAttachedShape(i)->getParentID() << endl;
    684 
    685             // parent of the CollisionShape
    686             printSpaces(indent+2);  orxout() << "ParentCCS*: " << cs->getAttachedShape(i)->getParent() << endl;
    687 
    688             // pointer to the btCollisionShape
    689             printSpaces(indent+2);  orxout() << "btCollisionShape*: " << cs->getAttachedShape(i)->getCollisionShape() << endl;
    690 
    691             // pointer to the CollisionShape
    692             printSpaces(indent+2);  orxout() << "CollisionShape*: " << cs->getAttachedShape(i) << endl;
    693 
    694             if (cs->getAttachedShape(i)->getCollisionShape() != NULL)
    695             {
    696                 // pointer to the user of the btCollisionShape
    697                 printSpaces(indent+2);  orxout() << "bt: getUserPointer: " << cs->getAttachedShape(i)->getCollisionShape()->getUserPointer() << endl;
    698 
    699                 //
    700                 printSpaces(indent+2);  orxout() << "bt: isCompound: " << cs->getAttachedShape(i)->getCollisionShape()->isCompound() << endl;
    701             }
    702 
    703             // if the childshape is a CompoundCollisionShape, print its children.
    704             if (orxonox_cast<CompoundCollisionShape*>(cs->getAttachedShape(i)))
    705             {
    706                 printChildShapes((CompoundCollisionShape*)(cs->getAttachedShape(i)), indent+2, i);
    707             }
    708 
    709         }*/
    710664    }
    711665
     
    736690    }
    737691
     692    int Pawn::entityOfCollisionShape(const btCollisionShape* cs)
     693    {
     694        btCompoundShape* ownBtCS = (btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape());
     695
     696        return -1;
     697    }
     698
    738699    void Pawn::printSpaces(int num)
    739700    {
Note: See TracChangeset for help on using the changeset viewer.