Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 22, 2014, 2:49:16 PM (11 years ago)
Author:
smerkli
Message:

Merged modularships branch

Location:
code/branches/presentationFS14
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentationFS14

  • code/branches/presentationFS14/src/orxonox/worldentities/pawns/CMakeLists.txt

    r7163 r10073  
    44  Pawn.cc
    55  SpaceShip.cc
     6  ModularSpaceShip.cc
    67  TeamBaseMatchBase.cc
    78  Destroyer.cc
  • code/branches/presentationFS14/src/orxonox/worldentities/pawns/Pawn.cc

    r9950 r10073  
    5050#include "controllers/FormationController.h"
    5151
     52#include "collisionshapes/WorldEntityCollisionShape.h"
     53#include <BulletCollision/CollisionShapes/btCollisionShape.h>
     54#include <BulletCollision/CollisionShapes/btCompoundShape.h>
     55#include "graphics/Model.h"
     56
     57
    5258namespace orxonox
    5359{
     
    244250    }
    245251
    246     void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
    247     {
     252    void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
     253    {
     254        //FIXME: (noep) remove debug
     255        //orxout() << "damage(): Collision detected on " << this->getName() << ", btCS*: " << cs << endl;
     256
     257        //int collisionShapeIndex = this->isMyCollisionShape(cs);
     258        //orxout() << collisionShapeIndex << endl;
     259
    248260        // Applies multiplier given by the DamageBoost Pickup.
    249261        if (originator)
     
    279291
    280292*/
    281     void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage)
     293    void Pawn::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)
    282294    {
    283295        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    284296        {
    285             this->damage(damage, healthdamage, shielddamage, originator);
     297            this->damage(damage, healthdamage, shielddamage, originator, cs);
    286298            this->setVelocity(this->getVelocity() + force);
    287299        }
    288300    }
    289301
    290 
    291     void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage)
     302    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)
    292303    {
    293304        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    294305        {
    295             this->damage(damage, healthdamage, shielddamage, originator);
     306            this->damage(damage, healthdamage, shielddamage, originator, cs);
    296307
    297308            if ( this->getController() )
     
    561572
    562573
     574    int Pawn::isMyCollisionShape(const btCollisionShape* cs)
     575    {
     576        // This entities WECS
     577        WorldEntityCollisionShape* ownWECS = this->getWorldEntityCollisionShape();
     578
     579        // e.g. "Box 4: Searching for CS 0x1ad49200"
     580        orxout() << this->getName() << ": Searching for btCS* " << cs << endl;
     581        // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060"
     582        orxout() << "  " << this->getName() << " is WorldEntityCollisionShape* " << ownWECS << endl;
     583        // e.g. "Box 4 is WorldEntity 0x126dd060"
     584        orxout() << "  " << this->getName() << " is WorldEntity* " << this << endl;
     585        // e.g. "Box 4 is objectID 943"
     586        orxout() << "  " << this->getName() << " is objectID " << this->getObjectID() << endl;
     587
     588        // List all attached Objects
     589        orxout() << "  " << this->getName() << " has the following Objects attached:" << endl;
     590        for (int i=0; i<50; i++)
     591        {
     592            if (this->getAttachedObject(i)==NULL)
     593                break;
     594            orxout() << " " << i << ": " << this->getAttachedObject(i) << " (" << this->getAttachedObject(i)->getName() << ")";
     595            if(!orxonox_cast<Model*>(this->getAttachedObject(i)))
     596                orxout() << " (SE)";
     597            orxout() << endl;
     598        }
     599
     600
     601        // print child shapes of this WECS
     602        printBtChildShapes((btCompoundShape*)(ownWECS->getCollisionShape()), 2, 0);
     603
     604        int temp = entityOfCollisionShape(cs);
     605        if (temp==0)
     606            orxout() << this->getName() << " has been hit on it's main body." << endl;
     607        else
     608            orxout() << this->getName() << " has been hit on the attached entity no. " << temp << endl;
     609
     610        // end
     611        return -1;
     612    }
     613
     614    void Pawn::printBtChildShapes(btCompoundShape* cs, int indent, int subshape)
     615    {
     616        // e.g. "  Childshape 1 (WECS 0x126dc8c0) has 2 childshapes:"
     617        printSpaces(indent);  orxout() << "Childshape " << subshape << " (btCS* " << cs << ") has " << cs->getNumChildShapes() << " childshapes:" << endl;
     618
     619        for (int i=0; i < cs->getNumChildShapes(); i++)
     620        {
     621            printSpaces(indent+2);  orxout() << "- " << i << " - - -" << endl;
     622
     623            // For each childshape, print: (as long as it's not another CompoundCollisionShape)
     624            if (!orxonox_cast<btCompoundShape*>(cs->getChildShape(i)))
     625            {
     626                // pointer to the btCollisionShape
     627                printSpaces(indent+2);  orxout() << "btCollisionShape*: " << cs->getChildShape(i) << endl;
     628
     629                // pointer to the btCollisionShape
     630                printSpaces(indent+2);  orxout() << "m_userPointer*: " << cs->getChildShape(i)->getUserPointer() << " (name_: " << ((BaseObject*)(cs->getChildShape(i)->getUserPointer()))->getName() << ")" << endl;
     631            }
     632
     633            // if the childshape is a CompoundCollisionShape, print its children.
     634            if (cs->getChildShape(i)->isCompound())
     635                printBtChildShapes((btCompoundShape*)(cs->getChildShape(i)), indent+2, i);
     636
     637        }
     638    }
     639
     640    int Pawn::entityOfCollisionShape(const btCollisionShape* cs)
     641    {
     642        btCompoundShape* ownBtCS = (btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape());
     643
     644        return -1;
     645    }
     646
     647    void Pawn::printSpaces(int num)
     648    {
     649        for(int i=0; i<num; i++)
     650            orxout() << " ";
     651    }
    563652}
  • code/branches/presentationFS14/src/orxonox/worldentities/pawns/Pawn.h

    r9948 r10073  
    126126            //virtual void hit(Pawn* originator, const Vector3& force, float damage);
    127127            //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
    128             virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
    129             virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
     128            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
     129            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
    130130
    131131            virtual void kill();
     
    196196
    197197            //virtual void damage(float damage, Pawn* originator = 0);
    198             virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL);
     198            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
    199199
    200200            bool bAlive_;
     
    229229            unsigned int numexplosionchunks_;
    230230
     231            virtual int isMyCollisionShape(const btCollisionShape* cs); // FIXME: (noep) remove debug
     232            void printBtChildShapes(btCompoundShape* cs, int indent, int subshape); // FIXME: (noep) remove debug
     233            void printSpaces(int num);   // FIXME: (noep) remove debug
     234            int entityOfCollisionShape(const btCollisionShape* cs);
     235
    231236        private:
    232237            void registerVariables();
  • code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.h

    r9667 r10073  
    270270            float stallSpeed_; //!< The forward speed where no more lift is added.
    271271
     272            std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.
     273
    272274        private:
    273275            void registerVariables();
     
    284286            void backupCamera(); // Save the original position and orientation of the camera.
    285287            void resetCamera(); // Reset the camera to its original position.
    286 
    287             std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.
    288288
    289289            Timer timer_;                          //!< Timer for the cooldown duration.
Note: See TracChangeset for help on using the changeset viewer.