Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 28, 2008, 1:25:16 AM (16 years ago)
Author:
rgrieder
Message:

Finally managed to work out some physics. According to my tests, collisions with simple spheres should work with dynamic/kinematic/static objects. There are currently only a limited number of XML parameters, but we're surely going to extend that. Furthermore there is some more thinking to be done concerning changes of btRigidBody properties when it's already added to the world.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2087 r2292  
    3030#include "SpaceShip.h"
    3131
     32#include "util/Math.h"
     33#include "util/Exception.h"
    3234#include "core/CoreIncludes.h"
    3335#include "core/ConfigValueIncludes.h"
    3436#include "core/XMLPort.h"
    35 #include "util/Math.h"
    3637
    3738namespace orxonox
     
    5960
    6061        this->setDestroyWhenPlayerLeft(true);
     62
     63        // create a phyisical body
     64        OrxAssert(this->physicalBody_ == 0, " Check why there is already a physical body in the space ship.");
     65        this->createPhysicalBody();
    6166
    6267        this->setConfigValues();
     
    165170    void SpaceShip::moveFrontBack(const Vector2& value)
    166171    {
    167         this->acceleration_.z = -this->translationAcceleration_ * value.x;
     172        assert(this->physicalBody_);
     173        this->physicalBody_->applyCentralForce(btVector3(0.0f, 0.0f, -1.0f/this->physicalBody_->getInvMass() * value.x));
     174//        this->acceleration_.z = -this->translationAcceleration_ * value.x;
    168175    }
    169176
    170177    void SpaceShip::moveRightLeft(const Vector2& value)
    171178    {
    172         this->acceleration_.x = this->translationAcceleration_ * value.x;
     179        this->physicalBody_->applyCentralForce(btVector3(1.0f/this->physicalBody_->getInvMass() * value.x, 0.0f, 0.0f));
     180//        this->acceleration_.x = this->translationAcceleration_ * value.x;
    173181    }
    174182
    175183    void SpaceShip::moveUpDown(const Vector2& value)
    176184    {
    177         this->acceleration_.y = this->translationAcceleration_ * value.x;
     185        this->physicalBody_->applyCentralForce(btVector3(0.0f, 1.0f/this->physicalBody_->getInvMass() * value.x, 0.0f));
     186//        this->acceleration_.y = this->translationAcceleration_ * value.x;
    178187    }
    179188
Note: See TracChangeset for help on using the changeset viewer.