Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2019, 11:36:28 AM (6 years ago)
Author:
pomselj
Message:

Worked on Collision, doesn't work yet, compiles tho

Location:
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12345 r12346  
    147147
    148148            // Create the first Wall.
    149             this->LevelUp();
     149            this->createWall();
    150150
    151151            //Create Ship
     
    213213        this->createWall();
    214214        this->activeWalls_.push_back(this->futureWall_);
     215        for (int i = 0; i < this->futureWall_->getNumberOfStones(); i++)
     216            this->stones_.push_back(this->futureWall_->getStone(i));
    215217        //new location of ship
    216218        //new amount of balls
    217219        //create balls
    218220        //insert new wall
    219 
    220221    }
    221222
     
    243244    }
    244245
    245    
     246    OrxoBloxStones* OrxoBlox::CheckForCollision(OrxoBloxBall* Ball) {
     247
     248        orxout() << "Checking for Collision" << endl;
     249        Vector3 BallPosition = Ball->getPosition();
     250        for(OrxoBloxStones* someStone : this->stones_)
     251        {
     252            orxout() << "Checking a stone" << endl;
     253            const Vector3& StonePosition = someStone->getPosition(); //!< Saves the position of the currentStone
     254            int size = someStone->getSize();
     255            if((BallPosition.x >= StonePosition.x - size && BallPosition.x <= StonePosition.x + size) ||
     256                (BallPosition.z >= StonePosition.z - size && BallPosition.z <= StonePosition.z + size)) {
     257                orxout() << "FOUND ONE" << endl;
     258                return someStone;
     259            }
     260        }
     261        orxout() << "Found nothing...." << endl;
     262        return nullptr;
     263    }
    246264   
    247265}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h

    r12343 r12346  
    8787            OrxoBloxCenterpoint* getCenterpoint(void)
    8888                { return this->center_; }
     89            OrxoBloxStones* CheckForCollision(OrxoBloxBall* Ball);
    8990
    9091        protected:
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc

    r12344 r12346  
    5555    */
    5656    OrxoBloxBall::OrxoBloxBall(Context* context)
    57         : MovableEntity(context)
     57        : Pawn(context)
    5858    {
    5959        RegisterObject(OrxoBloxBall);
     
    6363        this->bDeleteBats_ = false;
    6464        this->relMercyOffset_ = 0.05f;
     65        this->orxoblox_ = this->getOrxoBlox();
    6566
    6667        this->registerVariables();
     
    206207        if (position != this->getPosition())
    207208            this->setPosition(position);
     209        this->Collides((this->orxoblox_->CheckForCollision(this)));
     210
     211 
    208212    }
    209213
     
    287291
    288292
    289     void OrxoBloxBall::Bounce(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
     293    void OrxoBloxBall::Bounce(OrxoBloxStones* otherObject) {
    290294
    291295        Vector3 velocity = this->getVelocity();
    292         Vector3 myPosition = otherObject->getPosition();
    293         btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();
     296        Vector3 positionOtherObject = otherObject->getPosition();
     297        Vector3 myPosition = this->getPosition();
    294298        orxout() << "About to Bounce >D" << endl;
    295299        //if (positionOtherObject.y < 0) {
     
    298302        //else {
    299303       
    300             int distance_X = positionOtherObject.getX() - myPosition.x;
    301             int distance_Z = positionOtherObject.getZ() - myPosition.z;
     304            int distance_X = myPosition.x - positionOtherObject.x;
     305            int distance_Z = myPosition.z - positionOtherObject.z;
    302306
    303307            if (distance_X < 0)
     
    325329            }
    326330            this->setVelocity(velocity);
    327         //}
    328     }
    329 
    330 
    331     bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
    332     {
     331    }
     332
     333
     334    void OrxoBloxBall::Collides(OrxoBloxStones* otherObject)
     335    {
     336
     337        if(otherObject == nullptr)
     338            return;
     339
    333340        orxout() << "About to Bounce >D" << endl;
    334         bool result = MovableEntity::collidesAgainst(otherObject, ownCollisionShape, contactPoint);
    335         Bounce(otherObject, ownCollisionShape, contactPoint);
    336         return result;
     341        Bounce(otherObject);
     342    }
     343
     344    OrxoBlox* OrxoBloxBall::getOrxoBlox()
     345    {
     346        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
     347        {
     348            OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
     349            return orxobloxGametype;
     350        }
     351        else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
     352        return nullptr;
    337353    }
    338354
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h

    r12337 r12346  
    4040#include "util/Math.h"
    4141
    42 #include "worldentities/MovableEntity.h"
     42#include "worldentities/pawns/Pawn.h"
    4343#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
    4444
     
    5858    @ingroup OrxoBlox
    5959    */
    60     class _OrxoBloxExport OrxoBloxBall : public MovableEntity
     60    class _OrxoBloxExport OrxoBloxBall : public Pawn
    6161    {
    6262        public:
     
    123123
    124124
    125             void Bounce(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint);
    126            
    127             virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
     125            void Bounce(OrxoBloxStones* otherObject);
     126            void Collides(OrxoBloxStones* otherObject);
    128127
    129128            static const float MAX_REL_Z_VELOCITY;
     
    139138            void registerVariables();
    140139
     140            OrxoBlox* getOrxoBlox();
    141141            float fieldWidth_; //!< The width of the playing field.
    142142            float fieldHeight_; //!< The height of the playing field.
     
    150150            WorldSound* defBatSound_;
    151151            WorldSound* defBoundarySound_;
     152            OrxoBlox* orxoblox_;
    152153    };
    153154}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc

    r12341 r12346  
    8989        return nullptr;
    9090    }
     91
     92    int OrxoBloxWall::getNumberOfStones() {
     93        return num_Stones_;
     94    }
    9195}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h

    r12341 r12346  
    4242            void setGame(OrxoBlox* orxoblox)
    4343                { assert(orxoblox); orxoblox_ = orxoblox; }
     44            int getNumberOfStones();
    4445        private:
    4546            void createWall(void);
Note: See TracChangeset for help on using the changeset viewer.