Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 18, 2019, 4:04:33 PM (5 years ago)
Author:
pomselj
Message:

oxw file cleaned up

File:
1 edited

Legend:

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

    r12308 r12310  
    3333
    3434#include "OrxoBloxBall.h"
     35#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
    3536
    3637#include "core/CoreIncludes.h"
     
    260261        return BLANKSTRING;
    261262    }
     263
     264
     265    void OrxoBloxBall::Bounce(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
     266
     267        Vector3 velocity = this->getVelocity();
     268        Vector3 myPosition = otherObject->getPosition();
     269        btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();
     270        orxout() << "About to Bounce >D" << endl;
     271        //if (positionOtherObject.y < 0) {
     272            //this.destroy()
     273        //}S
     274        //else {
     275       
     276            int distance_X = positionOtherObject.getX() - myPosition.x;
     277            int distance_Z = positionOtherObject.getZ() - myPosition.z;
     278
     279            if (distance_X < 0)
     280                distance_X = -distance_X;
     281   
     282
     283            if (distance_Z < 0)
     284                distance_Z = -distance_Z;
     285
     286            orxout() << distance_X << endl;
     287            orxout() << distance_Z << endl;
     288
     289            if (distance_X < distance_Z) {
     290                velocity.z = -velocity.z;
     291                orxout() << "z" << endl;
     292            }
     293            if (distance_Z < distance_X) {
     294                velocity.x = -velocity.x;
     295                orxout() << "x" << endl;
     296            }
     297            else {
     298                velocity.x = -velocity.x;
     299                velocity.z = -velocity.z;
     300                orxout() << "both" << endl;
     301            }
     302            this->setVelocity(velocity);
     303        //}
     304    }
     305
     306
     307    bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     308    {
     309        orxout() << "About to Bounce >D" << endl;
     310        bool result = MovableEntity::collidesAgainst(otherObject, ownCollisionShape, contactPoint);
     311        Bounce(otherObject, ownCollisionShape, contactPoint);
     312        return result;
     313    }
     314
     315
    262316}
Note: See TracChangeset for help on using the changeset viewer.