Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2178


Ignore:
Timestamp:
Nov 11, 2008, 10:30:49 PM (15 years ago)
Author:
rgrieder
Message:
  • Added first basic construct of object hierarchy with physics.
  • Added a few bullet classes to OrxonoxPrereqs.h
  • Added bullet header files to the msvc projects.

No Implementation at all yet, but the game still compiles and runs. Please update the media repository.

Location:
code/branches/physics
Files:
2 added
4 deleted
15 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/OrxonoxPrereqs.h

    r2151 r2178  
    203203}
    204204
     205// Bullet Physics Engine
     206
     207class btRigidBody;
     208class btCollisionObject;
     209class btGhostObject;
     210class btCollisionShape;
     211class btSphereShape;
     212
     213
    205214struct lua_State;
    206215
  • code/branches/physics/src/orxonox/OrxonoxStableHeaders.h

    r2087 r2178  
    4848#include <CEGUI.h>
    4949#include "ois/OIS.h"
     50//#include "btBulletCollisionCommon.h"
     51//#include "btBulletDynamicsCommon.h"
    5052#include <boost/thread/recursive_mutex.hpp>
    5153//#include <boost/thread/mutex.hpp>
     
    9799#include "network/Synchronisable.h"
    98100
    99 #include "Settings.h"
     101//#include "Settings.h"
    100102
    101103//#endif /* ifdef NDEBUG */
  • code/branches/physics/src/orxonox/objects/HelloBullet.cc

    r2177 r2178  
    3434#include <OgreEntity.h>
    3535
    36 // #include "ogreode/OgreOde_Core.h"
    37 // #include "ogreode/OgreOdeGeometry.h"
    3836#include "util/Convert.h"
    3937#include "core/CoreIncludes.h"
     
    5250        : BaseObject(creator)
    5351    {
    54            RegisterObject(HelloBullet);
    55            COUT(0) << "HelloBullet loaded" << std::endl ;
    56            int maxProxies = 1024;
     52        RegisterObject(HelloBullet);
     53        COUT(0) << "HelloBullet loaded" << std::endl ;
     54        int maxProxies = 1024;
    5755
    5856
     
    6866  //      dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
    6967
    70         dynamicsWorld =  creator->getScene()->getPhysicalWorld();
    71         dynamicsWorld-> setGravity(btVector3(0,-10,0));
     68        dynamicsWorld = getCreator()->getScene()->getPhysicalWorld();
    7269
    7370
     
    9491
    9592 
    96 
    97 //load floor mash
     93        //load floor mash
    9894        Ogre::SceneManager* sceneMgr = creator->getScene()->getSceneManager();
    9995
     
    119115
    120116
    121 // crate
     117        // crate
    122118
    123119        entity_ = sceneMgr->createEntity("crate","crate.mesh");
     
    127123        entity_->setNormaliseNormals(true);
    128124        entity_->setCastShadows(true);
    129         sceneNode_ -> setPosition(Vector3(0,100,0));
    130 
    131 
    132      
    133 
    134 
     125        sceneNode_ -> setPosition(Vector3(0,100,0));
    135126    }
    136127
     
    181172    void HelloBullet::tick(float dt)
    182173    {
    183                 dynamicsWorld->stepSimulation(dt,10);
    184                 btTransform trans;
    185                 fallRigidBody->getMotionState()->getWorldTransform(trans);
    186                // COUT(0) << "sphere height: " << trans.getOrigin().getY() << std::endl;
    187                 sceneNode_ -> setPosition(Vector3(0,trans.getOrigin().getY(),0));
    188         //      msleep(20);
    189                
    190                
     174        dynamicsWorld->stepSimulation(dt,10);
     175        btTransform trans;
     176        fallRigidBody->getMotionState()->getWorldTransform(trans);
     177        // COUT(0) << "sphere height: " << trans.getOrigin().getY() << std::endl;
     178        sceneNode_ -> setPosition(Vector3(0,trans.getOrigin().getY(),0));
     179        //      msleep(20);
    191180    }
    192 
    193181}
  • code/branches/physics/src/orxonox/objects/HelloBullet.h

    r2124 r2178  
    3333#include "core/BaseObject.h"
    3434
    35 #include "ogrebullet/Dynamics/OgreBulletDynamics.h"
     35#include "btBulletCollisionCommon.h"
     36#include "btBulletDynamicsCommon.h"
    3637
    3738#include "Tickable.h"
  • code/branches/physics/src/orxonox/objects/Scene.cc

    r2150 r2178  
    6262                this->rootSceneNode_ = 0;
    6363            }
    64         // create bullet world; bullet solver etc.
     64        }
     65        else
     66        {
     67            // create a dummy SceneManager of our own since we don't have Ogre::Root.
     68            this->sceneManager_ = new Ogre::DefaultSceneManager("");
     69            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
     70        }
     71
     72        /////////////
     73        // Physics //
     74        /////////////
     75
     76        // create bullet world; bullet solver etc.
    6577
    6678        // int maxProxies = 1024;
     
    7082        bt32BitAxisSweep3* broadphase = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax);
    7183
    72         this -> collisionConfiguration_ = new btDefaultCollisionConfiguration();
     84        this -> collisionConfiguration_ = new btDefaultCollisionConfiguration();
    7385        this -> dispatcher_ = new btCollisionDispatcher(collisionConfiguration_);
    7486
     
    7789        this -> dynamicsWorld_ =  new btDiscreteDynamicsWorld(dispatcher_,broadphase,solver_,collisionConfiguration_);
    7890
    79       //  dynamicsWorld->setGravity(btVector3(0,-10,0));
     91        dynamicsWorld_->setGravity(btVector3(0,-10,0));
    8092
    81         }
    82         else
    83         {
    84             // create a dummy SceneManager of our own since we don't have Ogre::Root.
    85             this->sceneManager_ = new Ogre::DefaultSceneManager("");
    86             this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
    87         }
    8893
    8994        // test test test
     
    108113            if (Ogre::Root::getSingletonPtr())
    109114            {
    110 //                this->sceneManager_->destroySceneNode(this->rootSceneNode_->getName()); // TODO: remove getName() for newer versions of Ogre
    111115                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    112116            }
  • code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2087 r2178  
    4444    CreateFactory(ControllableEntity);
    4545
    46     ControllableEntity::ControllableEntity(BaseObject* creator) : WorldEntity(creator)
     46    ControllableEntity::ControllableEntity(BaseObject* creator) : MovableEntity(creator)
    4747    {
    4848        RegisterObject(ControllableEntity);
  • code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h

    r2087 r2178  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "WorldEntity.h"
     34#include "MovableEntity.h"
    3535#include "objects/Tickable.h"
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport ControllableEntity : public WorldEntity, public Tickable
     39    class _OrxonoxExport ControllableEntity : public MovableEntity, public Tickable
    4040    {
    4141        public:
  • code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.cc

    r2087 r2178  
    3232#include "core/CoreIncludes.h"
    3333#include "core/XMLPort.h"
    34 #include "core/Executor.h"
    35 #include "tools/Timer.h"
    3634
    3735namespace orxonox
    3836{
    39     static const float MAX_RESYNCHRONIZE_TIME = 3.0f;
    40 
    41     CreateFactory(MovableEntity);
    42 
    4337    MovableEntity::MovableEntity(BaseObject* creator) : WorldEntity(creator)
    4438    {
    4539        RegisterObject(MovableEntity);
    46 
    47         this->velocity_ = Vector3::ZERO;
    48         this->acceleration_ = Vector3::ZERO;
    49         this->rotationAxis_ = Vector3::ZERO;
    50         this->rotationRate_ = 0;
    51         this->momentum_ = 0;
    52 
    53         this->overwrite_position_ = Vector3::ZERO;
    54         this->overwrite_orientation_ = Quaternion::IDENTITY;
    5540
    5641        this->registerVariables();
     
    6449    {
    6550        SUPER(MovableEntity, XMLPort, xmlelement, mode);
    66 
    67         XMLPortParamTemplate(MovableEntity, "velocity", setVelocity, getVelocity, xmlelement, mode, const Vector3&);
    68         XMLPortParamTemplate(MovableEntity, "rotationaxis", setRotationAxis, getRotationAxis, xmlelement, mode, const Vector3&);
    69         XMLPortParamTemplate(MovableEntity, "rotationrate", setRotationRate, getRotationRate, xmlelement, mode, const Degree&);
    70     }
    71 
    72     void MovableEntity::tick(float dt)
    73     {
    74         if (this->isActive())
    75         {
    76             this->velocity_ += (dt * this->acceleration_);
    77             this->node_->translate(dt * this->velocity_);
    78 
    79             this->rotationRate_ += (dt * this->momentum_);
    80             this->node_->rotate(this->rotationAxis_, this->rotationRate_  * dt);
    81         }
    8251    }
    8352
    8453    void MovableEntity::registerVariables()
    8554    {
    86         REGISTERDATA(this->velocity_.x, network::direction::toclient);
    87         REGISTERDATA(this->velocity_.y, network::direction::toclient);
    88         REGISTERDATA(this->velocity_.z, network::direction::toclient);
    89 
    90         REGISTERDATA(this->rotationAxis_.x, network::direction::toclient);
    91         REGISTERDATA(this->rotationAxis_.y, network::direction::toclient);
    92         REGISTERDATA(this->rotationAxis_.z, network::direction::toclient);
    93 
    94         REGISTERDATA(this->rotationRate_, network::direction::toclient);
    95 
    96         REGISTERDATA(this->overwrite_position_,    network::direction::toclient, new network::NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
    97         REGISTERDATA(this->overwrite_orientation_, network::direction::toclient, new network::NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
    98     }
    99 
    100     void MovableEntity::overwritePosition()
    101     {
    102         this->node_->setPosition(this->overwrite_position_);
    103     }
    104 
    105     void MovableEntity::overwriteOrientation()
    106     {
    107         this->node_->setOrientation(this->overwrite_orientation_);
    108     }
    109 
    110     void MovableEntity::clientConnected(unsigned int clientID)
    111     {
    112         new Timer<MovableEntity>(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), true);
    113     }
    114 
    115     void MovableEntity::clientDisconnected(unsigned int clientID)
    116     {
    117     }
    118 
    119     void MovableEntity::resynchronize()
    120     {
    121         this->overwrite_position_ = this->getPosition();
    122         this->overwrite_orientation_ = this->getOrientation();
    123     }
    124 
    125     void MovableEntity::setPosition(const Vector3& position)
    126     {
    127         this->node_->setPosition(position);
    128         this->overwrite_position_ = this->node_->getPosition();
    129     }
    130 
    131     void MovableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
    132     {
    133         this->node_->translate(distance, relativeTo);
    134         this->overwrite_position_ = this->node_->getPosition();
    135     }
    136 
    137     void MovableEntity::setOrientation(const Quaternion& orientation)
    138     {
    139         this->node_->setOrientation(orientation);
    140         this->overwrite_orientation_ = this->node_->getOrientation();
    141     }
    142 
    143     void MovableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    144     {
    145         this->node_->rotate(rotation, relativeTo);
    146         this->overwrite_orientation_ = this->node_->getOrientation();
    147     }
    148 
    149     void MovableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    150     {
    151         this->node_->yaw(angle, relativeTo);
    152         this->overwrite_orientation_ = this->node_->getOrientation();
    153     }
    154 
    155     void MovableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    156     {
    157         this->node_->pitch(angle, relativeTo);
    158         this->overwrite_orientation_ = this->node_->getOrientation();
    159     }
    160 
    161     void MovableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    162     {
    163         this->node_->roll(angle, relativeTo);
    164         this->overwrite_orientation_ = this->node_->getOrientation();
    165     }
    166 
    167     void MovableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    168     {
    169         this->node_->lookAt(target, relativeTo, localDirectionVector);
    170         this->overwrite_orientation_ = this->node_->getOrientation();
    171     }
    172 
    173     void MovableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    174     {
    175         this->node_->setDirection(direction, relativeTo, localDirectionVector);
    176         this->overwrite_orientation_ = this->node_->getOrientation();
    17755    }
    17856}
  • code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h

    r2087 r2178  
    3838namespace orxonox
    3939{
    40     class _OrxonoxExport MovableEntity : public WorldEntity, public Tickable, public network::ClientConnectionListener
     40    class _OrxonoxExport MovableEntity : public WorldEntity
    4141    {
    4242        public:
     
    4545
    4646            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    47             virtual void tick(float dt);
    4847            void registerVariables();
    4948
    50             using WorldEntity::setPosition;
    51             using WorldEntity::translate;
    52             using WorldEntity::setOrientation;
    53             using WorldEntity::rotate;
    54             using WorldEntity::yaw;
    55             using WorldEntity::pitch;
    56             using WorldEntity::roll;
    57             using WorldEntity::lookAt;
    58             using WorldEntity::setDirection;
     49        private:
    5950
    60             void setPosition(const Vector3& position);
    61             void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    62             void setOrientation(const Quaternion& orientation);
    63             void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    64             void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    65             void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    66             void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    67             void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    68             void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     51            //void attachPhysicalObject(WorldEntity* object);
    6952
    70             inline void setVelocity(const Vector3& velocity)
    71                 { this->velocity_ = velocity; }
    72             inline void setVelocity(float x, float y, float z)
    73                 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
    74             inline const Vector3& getVelocity() const
    75                 { return this->velocity_; }
     53            //// Bullet btMotionState related
     54            //void setWorldTransform(const btTransform& worldTrans)
     55            //{
     56            //    this->node_->setPosition(worldTrans.getOrigin().x(), worldTrans.getOrigin().y(), worldTrans.getOrigin().z());
     57            //    this->node_->setOrientation(worldTrans.getRotation().w(), worldTrans.getRotation().x(), worldTrans.getRotation().y(), worldTrans.getRotation().z());
     58            //    //this->velocity_.x = this->physicalBody_->
     59            //}
    7660
    77             inline void setAcceleration(const Vector3& acceleration)
    78                 { this->acceleration_ = acceleration; }
    79             inline void setAcceleration(float x, float y, float z)
    80                 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
    81             inline const Vector3& getAcceleration() const
    82                 { return this->acceleration_; }
    83 
    84             inline void setRotationAxis(const Vector3& axis)
    85                 { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
    86             inline void setRotationAxis(float x, float y, float z)
    87                 { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
    88             inline const Vector3& getRotationAxis() const
    89                 { return this->rotationAxis_; }
    90 
    91             inline void setRotationRate(const Degree& angle)
    92                 { this->rotationRate_ = angle; }
    93             inline void setRotationRate(const Radian& angle)
    94                 { this->rotationRate_ = angle; }
    95             inline const Degree& getRotationRate() const
    96                 { return this->rotationRate_; }
    97 
    98             inline void setMomentum(const Degree& angle)
    99                 { this->momentum_ = angle; }
    100             inline void setMomentum(const Radian& angle)
    101                 { this->momentum_ = angle; }
    102             inline const Degree& getMomentum() const
    103                 { return this->momentum_; }
    104 
    105         private:
    106             void clientConnected(unsigned int clientID);
    107             void clientDisconnected(unsigned int clientID);
    108             void resynchronize();
    109 
    110             void overwritePosition();
    111             void overwriteOrientation();
    112 
    113             Vector3 velocity_;
    114             Vector3 acceleration_;
    115             Vector3 rotationAxis_;
    116             Degree rotationRate_;
    117             Degree momentum_;
    118 
    119             Vector3 overwrite_position_;
    120             Quaternion overwrite_orientation_;
     61            //// Bullet btMotionState related
     62            //void getWorldTransform(btTransform& worldTrans) const
     63            //{
     64            //    worldTrans.setOrigin(btVector3(node_->getPosition().x, node_->getPosition().y, node_->getPosition().z));
     65            //    worldTrans.setRotation(btQuaternion(node_->getOrientation().w, node_->getOrientation().x, node_->getOrientation().y, node_->getOrientation().z));
     66            //}
    12167    };
    12268}
  • code/branches/physics/src/orxonox/objects/worldentities/PositionableEntity.cc

    r2151 r2178  
    2828
    2929#include "OrxonoxStableHeaders.h"
    30 #include "StaticEntity.h"
     30#include "PositionableEntity.h"
    3131#include "core/CoreIncludes.h"
    3232
    3333namespace orxonox
    3434{
    35     CreateFactory(StaticEntity);
     35    CreateFactory(PositionableEntity);
    3636
    37     StaticEntity::StaticEntity(BaseObject* creator) : WorldEntity(creator)
     37    PositionableEntity::PositionableEntity(BaseObject* creator) : MovableEntity(creator)
    3838    {
    39         RegisterObject(StaticEntity);
     39        RegisterObject(PositionableEntity);
    4040
    4141        this->registerVariables();
    4242    }
    4343
    44     StaticEntity::~StaticEntity()
     44    PositionableEntity::~PositionableEntity()
    4545    {
    4646    }
    4747
    48     void StaticEntity::registerVariables()
     48    void PositionableEntity::registerVariables()
    4949    {
    5050        REGISTERDATA(this->getPosition().x, network::direction::toclient);
     
    5757        REGISTERDATA(this->getOrientation().z, network::direction::toclient);
    5858    }
     59
     60    //void PositionableEntity::attachPhysicalObject(WorldEntity* object)
     61    //{
     62    //}
    5963}
  • code/branches/physics/src/orxonox/objects/worldentities/PositionableEntity.h

    r2151 r2178  
    2727 */
    2828
    29 #ifndef _StaticEntity_H__
    30 #define _StaticEntity_H__
     29#ifndef _PositionableEntity_H__
     30#define _PositionableEntity_H__
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "WorldEntity.h"
     33#include "MovableEntity.h"
    3434
    3535namespace orxonox
    3636{
    37     class _OrxonoxExport StaticEntity : public WorldEntity
     37    class _OrxonoxExport PositionableEntity : public MovableEntity
    3838    {
    3939        public:
    40             StaticEntity(BaseObject* creator);
    41             virtual ~StaticEntity();
     40            PositionableEntity(BaseObject* creator);
     41            virtual ~PositionableEntity();
    4242
    4343            void registerVariables();
     
    7171            inline void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
    7272                { this->node_->setDirection(direction, relativeTo, localDirectionVector); }
     73
     74        private:
     75            //void attachPhysicalObject(WorldEntity* object);
    7376    };
    7477}
    7578
    76 #endif /* _StaticEntity_H__ */
     79#endif /* _PositionableEntity_H__ */
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc

    r2087 r2178  
    3232#include <cassert>
    3333#include <OgreSceneManager.h>
     34#include "BulletCollision/CollisionShapes/btSphereShape.h"
    3435
    3536#include "core/CoreIncludes.h"
     
    6364        this->node_->setOrientation(Quaternion::IDENTITY);
    6465
     66        // Default behaviour does not include physics
     67        this->bAddedToPhysicalWorld_ = false;
     68        this->physicalBody_ = 0;
     69
    6570        this->registerVariables();
    6671    }
     
    7378            if (this->getScene()->getSceneManager())
    7479                this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
     80           
     81            // Physics is not guaranteed, so check first
     82            if (this->physicalBody_)
     83            {
     84                if (this->bAddedToPhysicalWorld_)
     85                    this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     86                if (this->physicalBody_->getCollisionShape())
     87                    delete this->physicalBody_->getCollisionShape();
     88                delete this->physicalBody_;
     89            }
    7590        }
    7691    }
     
    89104        XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&);
    90105        XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, mode);
     106        XMLPortParam(WorldEntity, "collisionRadius", setcollisionRadius, getcollisionRadius, xmlelement, mode);
    91107
    92108        XMLPortObject(WorldEntity, WorldEntity, "attached", attach, getAttachedObject, xmlelement, mode);
     
    127143        object->parent_ = this;
    128144        object->parentID_ = this->getObjectID();
     145
     146        // Do the physical connection if required
     147        this->attachPhysicalObject(object);
    129148    }
    130149
     
    150169        return 0;
    151170    }
     171
     172    void WorldEntity::createPhysicalBody()
     173    {
     174        // Note: The motion state will be configured in a derived class.
     175        btRigidBody::btRigidBodyConstructionInfo bodyConstructionInfo(0, this, 0, btVector3(0,0,0));
     176        this->physicalBody_ = new btRigidBody(bodyConstructionInfo);
     177        this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     178        this->bAddedToPhysicalWorld_ = true;
     179    }
     180
     181    void WorldEntity::setcollisionRadius(float radius)
     182    {
     183        if (!this->physicalBody_)
     184            createPhysicalBody();
     185
     186        // destroy old onw first
     187        btCollisionShape* oldShape = this->physicalBody_->getCollisionShape();
     188        if (oldShape)
     189            delete oldShape;
     190
     191        this->physicalBody_->setCollisionShape(new btSphereShape(btScalar(radius)));
     192    }
     193
     194    float WorldEntity::getcollisionRadius()
     195    {
     196        if (this->physicalBody_)
     197        {
     198            btSphereShape* sphere = dynamic_cast<btSphereShape*>(this->physicalBody_->getCollisionShape());
     199            if (sphere)
     200                return (float)sphere->getRadius();
     201        }
     202        return 0.0f;
     203    }
    152204}
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h

    r2087 r2178  
    3333
    3434#define OGRE_FORCE_ANGLE_TYPES
     35#include <OgreSceneNode.h>
    3536
    36 #include <OgreSceneNode.h>
     37#include "LinearMath/btMotionState.h"
     38#include "BulletDynamics/Dynamics/btRigidBody.h"
    3739
    3840#include "network/Synchronisable.h"
     
    4244namespace orxonox
    4345{
    44     class _OrxonoxExport WorldEntity : public BaseObject, public network::Synchronisable
     46    class _OrxonoxExport WorldEntity : public BaseObject, public network::Synchronisable, public btMotionState
    4547    {
    4648        public:
     
    125127                { this->node_->scale(scale, scale, scale); }
    126128
     129            void setcollisionRadius(float radius);
     130            float getcollisionRadius();
     131
     132            bool hasPhysics()  { return this->physicalBody_; }
     133            bool isKinematic() { return this->physicalBody_ && this->physicalBody_->isKinematicObject(); }
     134            bool isDynamic()   { return this->physicalBody_ && !this->physicalBody_->isStaticOrKinematicObject(); }
     135
    127136            void attach(WorldEntity* object);
    128137            void detach(WorldEntity* object);
     
    139148
    140149        protected:
     150            //virtual btCollisionShape* getCollisionShape() = 0;
     151
     152            void createPhysicalBody();
     153            virtual void attachPhysicalObject(WorldEntity* object) { }
     154
    141155            Ogre::SceneNode* node_;
     156            bool bAddedToPhysicalWorld_;
     157            btRigidBody* physicalBody_;
    142158
    143159        private:
     
    155171                { this->roll(angle); }
    156172
     173            // Bullet btMotionState related
     174            virtual void setWorldTransform(const btTransform& worldTrans)
     175            {
     176            }
     177
     178            // Bullet btMotionState related
     179            virtual void getWorldTransform(btTransform& worldTrans) const
     180            {
     181            }
     182
    157183            WorldEntity* parent_;
    158184            unsigned int parentID_;
  • code/branches/physics/visual_studio/vc8/bullet_collision.vcproj

    r2149 r2178  
    494494                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
    495495                        >
     496                        <File
     497                                RelativePath="..\..\src\bullet\btBulletCollisionCommon.h"
     498                                >
     499                        </File>
    496500                        <Filter
    497501                                Name="BroadphaseCollision"
  • code/branches/physics/visual_studio/vc8/bullet_dynamics.vcproj

    r2149 r2178  
    214214                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
    215215                        >
     216                        <File
     217                                RelativePath="..\..\src\bullet\btBulletDynamicsCommon.h"
     218                                >
     219                        </File>
    216220                        <Filter
    217221                                Name="ConstraintSolver"
  • code/branches/physics/visual_studio/vc8/bullet_linearmath.vcproj

    r2119 r2178  
    154154                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
    155155                        >
     156                        <File
     157                                RelativePath="..\..\src\bullet\LinearMath\btAabbUtil2.h"
     158                                >
     159                        </File>
     160                        <File
     161                                RelativePath="..\..\src\bullet\LinearMath\btAlignedAllocator.h"
     162                                >
     163                        </File>
     164                        <File
     165                                RelativePath="..\..\src\bullet\LinearMath\btAlignedObjectArray.h"
     166                                >
     167                        </File>
     168                        <File
     169                                RelativePath="..\..\src\bullet\LinearMath\btConvexHull.h"
     170                                >
     171                        </File>
     172                        <File
     173                                RelativePath="..\..\src\bullet\LinearMath\btDefaultMotionState.h"
     174                                >
     175                        </File>
     176                        <File
     177                                RelativePath="..\..\src\bullet\LinearMath\btGeometryUtil.h"
     178                                >
     179                        </File>
     180                        <File
     181                                RelativePath="..\..\src\bullet\LinearMath\btHashMap.h"
     182                                >
     183                        </File>
     184                        <File
     185                                RelativePath="..\..\src\bullet\LinearMath\btIDebugDraw.h"
     186                                >
     187                        </File>
     188                        <File
     189                                RelativePath="..\..\src\bullet\LinearMath\btList.h"
     190                                >
     191                        </File>
     192                        <File
     193                                RelativePath="..\..\src\bullet\LinearMath\btMatrix3x3.h"
     194                                >
     195                        </File>
     196                        <File
     197                                RelativePath="..\..\src\bullet\LinearMath\btMinMax.h"
     198                                >
     199                        </File>
     200                        <File
     201                                RelativePath="..\..\src\bullet\LinearMath\btMotionState.h"
     202                                >
     203                        </File>
     204                        <File
     205                                RelativePath="..\..\src\bullet\LinearMath\btPoint3.h"
     206                                >
     207                        </File>
     208                        <File
     209                                RelativePath="..\..\src\bullet\LinearMath\btPoolAllocator.h"
     210                                >
     211                        </File>
     212                        <File
     213                                RelativePath="..\..\src\bullet\LinearMath\btQuadWord.h"
     214                                >
     215                        </File>
     216                        <File
     217                                RelativePath="..\..\src\bullet\LinearMath\btQuaternion.h"
     218                                >
     219                        </File>
     220                        <File
     221                                RelativePath="..\..\src\bullet\LinearMath\btQuickprof.h"
     222                                >
     223                        </File>
     224                        <File
     225                                RelativePath="..\..\src\bullet\LinearMath\btRandom.h"
     226                                >
     227                        </File>
     228                        <File
     229                                RelativePath="..\..\src\bullet\LinearMath\btScalar.h"
     230                                >
     231                        </File>
     232                        <File
     233                                RelativePath="..\..\src\bullet\LinearMath\btStackAlloc.h"
     234                                >
     235                        </File>
     236                        <File
     237                                RelativePath="..\..\src\bullet\LinearMath\btTransform.h"
     238                                >
     239                        </File>
     240                        <File
     241                                RelativePath="..\..\src\bullet\LinearMath\btTransformUtil.h"
     242                                >
     243                        </File>
     244                        <File
     245                                RelativePath="..\..\src\bullet\LinearMath\btVector3.h"
     246                                >
     247                        </File>
    156248                </Filter>
    157249        </Files>
  • code/branches/physics/visual_studio/vc8/orxonox.vcproj

    r2151 r2178  
    301301                                        </File>
    302302                                        <File
    303                                                 RelativePath="..\..\src\orxonox\objects\worldentities\DynamicEntity.cc"
    304                                                 >
    305                                         </File>
    306                                         <File
    307                                                 RelativePath="..\..\src\orxonox\objects\worldentities\KinematicEntity.cc"
    308                                                 >
    309                                         </File>
    310                                         <File
    311303                                                RelativePath="..\..\src\orxonox\objects\worldentities\Light.cc"
    312304                                                >
    313305                                        </File>
    314306                                        <File
     307                                                RelativePath="..\..\src\orxonox\objects\worldentities\LinearEntity.cc"
     308                                                >
     309                                        </File>
     310                                        <File
    315311                                                RelativePath="..\..\src\orxonox\objects\worldentities\Model.cc"
    316312                                                >
     
    326322                                        <File
    327323                                                RelativePath="..\..\src\orxonox\objects\worldentities\ParticleSpawner.cc"
     324                                                >
     325                                        </File>
     326                                        <File
     327                                                RelativePath="..\..\src\orxonox\objects\worldentities\PositionableEntity.cc"
    328328                                                >
    329329                                        </File>
     
    419419                                                RelativePath="..\..\src\orxonox\objects\weaponSystem\Munition.cc"
    420420                                                >
     421                                                <FileConfiguration
     422                                                        Name="Debug|Win32"
     423                                                        ExcludedFromBuild="true"
     424                                                        >
     425                                                        <Tool
     426                                                                Name="VCCLCompilerTool"
     427                                                        />
     428                                                </FileConfiguration>
     429                                                <FileConfiguration
     430                                                        Name="Release|Win32"
     431                                                        ExcludedFromBuild="true"
     432                                                        >
     433                                                        <Tool
     434                                                                Name="VCCLCompilerTool"
     435                                                        />
     436                                                </FileConfiguration>
    421437                                        </File>
    422438                                        <File
    423439                                                RelativePath="..\..\src\orxonox\objects\weaponSystem\Weapon.cc"
    424440                                                >
     441                                                <FileConfiguration
     442                                                        Name="Debug|Win32"
     443                                                        ExcludedFromBuild="true"
     444                                                        >
     445                                                        <Tool
     446                                                                Name="VCCLCompilerTool"
     447                                                        />
     448                                                </FileConfiguration>
     449                                                <FileConfiguration
     450                                                        Name="Release|Win32"
     451                                                        ExcludedFromBuild="true"
     452                                                        >
     453                                                        <Tool
     454                                                                Name="VCCLCompilerTool"
     455                                                        />
     456                                                </FileConfiguration>
    425457                                        </File>
    426458                                        <File
     
    575607                                                RelativePath="..\..\src\orxonox\objects\quest\AddQuest.cc"
    576608                                                >
     609                                                <FileConfiguration
     610                                                        Name="Debug|Win32"
     611                                                        ExcludedFromBuild="true"
     612                                                        >
     613                                                        <Tool
     614                                                                Name="VCCLCompilerTool"
     615                                                        />
     616                                                </FileConfiguration>
     617                                                <FileConfiguration
     618                                                        Name="Release|Win32"
     619                                                        ExcludedFromBuild="true"
     620                                                        >
     621                                                        <Tool
     622                                                                Name="VCCLCompilerTool"
     623                                                        />
     624                                                </FileConfiguration>
    577625                                        </File>
    578626                                        <File
    579627                                                RelativePath="..\..\src\orxonox\objects\quest\AddQuestHint.cc"
    580628                                                >
     629                                                <FileConfiguration
     630                                                        Name="Debug|Win32"
     631                                                        ExcludedFromBuild="true"
     632                                                        >
     633                                                        <Tool
     634                                                                Name="VCCLCompilerTool"
     635                                                        />
     636                                                </FileConfiguration>
     637                                                <FileConfiguration
     638                                                        Name="Release|Win32"
     639                                                        ExcludedFromBuild="true"
     640                                                        >
     641                                                        <Tool
     642                                                                Name="VCCLCompilerTool"
     643                                                        />
     644                                                </FileConfiguration>
    581645                                        </File>
    582646                                        <File
    583647                                                RelativePath="..\..\src\orxonox\objects\quest\AddReward.cc"
    584648                                                >
     649                                                <FileConfiguration
     650                                                        Name="Debug|Win32"
     651                                                        ExcludedFromBuild="true"
     652                                                        >
     653                                                        <Tool
     654                                                                Name="VCCLCompilerTool"
     655                                                        />
     656                                                </FileConfiguration>
     657                                                <FileConfiguration
     658                                                        Name="Release|Win32"
     659                                                        ExcludedFromBuild="true"
     660                                                        >
     661                                                        <Tool
     662                                                                Name="VCCLCompilerTool"
     663                                                        />
     664                                                </FileConfiguration>
    585665                                        </File>
    586666                                        <File
    587667                                                RelativePath="..\..\src\orxonox\objects\quest\ChangeQuestStatus.cc"
    588668                                                >
     669                                                <FileConfiguration
     670                                                        Name="Debug|Win32"
     671                                                        ExcludedFromBuild="true"
     672                                                        >
     673                                                        <Tool
     674                                                                Name="VCCLCompilerTool"
     675                                                        />
     676                                                </FileConfiguration>
     677                                                <FileConfiguration
     678                                                        Name="Release|Win32"
     679                                                        ExcludedFromBuild="true"
     680                                                        >
     681                                                        <Tool
     682                                                                Name="VCCLCompilerTool"
     683                                                        />
     684                                                </FileConfiguration>
    589685                                        </File>
    590686                                        <File
    591687                                                RelativePath="..\..\src\orxonox\objects\quest\CompleteQuest.cc"
    592688                                                >
     689                                                <FileConfiguration
     690                                                        Name="Debug|Win32"
     691                                                        ExcludedFromBuild="true"
     692                                                        >
     693                                                        <Tool
     694                                                                Name="VCCLCompilerTool"
     695                                                        />
     696                                                </FileConfiguration>
     697                                                <FileConfiguration
     698                                                        Name="Release|Win32"
     699                                                        ExcludedFromBuild="true"
     700                                                        >
     701                                                        <Tool
     702                                                                Name="VCCLCompilerTool"
     703                                                        />
     704                                                </FileConfiguration>
    593705                                        </File>
    594706                                        <File
    595707                                                RelativePath="..\..\src\orxonox\objects\quest\FailQuest.cc"
    596708                                                >
     709                                                <FileConfiguration
     710                                                        Name="Debug|Win32"
     711                                                        ExcludedFromBuild="true"
     712                                                        >
     713                                                        <Tool
     714                                                                Name="VCCLCompilerTool"
     715                                                        />
     716                                                </FileConfiguration>
     717                                                <FileConfiguration
     718                                                        Name="Release|Win32"
     719                                                        ExcludedFromBuild="true"
     720                                                        >
     721                                                        <Tool
     722                                                                Name="VCCLCompilerTool"
     723                                                        />
     724                                                </FileConfiguration>
    597725                                        </File>
    598726                                        <File
    599727                                                RelativePath="..\..\src\orxonox\objects\quest\GlobalQuest.cc"
    600728                                                >
     729                                                <FileConfiguration
     730                                                        Name="Debug|Win32"
     731                                                        ExcludedFromBuild="true"
     732                                                        >
     733                                                        <Tool
     734                                                                Name="VCCLCompilerTool"
     735                                                        />
     736                                                </FileConfiguration>
     737                                                <FileConfiguration
     738                                                        Name="Release|Win32"
     739                                                        ExcludedFromBuild="true"
     740                                                        >
     741                                                        <Tool
     742                                                                Name="VCCLCompilerTool"
     743                                                        />
     744                                                </FileConfiguration>
    601745                                        </File>
    602746                                        <File
    603747                                                RelativePath="..\..\src\orxonox\objects\quest\LocalQuest.cc"
    604748                                                >
     749                                                <FileConfiguration
     750                                                        Name="Debug|Win32"
     751                                                        ExcludedFromBuild="true"
     752                                                        >
     753                                                        <Tool
     754                                                                Name="VCCLCompilerTool"
     755                                                        />
     756                                                </FileConfiguration>
     757                                                <FileConfiguration
     758                                                        Name="Release|Win32"
     759                                                        ExcludedFromBuild="true"
     760                                                        >
     761                                                        <Tool
     762                                                                Name="VCCLCompilerTool"
     763                                                        />
     764                                                </FileConfiguration>
    605765                                        </File>
    606766                                        <File
    607767                                                RelativePath="..\..\src\orxonox\objects\quest\Quest.cc"
    608768                                                >
     769                                                <FileConfiguration
     770                                                        Name="Debug|Win32"
     771                                                        ExcludedFromBuild="true"
     772                                                        >
     773                                                        <Tool
     774                                                                Name="VCCLCompilerTool"
     775                                                        />
     776                                                </FileConfiguration>
     777                                                <FileConfiguration
     778                                                        Name="Release|Win32"
     779                                                        ExcludedFromBuild="true"
     780                                                        >
     781                                                        <Tool
     782                                                                Name="VCCLCompilerTool"
     783                                                        />
     784                                                </FileConfiguration>
    609785                                        </File>
    610786                                        <File
    611787                                                RelativePath="..\..\src\orxonox\objects\quest\QuestDescription.cc"
    612788                                                >
     789                                                <FileConfiguration
     790                                                        Name="Debug|Win32"
     791                                                        ExcludedFromBuild="true"
     792                                                        >
     793                                                        <Tool
     794                                                                Name="VCCLCompilerTool"
     795                                                        />
     796                                                </FileConfiguration>
     797                                                <FileConfiguration
     798                                                        Name="Release|Win32"
     799                                                        ExcludedFromBuild="true"
     800                                                        >
     801                                                        <Tool
     802                                                                Name="VCCLCompilerTool"
     803                                                        />
     804                                                </FileConfiguration>
    613805                                        </File>
    614806                                        <File
    615807                                                RelativePath="..\..\src\orxonox\objects\quest\QuestEffect.cc"
    616808                                                >
     809                                                <FileConfiguration
     810                                                        Name="Debug|Win32"
     811                                                        ExcludedFromBuild="true"
     812                                                        >
     813                                                        <Tool
     814                                                                Name="VCCLCompilerTool"
     815                                                        />
     816                                                </FileConfiguration>
     817                                                <FileConfiguration
     818                                                        Name="Release|Win32"
     819                                                        ExcludedFromBuild="true"
     820                                                        >
     821                                                        <Tool
     822                                                                Name="VCCLCompilerTool"
     823                                                        />
     824                                                </FileConfiguration>
    617825                                        </File>
    618826                                        <File
    619827                                                RelativePath="..\..\src\orxonox\objects\quest\QuestHint.cc"
    620828                                                >
     829                                                <FileConfiguration
     830                                                        Name="Debug|Win32"
     831                                                        ExcludedFromBuild="true"
     832                                                        >
     833                                                        <Tool
     834                                                                Name="VCCLCompilerTool"
     835                                                        />
     836                                                </FileConfiguration>
     837                                                <FileConfiguration
     838                                                        Name="Release|Win32"
     839                                                        ExcludedFromBuild="true"
     840                                                        >
     841                                                        <Tool
     842                                                                Name="VCCLCompilerTool"
     843                                                        />
     844                                                </FileConfiguration>
    621845                                        </File>
    622846                                        <File
    623847                                                RelativePath="..\..\src\orxonox\objects\quest\QuestItem.cc"
    624848                                                >
     849                                                <FileConfiguration
     850                                                        Name="Debug|Win32"
     851                                                        ExcludedFromBuild="true"
     852                                                        >
     853                                                        <Tool
     854                                                                Name="VCCLCompilerTool"
     855                                                        />
     856                                                </FileConfiguration>
     857                                                <FileConfiguration
     858                                                        Name="Release|Win32"
     859                                                        ExcludedFromBuild="true"
     860                                                        >
     861                                                        <Tool
     862                                                                Name="VCCLCompilerTool"
     863                                                        />
     864                                                </FileConfiguration>
    625865                                        </File>
    626866                                        <File
    627867                                                RelativePath="..\..\src\orxonox\objects\quest\QuestManager.cc"
    628868                                                >
     869                                                <FileConfiguration
     870                                                        Name="Debug|Win32"
     871                                                        ExcludedFromBuild="true"
     872                                                        >
     873                                                        <Tool
     874                                                                Name="VCCLCompilerTool"
     875                                                        />
     876                                                </FileConfiguration>
     877                                                <FileConfiguration
     878                                                        Name="Release|Win32"
     879                                                        ExcludedFromBuild="true"
     880                                                        >
     881                                                        <Tool
     882                                                                Name="VCCLCompilerTool"
     883                                                        />
     884                                                </FileConfiguration>
    629885                                        </File>
    630886                                        <File
    631887                                                RelativePath="..\..\src\orxonox\objects\quest\Rewardable.cc"
    632888                                                >
     889                                                <FileConfiguration
     890                                                        Name="Debug|Win32"
     891                                                        ExcludedFromBuild="true"
     892                                                        >
     893                                                        <Tool
     894                                                                Name="VCCLCompilerTool"
     895                                                        />
     896                                                </FileConfiguration>
     897                                                <FileConfiguration
     898                                                        Name="Release|Win32"
     899                                                        ExcludedFromBuild="true"
     900                                                        >
     901                                                        <Tool
     902                                                                Name="VCCLCompilerTool"
     903                                                        />
     904                                                </FileConfiguration>
    633905                                        </File>
    634906                                </Filter>
     
    9411213                                        </File>
    9421214                                        <File
    943                                                 RelativePath="..\..\src\orxonox\objects\worldentities\DynamicEntity.h"
    944                                                 >
    945                                         </File>
    946                                         <File
    947                                                 RelativePath="..\..\src\orxonox\objects\worldentities\KinematicEntity.h"
    948                                                 >
    949                                         </File>
    950                                         <File
    9511215                                                RelativePath="..\..\src\orxonox\objects\worldentities\Light.h"
    9521216                                                >
    9531217                                        </File>
    9541218                                        <File
     1219                                                RelativePath="..\..\src\orxonox\objects\worldentities\LinearEntity.h"
     1220                                                >
     1221                                        </File>
     1222                                        <File
    9551223                                                RelativePath="..\..\src\orxonox\objects\worldentities\Model.h"
    9561224                                                >
     
    9661234                                        <File
    9671235                                                RelativePath="..\..\src\orxonox\objects\worldentities\ParticleSpawner.h"
     1236                                                >
     1237                                        </File>
     1238                                        <File
     1239                                                RelativePath="..\..\src\orxonox\objects\worldentities\PositionableEntity.h"
    9681240                                                >
    9691241                                        </File>
Note: See TracChangeset for help on using the changeset viewer.