Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2008, 4:16:52 PM (15 years ago)
Author:
rgrieder
Message:

Finally merged physics stuff. Target is physics_merge because I'll have to do some testing first.

Location:
code/branches/physics_merge
Files:
1 added
2 deleted
84 edited
14 copied

Legend:

Unmodified
Added
Removed
  • code/branches/physics_merge

  • code/branches/physics_merge/src/orxonox/CMakeLists.txt

    r2171 r2442  
    4848  tinyxml_orxonox
    4949  tolualib_orxonox
     50  LibBulletDynamics
     51  LibBulletCollision
     52  LibLinearMath
    5053  util
    5154  core
  • code/branches/physics_merge/src/orxonox/CameraManager.cc

  • code/branches/physics_merge/src/orxonox/CameraManager.h

  • code/branches/physics_merge/src/orxonox/OrxonoxPrereqs.h

    r2385 r2442  
    107107
    108108    class WorldEntity;
    109     class PositionableEntity;
     109    class StaticEntity;
     110    class MobileEntity;
     111    class ControllableEntity;
    110112    class MovableEntity;
    111     class ControllableEntity;
    112113    class Sublevel;
    113114
     
    153154
    154155    class Scores;
     156
     157    // collision
     158    class CollisionShape;
     159    class SphereCollisionShape;
     160    class CompoundCollisionShape;
     161    class PlaneCollisionShape;
    155162
    156163    // tools
     
    210217}
    211218
     219// Bullet Physics Engine
     220
     221class btTransform;
     222class btVector3;
     223
     224class btRigidBody;
     225class btCollisionObject;
     226class btGhostObject;
     227
     228class btCollisionShape;
     229class btSphereShape;
     230class btCompoundShape;
     231class btStaticPlaneShape;
     232
     233class btDiscreteDynamicsWorld;
     234
     235// lua
    212236struct lua_State;
    213237
  • code/branches/physics_merge/src/orxonox/OrxonoxStableHeaders.h

    r2371 r2442  
    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/Synchronisable.h"
    98100
    99 #include "Settings.h"
     101//#include "Settings.h"
    100102
    101103//#endif /* ifdef NDEBUG */
    102104
    103 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
     105#endif /* defined(ORXONOX_ENABLE_PCH) */
    104106
    105107#endif /* _OrxonoxStableHeaders_H__ */
  • code/branches/physics_merge/src/orxonox/gamestates/GSLevel.cc

    r2103 r2442  
    5151namespace orxonox
    5252{
    53     SetCommandLineArgument(level, "sample2.oxw").shortcut("l");
     53    SetCommandLineArgument(level, "physicstest2.oxw").shortcut("l");
    5454
    5555    GSLevel::GSLevel()
  • code/branches/physics_merge/src/orxonox/gamestates/GSRoot.cc

    r2171 r2442  
    146146        /*** HACK *** HACK ***/
    147147        // Call the Tickable objects
     148        float leveldt = time.getDeltaTime();
     149        if (leveldt > 1.0f)
     150        {
     151            // just loaded
     152            leveldt = 0.0f;
     153        }
    148154        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    149             it->tick(time.getDeltaTime());
     155            it->tick(leveldt);
    150156        /*** HACK *** HACK ***/
    151157
  • code/branches/physics_merge/src/orxonox/objects/CMakeLists.txt

    r2171 r2442  
    1313)
    1414
     15ADD_SOURCE_DIRECTORY(SRC_FILES collisionshapes)
    1516ADD_SOURCE_DIRECTORY(SRC_FILES controllers)
    1617ADD_SOURCE_DIRECTORY(SRC_FILES gametypes)
  • code/branches/physics_merge/src/orxonox/objects/Scene.cc

    r2371 r2442  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder (physics)
    2626 *
    2727 */
     
    3535#include <OgreLight.h>
    3636
     37#include "BulletCollision/BroadphaseCollision/btAxisSweep3.h"
     38#include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h"
     39#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
     40#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
     41
    3742#include "core/CoreIncludes.h"
    3843#include "core/Core.h"
    3944#include "core/XMLPort.h"
     45#include "tools/BulletConversions.h"
     46#include "objects/worldentities/WorldEntity.h"
    4047
    4148namespace orxonox
     
    6976            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
    7077        }
     78
     79        // No physics for default
     80        this->physicalWorld_ = 0;
    7181
    7282        // test test test
     
    91101            if (Ogre::Root::getSingletonPtr())
    92102            {
    93 //                this->sceneManager_->destroySceneNode(this->rootSceneNode_->getName()); // TODO: remove getName() for newer versions of Ogre
    94103                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    95104            }
     
    109118        XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true);
    110119
     120        //const int defaultMaxWorldSize = 100000;
     121        //Vector3 worldAabbMin(-defaultMaxWorldSize, -defaultMaxWorldSize, -defaultMaxWorldSize);
     122        //Vector3 worldAabbMax( defaultMaxWorldSize,  defaultMaxWorldSize,  defaultMaxWorldSize);
     123        //XMLPortParamVariable(Scene, "negativeWorldRange", worldAabbMin, xmlelement, mode);
     124        //XMLPortParamVariable(Scene, "positiveWorldRange", worldAabbMax, xmlelement, mode);
     125        XMLPortParam(Scene, "hasPhysics", setPhysicalWorld, hasPhysics, xmlelement, mode).defaultValue(0, true);//.defaultValue(1, worldAabbMin).defaultValue(2, worldAabbMax);
     126
    111127        XMLPortObjectExtended(Scene, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
    112128    }
     
    114130    void Scene::registerVariables()
    115131    {
    116         registerVariable(this->skybox_,     variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
     132        registerVariable(this->skybox_,       variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
    117133        registerVariable(this->ambientLight_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
     134        registerVariable(this->bHasPhysics_,  variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
     135    }
     136
     137    void Scene::setPhysicalWorld(bool wantPhysics)//, const Vector3& worldAabbMin, const Vector3& worldAabbMax)
     138    {
     139        this->bHasPhysics_ = wantPhysics;
     140        if (wantPhysics && !hasPhysics())
     141        {
     142            //float x = worldAabbMin.x;
     143            //float y = worldAabbMin.y;
     144            //float z = worldAabbMin.z;
     145            btVector3 worldAabbMin(-100000, -100000, -100000);
     146            //x = worldAabbMax.x;
     147            //y = worldAabbMax.y;
     148            //z = worldAabbMax.z;
     149            btVector3 worldAabbMax(100000, 100000, 100000);
     150
     151            btDefaultCollisionConfiguration*     collisionConfig = new btDefaultCollisionConfiguration();
     152            btCollisionDispatcher*               dispatcher      = new btCollisionDispatcher(collisionConfig);
     153            bt32BitAxisSweep3*                   broadphase      = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax);
     154            btSequentialImpulseConstraintSolver* solver          = new btSequentialImpulseConstraintSolver;
     155
     156            this->physicalWorld_ =  new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig);
     157
     158            // Disable Gravity for space
     159            this->physicalWorld_->setGravity(btVector3(0,0,0));
     160        }
     161        else
     162        {
     163            // TODO: Destroy Bullet physics
     164        }
     165    }
     166
     167    void Scene::tick(float dt)
     168    {
     169        if (!Core::showsGraphics())
     170        {
     171            // We need to update the scene nodes if we don't render
     172            this->rootSceneNode_->_update(true, false);
     173        }
     174        if (physicalWorld_)
     175        {
     176            if (this->physicsQueue_.size() > 0)
     177            {
     178                // Add all scheduled WorldEntities
     179                for (std::set<btRigidBody*>::const_iterator it = this->physicsQueue_.begin();
     180                    it != this->physicsQueue_.end(); ++it)
     181                {
     182                    if (!(*it)->isInWorld())
     183                    {
     184                        //COUT(0) << "body position: " << omni_cast<Vector3>((*it)->getWorldTransform().getOrigin()) << std::endl;
     185                        //COUT(0) << "body velocity: " << omni_cast<Vector3>((*it)->getLinearVelocity()) << std::endl;
     186                        //COUT(0) << "body orientation: " << omni_cast<Quaternion>((*it)->getWorldTransform().getRotation()) << std::endl;
     187                        //COUT(0) << "body angular: " << omni_cast<Vector3>((*it)->getAngularVelocity()) << std::endl;
     188                        //COUT(0) << "body mass: " << omni_cast<float>((*it)->getInvMass()) << std::endl;
     189                        //COUT(0) << "body inertia: " << omni_cast<Vector3>((*it)->getInvInertiaDiagLocal()) << std::endl;
     190                        this->physicalWorld_->addRigidBody(*it);
     191                    }
     192                }
     193                this->physicsQueue_.clear();
     194            }
     195
     196            // TODO: This is not stable! If physics cannot be calculated real time anymore,
     197            //       framerate will drop exponentially.
     198            physicalWorld_->stepSimulation(dt,(int)(dt/0.0166666f + 1.0f));
     199        }
    118200    }
    119201
     
    165247    }
    166248
    167     void Scene::tick(float dt)
    168     {
    169         if (!Core::showsGraphics())
    170         {
    171             // We need to update the scene nodes if we don't render
    172             this->rootSceneNode_->_update(true, false);
     249    void Scene::addRigidBody(btRigidBody* body)
     250    {
     251        if (!this->physicalWorld_)
     252            COUT(1) << "Error: Cannot add WorldEntity body to physical Scene: No physics." << std::endl;
     253        else if (body)
     254            this->physicsQueue_.insert(body);
     255    }
     256
     257    void Scene::removeRigidBody(btRigidBody* body)
     258    {
     259        if (!this->physicalWorld_)
     260            COUT(1) << "Error: Cannot remove WorldEntity body from physical Scene: No physics." << std::endl;
     261        else if (body)
     262        {
     263            this->physicalWorld_->removeRigidBody(body);
     264            // Also check queue
     265            std::set<btRigidBody*>::iterator it = this->physicsQueue_.find(body);
     266            if (it != this->physicsQueue_.end())
     267                this->physicsQueue_.erase(it);
    173268        }
    174269    }
  • code/branches/physics_merge/src/orxonox/objects/Scene.h

    r2371 r2442  
    5353                { return this->rootSceneNode_; }
    5454
     55            inline btDiscreteDynamicsWorld* getPhysicalWorld() const
     56                { return this->physicalWorld_; }
     57
    5558            void setSkybox(const std::string& skybox);
    5659            inline const std::string& getSkybox() const
     
    6568                { return this->bShadows_; }
    6669
     70            inline bool hasPhysics()
     71                { return this->physicalWorld_ != 0; }
     72            void setPhysicalWorld(bool wantsPhysics);//, const Vector3& worldAabbMin, const Vector3& worldAabbMax);
     73
     74            void addRigidBody(btRigidBody* body);
     75            void removeRigidBody(btRigidBody* body);
     76
    6777            virtual void tick(float dt);
    6878
     
    7585            void networkcallback_applyAmbientLight()
    7686                { this->setAmbientLight(this->ambientLight_); }
     87            void networkcallback_hasPhysics()
     88                { this->setPhysicalWorld(this->bHasPhysics_); }
    7789
    78             Ogre::SceneManager*    sceneManager_;
    79             Ogre::SceneNode*       rootSceneNode_;
    80             std::string            skybox_;
    81             ColourValue            ambientLight_;
    82             std::list<BaseObject*> objects_;
    83             bool                   bShadows_;
     90            Ogre::SceneManager*      sceneManager_;
     91            Ogre::SceneNode*         rootSceneNode_;
     92
     93            btDiscreteDynamicsWorld* physicalWorld_;
     94            std::set<btRigidBody*>   physicsQueue_;
     95            bool                     bHasPhysics_;
     96
     97            std::string              skybox_;
     98            ColourValue              ambientLight_;
     99            std::list<BaseObject*>   objects_;
     100            bool                     bShadows_;
    84101    };
    85102}
  • code/branches/physics_merge/src/orxonox/objects/collisionshapes

  • code/branches/physics_merge/src/orxonox/objects/collisionshapes/CollisionShape.cc

    r2440 r2442  
    4545    CollisionShape::CollisionShape(BaseObject* creator)
    4646        : BaseObject(creator)
    47         , network::Synchronisable(creator)
     47        , Synchronisable(creator)
    4848    {
    4949        RegisterObject(CollisionShape);
     
    7676    void CollisionShape::registerVariables()
    7777    {
    78         REGISTERDATA(this->parentID_, network::direction::toclient, new network::NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
     78        registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
    7979    }
    8080
  • code/branches/physics_merge/src/orxonox/objects/collisionshapes/CollisionShape.h

    r2440 r2442  
    3535#include "util/Math.h"
    3636#include "core/BaseObject.h"
    37 #include "network/Synchronisable.h"
     37#include "network/synchronisable/Synchronisable.h"
    3838
    3939namespace orxonox
    4040{
    41     class _OrxonoxExport CollisionShape : public BaseObject, public network::Synchronisable
     41    class _OrxonoxExport CollisionShape : public BaseObject, public Synchronisable
    4242    {
    4343        public:
  • code/branches/physics_merge/src/orxonox/objects/collisionshapes/PlaneCollisionShape.cc

    r2440 r2442  
    5757    void PlaneCollisionShape::registerVariables()
    5858    {
    59         REGISTERDATA(this->normal_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::updatePlane));
    60         REGISTERDATA(this->offset_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::updatePlane));
     59        registerVariable(this->normal_, variableDirection::toclient, new NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::updatePlane));
     60        registerVariable(this->offset_, variableDirection::toclient, new NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::updatePlane));
    6161    }
    6262
  • code/branches/physics_merge/src/orxonox/objects/collisionshapes/SphereCollisionShape.cc

    r2440 r2442  
    5858    void SphereCollisionShape::registerVariables()
    5959    {
    60         REGISTERDATA(this->radius_, network::direction::toclient, new network::NetworkCallback<SphereCollisionShape>(this, &SphereCollisionShape::updateSphere));
     60        registerVariable(this->radius_, variableDirection::toclient, new NetworkCallback<SphereCollisionShape>(this, &SphereCollisionShape::updateSphere));
    6161    }
    6262
  • code/branches/physics_merge/src/orxonox/objects/pickup/Usable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/AddQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/AddQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/AddQuestHint.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/AddQuestHint.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/AddReward.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/AddReward.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/ChangeQuestStatus.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/ChangeQuestStatus.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/CompleteQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/CompleteQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/FailQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/FailQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/GlobalQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/GlobalQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/LocalQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/LocalQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/Quest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/Quest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestDescription.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestDescription.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestEffect.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestEffect.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r2435 r2442  
    5353        Constructor. Registers the object and initializes defaults.
    5454    */
    55     QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : PositionableEntity(creator)
     55    QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : StaticEntity(creator)
    5656    {
    5757        RegisterObject(QuestEffectBeacon);
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestEffectBeacon.h

    r2435 r2442  
    3737#include "OrxonoxPrereqs.h"
    3838
    39 #include "orxonox/objects/worldentities/PositionableEntity.h"
     39#include "orxonox/objects/worldentities/StaticEntity.h"
    4040
    4141namespace orxonox
     
    8080        Damian 'Mozork' Frick
    8181    */
    82     class _OrxonoxExport QuestEffectBeacon : public PositionableEntity
     82    class _OrxonoxExport QuestEffectBeacon : public StaticEntity
    8383    {
    8484        public:
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestHint.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestHint.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestItem.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestItem.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestManager.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/QuestManager.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/Rewardable.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/quest/Rewardable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/physics_merge/src/orxonox/objects/weaponSystem/WeaponSystem.h

  • code/branches/physics_merge/src/orxonox/objects/worldentities/Backlight.cc

  • code/branches/physics_merge/src/orxonox/objects/worldentities/Backlight.h

    r2420 r2442  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "PositionableEntity.h"
     34#include "StaticEntity.h"
    3535#include "tools/BillboardSet.h"
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport Backlight : public PositionableEntity
     39    class _OrxonoxExport Backlight : public StaticEntity
    4040    {
    4141        public:
  • code/branches/physics_merge/src/orxonox/objects/worldentities/Billboard.cc

    r2371 r2442  
    3030#include "Billboard.h"
    3131
     32#include <OgreBillboardSet.h>
     33
    3234#include "core/CoreIncludes.h"
    3335#include "core/XMLPort.h"
     
    3840    CreateFactory(Billboard);
    3941
    40     Billboard::Billboard(BaseObject* creator) : PositionableEntity(creator)
     42    Billboard::Billboard(BaseObject* creator) : StaticEntity(creator)
    4143    {
    4244        RegisterObject(Billboard);
     
    5052        {
    5153            if (this->isInitialized() && this->billboard_.getBillboardSet())
    52                 this->getNode()->detachObject(this->billboard_.getName());
     54                this->detachOgreObject(this->billboard_.getName());
    5355        }
    5456    }
     
    7678                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
    7779                if (this->billboard_.getBillboardSet())
    78                     this->getNode()->attachObject(this->billboard_.getBillboardSet());
     80                     this->attachOgreObject(this->billboard_.getBillboardSet());
    7981                this->billboard_.setVisible(this->isVisible());
    8082            }
     
    9294                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
    9395                if (this->billboard_.getBillboardSet())
    94                     this->getNode()->attachObject(this->billboard_.getBillboardSet());
     96                    this->attachOgreObject(this->billboard_.getBillboardSet());
    9597                this->billboard_.setVisible(this->isVisible());
    9698            }
  • code/branches/physics_merge/src/orxonox/objects/worldentities/Billboard.h

    r2087 r2442  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434#include "util/Math.h"
    3535#include "tools/BillboardSet.h"
     
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport Billboard : public PositionableEntity
     39    class _OrxonoxExport Billboard : public StaticEntity
    4040    {
    4141        public:
  • code/branches/physics_merge/src/orxonox/objects/worldentities/CMakeLists.txt

    r2420 r2442  
    11SET( SRC_FILES
    22  WorldEntity.cc
    3   PositionableEntity.cc
     3  StaticEntity.cc
    44  MovableEntity.cc
     5  MobileEntity.cc
    56  ControllableEntity.cc
    67  Model.cc
  • code/branches/physics_merge/src/orxonox/objects/worldentities/Camera.cc

    r2420 r2442  
    4848    CreateFactory(Camera);
    4949
    50     Camera::Camera(BaseObject* creator) : PositionableEntity(creator)
     50    Camera::Camera(BaseObject* creator) : StaticEntity(creator)
    5151    {
    5252        RegisterObject(Camera);
     
    5656
    5757        this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
    58         this->getNode()->attachObject(this->camera_);
     58        this->attachOgreObject(this->camera_);
    5959
    6060        this->bHasFocus_ = false;
  • code/branches/physics_merge/src/orxonox/objects/worldentities/Camera.h

    r2420 r2442  
    3333
    3434#include <OgrePrerequisites.h>
    35 #include "objects/worldentities/PositionableEntity.h"
     35#include "objects/worldentities/StaticEntity.h"
    3636#include "objects/Tickable.h"
    3737
    3838namespace orxonox
    3939{
    40     class _OrxonoxExport Camera : public PositionableEntity, public Tickable
     40    class _OrxonoxExport Camera : public StaticEntity, public Tickable
    4141    {
    4242        friend class CameraManager;
  • code/branches/physics_merge/src/orxonox/objects/worldentities/CameraPosition.cc

    r2087 r2442  
    3838    CreateFactory(CameraPosition);
    3939
    40     CameraPosition::CameraPosition(BaseObject* creator) : PositionableEntity(creator)
     40    CameraPosition::CameraPosition(BaseObject* creator) : StaticEntity(creator)
    4141    {
    4242        RegisterObject(CameraPosition);
  • code/branches/physics_merge/src/orxonox/objects/worldentities/CameraPosition.h

    r2087 r2442  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "objects/worldentities/PositionableEntity.h"
     34#include "objects/worldentities/StaticEntity.h"
    3535
    3636namespace orxonox
    3737{
    38     class _OrxonoxExport CameraPosition : public PositionableEntity
     38    class _OrxonoxExport CameraPosition : public StaticEntity
    3939    {
    4040        public:
  • code/branches/physics_merge/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2415 r2442  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder
    2626 *
    2727 */
     
    4444    CreateFactory(ControllableEntity);
    4545
    46     ControllableEntity::ControllableEntity(BaseObject* creator) : WorldEntity(creator)
     46    ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator)
    4747    {
    4848        RegisterObject(ControllableEntity);
     
    5757        this->bDestroyWhenPlayerLeft_ = false;
    5858
    59         this->velocity_ = Vector3::ZERO;
    60         this->acceleration_ = Vector3::ZERO;
    61 
    62         this->server_position_ = Vector3::ZERO;
    63         this->client_position_ = Vector3::ZERO;
    64         this->server_velocity_ = Vector3::ZERO;
    65         this->client_velocity_ = Vector3::ZERO;
    66         this->server_orientation_ = Quaternion::IDENTITY;
    67         this->client_orientation_ = Quaternion::IDENTITY;
    68        
     59        this->server_position_        = Vector3::ZERO;
     60        this->client_position_        = Vector3::ZERO;
     61        this->server_linear_velocity_  = Vector3::ZERO;
     62        this->client_linear_velocity_ = Vector3::ZERO;
     63        this->server_orientation_      = Quaternion::IDENTITY;
     64        this->client_orientation_      = Quaternion::IDENTITY;
     65        this->server_angular_velocity_ = Vector3::ZERO;
     66        this->client_angular_velocity_ = Vector3::ZERO;
     67
     68
    6969        this->setPriority( priority::very_high );
    70 
    7170        this->registerVariables();
    7271    }
     
    229228    void ControllableEntity::tick(float dt)
    230229    {
     230        MobileEntity::tick(dt);
     231
    231232        if (this->isActive())
    232233        {
    233             this->velocity_ += (dt * this->acceleration_);
    234             this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
    235 
    236             if (Core::isMaster())
     234            // Check whether Bullet doesn't do the physics for us
     235            if (!this->isDynamic())
    237236            {
    238                 this->server_velocity_ = this->velocity_;
    239                 this->server_position_ = this->node_->getPosition();
     237                if (Core::isMaster())
     238                {
     239                    this->server_position_ = this->getPosition();
     240                    this->server_orientation_ = this->getOrientation();
     241                    this->server_linear_velocity_ = this->getVelocity();
     242                    this->server_angular_velocity_ = this->getAngularVelocity();
     243                }
     244                else if (this->bControlled_)
     245                {
     246                    this->client_position_ = this->getPosition();
     247                    this->client_orientation_ = this->getOrientation();
     248                    this->client_linear_velocity_ = this->getVelocity();
     249                    this->client_angular_velocity_ = this->getAngularVelocity();
     250                }
    240251            }
    241             else if (this->bControlled_)
    242             {
    243 //                COUT(2) << "setting client position" << endl;
    244                 this->client_velocity_ = this->velocity_;
    245                 this->client_position_ = this->node_->getPosition();
    246             }
    247252        }
    248253    }
     
    251256    {
    252257        registerVariable(this->cameraPositionTemplate_, variableDirection::toclient);
    253  
    254         registerVariable(this->client_overwrite_,   variableDirection::toserver);
    255          
    256         registerVariable(this->server_position_,    variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    257         registerVariable(this->server_velocity_,    variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
    258         registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    259         registerVariable(this->server_overwrite_,   variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    260  
    261         registerVariable(this->client_position_,    variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
    262         registerVariable(this->client_velocity_,    variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
    263         registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    264  
    265  
    266         registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     258
     259        registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     260        registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
     261        registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
     262        registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
     263
     264        registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
     265        registerVariable(this->client_overwrite_,        variableDirection::toserver);
     266
     267        registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
     268        registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
     269        registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
     270        registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     271
     272        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
    267273    }
    268274
     
    270276    {
    271277        if (!this->bControlled_)
    272             this->node_->setPosition(this->server_position_);
    273     }
    274 
    275     void ControllableEntity::processServerVelocity()
     278            this->setPosition(this->server_position_);
     279    }
     280
     281    void ControllableEntity::processServerLinearVelocity()
    276282    {
    277283        if (!this->bControlled_)
    278             this->velocity_ = this->server_velocity_;
     284            this->setVelocity(this->server_linear_velocity_);
    279285    }
    280286
     
    282288    {
    283289        if (!this->bControlled_)
    284             this->node_->setOrientation(this->server_orientation_);
     290            this->setOrientation(this->server_orientation_);
     291    }
     292
     293    void ControllableEntity::processServerAngularVelocity()
     294    {
     295        if (!this->bControlled_)
     296            this->setAngularVelocity(this->server_angular_velocity_);
    285297    }
    286298
     
    290302        {
    291303            this->setPosition(this->server_position_);
    292             this->setVelocity(this->server_velocity_);
    293304            this->setOrientation(this->server_orientation_);
     305            this->setVelocity(this->server_linear_velocity_);
     306            this->setAngularVelocity(this->server_angular_velocity_);
    294307
    295308            this->client_overwrite_ = this->server_overwrite_;
     
    301314        if (this->server_overwrite_ == this->client_overwrite_)
    302315        {
    303 //            COUT(2) << "callback: setting client position" << endl;
    304             this->node_->setPosition(this->client_position_);
    305             this->server_position_ = this->client_position_;
    306         }
    307 //        else
    308 //          COUT(2) << "callback: not setting client position" << endl;
    309     }
    310 
    311     void ControllableEntity::processClientVelocity()
     316            this->setPosition(this->client_position_);
     317            // The call above increments the overwrite. This is not desired to reduce traffic
     318            --this->server_overwrite_;
     319        }
     320    }
     321
     322    void ControllableEntity::processClientLinearVelocity()
    312323    {
    313324        if (this->server_overwrite_ == this->client_overwrite_)
    314325        {
    315             this->velocity_ = this->client_velocity_;
    316             this->server_velocity_ = this->client_velocity_;
     326            this->setVelocity(this->client_linear_velocity_);
     327            // The call above increments the overwrite. This is not desired to reduce traffic
     328            --this->server_overwrite_;
    317329        }
    318330    }
     
    322334        if (this->server_overwrite_ == this->client_overwrite_)
    323335        {
    324             this->node_->setOrientation(this->client_orientation_);
    325             this->server_orientation_ = this->client_orientation_;
    326         }
    327     }
    328 
     336            this->setOrientation(this->client_orientation_);
     337            // The call above increments the overwrite. This is not desired to reduce traffic
     338            --this->server_overwrite_;
     339        }
     340    }
     341
     342    void ControllableEntity::processClientAngularVelocity()
     343    {
     344        if (this->server_overwrite_ == this->client_overwrite_)
     345        {
     346            this->setAngularVelocity(this->client_angular_velocity_);
     347            // The call above increments the overwrite. This is not desired to reduce traffic
     348            --this->server_overwrite_;
     349        }
     350    }
    329351
    330352    void ControllableEntity::setPosition(const Vector3& position)
     
    332354        if (Core::isMaster())
    333355        {
    334             this->node_->setPosition(position);
    335             this->server_position_ = position;
     356            MobileEntity::setPosition(position);
     357            this->server_position_ = this->getPosition();
    336358            ++this->server_overwrite_;
    337359        }
    338360        else if (this->bControlled_)
    339361        {
    340             this->node_->setPosition(position);
    341             this->client_position_ = position;
     362            MobileEntity::setPosition(position);
     363            this->client_position_ = this->getPosition();
     364        }
     365    }
     366
     367    void ControllableEntity::setOrientation(const Quaternion& orientation)
     368    {
     369        if (Core::isMaster())
     370        {
     371            MobileEntity::setOrientation(orientation);
     372            this->server_orientation_ = this->getOrientation();
     373            ++this->server_overwrite_;
     374        }
     375        else if (this->bControlled_)
     376        {
     377            MobileEntity::setOrientation(orientation);
     378            this->client_orientation_ = this->getOrientation();
    342379        }
    343380    }
     
    347384        if (Core::isMaster())
    348385        {
    349             this->velocity_ = velocity;
    350             this->server_velocity_ = velocity;
     386            MobileEntity::setVelocity(velocity);
     387            this->server_linear_velocity_ = this->getVelocity();
    351388            ++this->server_overwrite_;
    352389        }
    353390        else if (this->bControlled_)
    354391        {
    355             this->velocity_ = velocity;
    356             this->client_velocity_ = velocity;
    357         }
    358     }
    359 
    360     void ControllableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
     392            MobileEntity::setVelocity(velocity);
     393            this->client_linear_velocity_ = this->getVelocity();
     394        }
     395    }
     396
     397    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    361398    {
    362399        if (Core::isMaster())
    363400        {
    364             this->node_->translate(distance, relativeTo);
    365             this->server_position_ = this->node_->getPosition();
     401            MobileEntity::setAngularVelocity(velocity);
     402            this->server_angular_velocity_ = this->getAngularVelocity();
    366403            ++this->server_overwrite_;
    367404        }
    368405        else if (this->bControlled_)
    369406        {
    370             this->node_->translate(distance, relativeTo);
    371             this->client_position_ = this->node_->getPosition();
    372         }
    373     }
    374 
    375     void ControllableEntity::setOrientation(const Quaternion& orientation)
    376     {
     407            MobileEntity::setAngularVelocity(velocity);
     408            this->client_angular_velocity_ = this->getAngularVelocity();
     409        }
     410    }
     411
     412    void ControllableEntity::setWorldTransform(const btTransform& worldTrans)
     413    {
     414        MobileEntity::setWorldTransform(worldTrans);
    377415        if (Core::isMaster())
    378416        {
    379             this->node_->setOrientation(orientation);
    380             this->server_orientation_ = orientation;
    381             ++this->server_overwrite_;
     417            this->server_position_ = this->getPosition();
     418            this->server_orientation_ = this->getOrientation();
     419            this->server_linear_velocity_ = this->getVelocity();
     420            this->server_angular_velocity_ = this->getAngularVelocity();
    382421        }
    383422        else if (this->bControlled_)
    384423        {
    385             this->node_->setOrientation(orientation);
    386             this->client_orientation_ = orientation;
    387         }
    388     }
    389 
    390     void ControllableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    391     {
    392         if (Core::isMaster())
    393         {
    394             this->node_->rotate(rotation, relativeTo);
    395             this->server_orientation_ = this->node_->getOrientation();
    396             ++this->server_overwrite_;
    397         }
    398         else if (this->bControlled_)
    399         {
    400             this->node_->rotate(rotation, relativeTo);
    401             this->client_orientation_ = this->node_->getOrientation();
    402         }
    403     }
    404 
    405     void ControllableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    406     {
    407         if (Core::isMaster())
    408         {
    409             this->node_->yaw(angle, relativeTo);
    410             this->server_orientation_ = this->node_->getOrientation();
    411             ++this->server_overwrite_;
    412         }
    413         else if (this->bControlled_)
    414         {
    415             this->node_->yaw(angle, relativeTo);
    416             this->client_orientation_ = this->node_->getOrientation();
    417         }
    418     }
    419 
    420     void ControllableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    421     {
    422         if (Core::isMaster())
    423         {
    424             this->node_->pitch(angle, relativeTo);
    425             this->server_orientation_ = this->node_->getOrientation();
    426             ++this->server_overwrite_;
    427         }
    428         else if (this->bControlled_)
    429         {
    430             this->node_->pitch(angle, relativeTo);
    431             this->client_orientation_ = this->node_->getOrientation();
    432         }
    433     }
    434 
    435     void ControllableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    436     {
    437         if (Core::isMaster())
    438         {
    439             this->node_->roll(angle, relativeTo);
    440             this->server_orientation_ = this->node_->getOrientation();
    441             ++this->server_overwrite_;
    442         }
    443         else if (this->bControlled_)
    444         {
    445             this->node_->roll(angle, relativeTo);
    446             this->client_orientation_ = this->node_->getOrientation();
    447         }
    448     }
    449 
    450     void ControllableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    451     {
    452         if (Core::isMaster())
    453         {
    454             this->node_->lookAt(target, relativeTo, localDirectionVector);
    455             this->server_orientation_ = this->node_->getOrientation();
    456             ++this->server_overwrite_;
    457         }
    458         else if (this->bControlled_)
    459         {
    460             this->node_->lookAt(target, relativeTo, localDirectionVector);
    461             this->client_orientation_ = this->node_->getOrientation();
    462         }
    463     }
    464 
    465     void ControllableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    466     {
    467         if (Core::isMaster())
    468         {
    469             this->node_->setDirection(direction, relativeTo, localDirectionVector);
    470             this->server_orientation_ = this->node_->getOrientation();
    471             ++this->server_overwrite_;
    472         }
    473         else if (this->bControlled_)
    474         {
    475             this->node_->setDirection(direction, relativeTo, localDirectionVector);
    476             this->client_orientation_ = this->node_->getOrientation();
     424            this->client_position_ = this->getPosition();
     425            this->client_orientation_ = this->getOrientation();
     426            this->client_linear_velocity_ = this->getVelocity();
     427            this->client_angular_velocity_ = this->getAngularVelocity();
    477428        }
    478429    }
  • code/branches/physics_merge/src/orxonox/objects/worldentities/ControllableEntity.h

    r2087 r2442  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder
    2626 *
    2727 */
     
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "WorldEntity.h"
    35 #include "objects/Tickable.h"
     34#include "MobileEntity.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport ControllableEntity : public WorldEntity, public Tickable
     38    class _OrxonoxExport ControllableEntity : public MobileEntity
    4039    {
    4140        public:
     
    7271            virtual void switchCamera();
    7372
    74             inline const Vector3& getVelocity() const
    75                 { return this->velocity_; }
    76             inline const Vector3& getAcceleration() const
    77                 { return this->acceleration_; }
    7873            inline const std::string& getHudTemplate() const
    7974                { return this->hudtemplate_; }
    80 
    81             using WorldEntity::setPosition;
    82             using WorldEntity::translate;
    83             using WorldEntity::setOrientation;
    84             using WorldEntity::rotate;
    85             using WorldEntity::yaw;
    86             using WorldEntity::pitch;
    87             using WorldEntity::roll;
    88             using WorldEntity::lookAt;
    89             using WorldEntity::setDirection;
    90 
    91             void setPosition(const Vector3& position);
    92             void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    93             void setOrientation(const Quaternion& orientation);
    94             void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    95             void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    96             void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    97             void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    98             void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    99             void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    100 
    101             void setVelocity(const Vector3& velocity);
    102             inline void setVelocity(float x, float y, float z)
    103                 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
    104 
    105             inline void setAcceleration(const Vector3& acceleration)
    106                 { this->acceleration_ = acceleration; }
    107             inline void setAcceleration(float x, float y, float z)
    108                 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
    10975
    11076            inline Camera* getCamera() const
     
    12389                { return this->cameraPositionTemplate_; }
    12490
     91            using WorldEntity::setPosition;
     92            using WorldEntity::setOrientation;
     93            using MobileEntity::setVelocity;
     94            using MobileEntity::setAngularVelocity;
     95
     96            void setPosition(const Vector3& position);
     97            void setOrientation(const Quaternion& orientation);
     98            void setVelocity(const Vector3& velocity);
     99            void setAngularVelocity(const Vector3& velocity);
     100
    125101        protected:
    126102            virtual void startLocalControl();
     
    133109                { return this->bControlled_; }
    134110
    135             Vector3 acceleration_;
    136 
    137111        private:
    138112            void overwrite();
     
    140114
    141115            void processServerPosition();
    142             void processServerVelocity();
     116            void processServerLinearVelocity();
    143117            void processServerOrientation();
     118            void processServerAngularVelocity();
    144119
    145120            void processClientPosition();
    146             void processClientVelocity();
     121            void processClientLinearVelocity();
    147122            void processClientOrientation();
     123            void processClientAngularVelocity();
    148124
    149125            void networkcallback_changedplayerID();
     126
     127            // Bullet btMotionState related
     128            void setWorldTransform(const btTransform& worldTrans);
    150129
    151130            unsigned int server_overwrite_;
    152131            unsigned int client_overwrite_;
    153132
    154             Vector3 velocity_;
    155 
    156133            bool bControlled_;
    157134            Vector3 server_position_;
    158135            Vector3 client_position_;
    159             Vector3 server_velocity_;
    160             Vector3 client_velocity_;
     136            Vector3 server_linear_velocity_;
     137            Vector3 client_linear_velocity_;
    161138            Quaternion server_orientation_;
    162139            Quaternion client_orientation_;
     140            Vector3 server_angular_velocity_;
     141            Vector3 client_angular_velocity_;
    163142
    164143            PlayerInfo* player_;
  • code/branches/physics_merge/src/orxonox/objects/worldentities/Light.cc

    r2371 r2442  
    4747    CreateFactory(Light);
    4848
    49     Light::Light(BaseObject* creator) : PositionableEntity(creator)
     49    Light::Light(BaseObject* creator) : StaticEntity(creator)
    5050    {
    5151        RegisterObject(Light);
     
    5353        if (this->getScene() && this->getScene()->getSceneManager())
    5454        this->light_ = this->getScene()->getSceneManager()->createLight("Light" + convertToString(Light::lightCounter_s++));
    55         this->getNode()->attachObject(this->light_);
     55        this->attachOgreObject(this->light_);
    5656
    5757        this->registerVariables();
  • code/branches/physics_merge/src/orxonox/objects/worldentities/Light.h

    r2087 r2442  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434
    3535#include <string>
     
    4040namespace orxonox
    4141{
    42     class _OrxonoxExport Light : public PositionableEntity
     42    class _OrxonoxExport Light : public StaticEntity
    4343    {
    4444        public:
  • code/branches/physics_merge/src/orxonox/objects/worldentities/Model.cc

    r2415 r2442  
    2929#include "OrxonoxStableHeaders.h"
    3030
     31#include <OgreEntity.h>
    3132#include "Model.h"
    3233#include "core/CoreIncludes.h"
     
    3839    CreateFactory(Model);
    3940
    40     Model::Model(BaseObject* creator) : PositionableEntity(creator)
     41    Model::Model(BaseObject* creator) : StaticEntity(creator)
    4142    {
    4243        RegisterObject(Model);
     
    4849    {
    4950        if (this->isInitialized() && this->mesh_.getEntity())
    50             this->getNode()->detachObject(this->mesh_.getEntity());
     51            this->detachOgreObject(this->mesh_.getEntity());
    5152    }
    5253
     
    6869    {
    6970        if (this->mesh_.getEntity())
    70             this->getNode()->detachObject(this->mesh_.getEntity());
     71            this->detachOgreObject(this->mesh_.getEntity());
    7172
    7273        this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
     
    7475        if (this->mesh_.getEntity())
    7576        {
    76             this->getNode()->attachObject(this->mesh_.getEntity());
     77            this->attachOgreObject(this->mesh_.getEntity());
    7778            this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
    7879            this->mesh_.setVisible(this->isVisible());
  • code/branches/physics_merge/src/orxonox/objects/worldentities/Model.h

    r2087 r2442  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434#include "tools/Mesh.h"
    3535
    3636namespace orxonox
    3737{
    38     class _OrxonoxExport Model : public PositionableEntity
     38    class _OrxonoxExport Model : public StaticEntity
    3939    {
    4040        public:
     
    7070}
    7171
    72 #endif /* _PositionableEntity_H__ */
     72#endif /* _Model_H__ */
  • code/branches/physics_merge/src/orxonox/objects/worldentities/MovableEntity.cc

    r2415 r2442  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder
    2425 *   Co-authors:
    2526 *      ...
     
    3839{
    3940    static const float MAX_RESYNCHRONIZE_TIME = 3.0f;
     41    static const float CONTINUOUS_SYNCHRONIZATION_TIME = 10.0f;
    4042
    4143    CreateFactory(MovableEntity);
    4244
    43     MovableEntity::MovableEntity(BaseObject* creator) : WorldEntity(creator)
     45    MovableEntity::MovableEntity(BaseObject* creator) : MobileEntity(creator)
    4446    {
    4547        RegisterObject(MovableEntity);
    4648
    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;
     49        this->overwrite_position_    = Vector3::ZERO;
    5450        this->overwrite_orientation_ = Quaternion::IDENTITY;
    5551       
    5652        this->setPriority( priority::low );
     53
     54        // Resynchronise every few seconds because we only work with velocities (no positions)
     55        continuousResynchroTimer_ = new Timer<MovableEntity>(CONTINUOUS_SYNCHRONIZATION_TIME + rnd(-1, 1),
     56                true, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), false);
    5757
    5858        this->registerVariables();
     
    6161    MovableEntity::~MovableEntity()
    6262    {
     63        if (this->isInitialized())
     64            delete this->continuousResynchroTimer_;
    6365    }
    6466
     
    6668    {
    6769        SUPER(MovableEntity, XMLPort, xmlelement, mode);
    68 
    69         XMLPortParamTemplate(MovableEntity, "velocity", setVelocity, getVelocity, xmlelement, mode, const Vector3&);
    70         XMLPortParamTemplate(MovableEntity, "rotationaxis", setRotationAxis, getRotationAxis, xmlelement, mode, const Vector3&);
    71         XMLPortParamTemplate(MovableEntity, "rotationrate", setRotationRate, getRotationRate, xmlelement, mode, const Degree&);
    72     }
    73 
    74     void MovableEntity::tick(float dt)
    75     {
    76         if (this->isActive())
    77         {
    78             this->velocity_ += (dt * this->acceleration_);
    79             this->node_->translate(dt * this->velocity_);
    80 
    81             this->rotationRate_ += (dt * this->momentum_);
    82             this->node_->rotate(this->rotationAxis_, this->rotationRate_  * dt);
    83         }
    8470    }
    8571
    8672    void MovableEntity::registerVariables()
    8773    {
    88         registerVariable(this->velocity_.x, variableDirection::toclient);
    89         registerVariable(this->velocity_.y, variableDirection::toclient);
    90         registerVariable(this->velocity_.z, variableDirection::toclient);
    91  
    92         registerVariable(this->rotationAxis_.x, variableDirection::toclient);
    93         registerVariable(this->rotationAxis_.y, variableDirection::toclient);
    94         registerVariable(this->rotationAxis_.z, variableDirection::toclient);
    95  
    96         registerVariable(this->rotationRate_, variableDirection::toclient);
    97  
     74        registerVariable(this->linearVelocity_,        variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity));
     75        registerVariable(this->angularVelocity_,       variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processAngularVelocity));
     76
    9877        registerVariable(this->overwrite_position_,    variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
    9978        registerVariable(this->overwrite_orientation_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
    100     }
    101 
    102     void MovableEntity::overwritePosition()
    103     {
    104         this->node_->setPosition(this->overwrite_position_);
    105     }
    106 
    107     void MovableEntity::overwriteOrientation()
    108     {
    109         this->node_->setOrientation(this->overwrite_orientation_);
    11079    }
    11180
     
    12493        this->overwrite_orientation_ = this->getOrientation();
    12594    }
    126 
    127     void MovableEntity::setPosition(const Vector3& position)
    128     {
    129         this->node_->setPosition(position);
    130         this->overwrite_position_ = this->node_->getPosition();
    131     }
    132 
    133     void MovableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
    134     {
    135         this->node_->translate(distance, relativeTo);
    136         this->overwrite_position_ = this->node_->getPosition();
    137     }
    138 
    139     void MovableEntity::setOrientation(const Quaternion& orientation)
    140     {
    141         this->node_->setOrientation(orientation);
    142         this->overwrite_orientation_ = this->node_->getOrientation();
    143     }
    144 
    145     void MovableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    146     {
    147         this->node_->rotate(rotation, relativeTo);
    148         this->overwrite_orientation_ = this->node_->getOrientation();
    149     }
    150 
    151     void MovableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    152     {
    153         this->node_->yaw(angle, relativeTo);
    154         this->overwrite_orientation_ = this->node_->getOrientation();
    155     }
    156 
    157     void MovableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    158     {
    159         this->node_->pitch(angle, relativeTo);
    160         this->overwrite_orientation_ = this->node_->getOrientation();
    161     }
    162 
    163     void MovableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    164     {
    165         this->node_->roll(angle, relativeTo);
    166         this->overwrite_orientation_ = this->node_->getOrientation();
    167     }
    168 
    169     void MovableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    170     {
    171         this->node_->lookAt(target, relativeTo, localDirectionVector);
    172         this->overwrite_orientation_ = this->node_->getOrientation();
    173     }
    174 
    175     void MovableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    176     {
    177         this->node_->setDirection(direction, relativeTo, localDirectionVector);
    178         this->overwrite_orientation_ = this->node_->getOrientation();
    179     }
    18095}
  • code/branches/physics_merge/src/orxonox/objects/worldentities/MovableEntity.h

    r2171 r2442  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder
    2425 *   Co-authors:
    2526 *      ...
     
    3233#include "OrxonoxPrereqs.h"
    3334
    34 #include "WorldEntity.h"
    35 #include "objects/Tickable.h"
     35#include "MobileEntity.h"
    3636#include "network/ClientConnectionListener.h"
    3737
    3838namespace orxonox
    3939{
    40     class _OrxonoxExport MovableEntity : public WorldEntity, public Tickable, public ClientConnectionListener
     40    class _OrxonoxExport MovableEntity : public MobileEntity, public ClientConnectionListener
    4141    {
    4242        public:
     
    4545
    4646            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    47             virtual void tick(float dt);
    4847            void registerVariables();
    4948
    5049            using WorldEntity::setPosition;
    51             using WorldEntity::translate;
    5250            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;
    5951
    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);
    69 
    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_; }
    76 
    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_; }
     52            inline void setPosition(const Vector3& position)
     53                { MobileEntity::setPosition(position); this->overwrite_position_ = this->getPosition(); }
     54            inline void setOrientation(const Quaternion& orientation)
     55                { MobileEntity::setOrientation(orientation); this->overwrite_orientation_ = this->getOrientation(); }
    10456
    10557        private:
     
    10860            void resynchronize();
    10961
    110             void overwritePosition();
    111             void overwriteOrientation();
     62            inline void processLinearVelocity()
     63                { this->setVelocity(this->linearVelocity_); }
     64            inline void processAngularVelocity()
     65                { this->setAngularVelocity(this->angularVelocity_); }
    11266
    113             Vector3 velocity_;
    114             Vector3 acceleration_;
    115             Vector3 rotationAxis_;
    116             Degree rotationRate_;
    117             Degree momentum_;
     67            inline void overwritePosition()
     68                { this->setPosition(this->overwrite_position_); }
     69            inline void overwriteOrientation()
     70                { this->setOrientation(this->overwrite_orientation_); }
    11871
    119             Vector3 overwrite_position_;
     72            Vector3    overwrite_position_;
    12073            Quaternion overwrite_orientation_;
     74            Timer<MovableEntity>* continuousResynchroTimer_;
    12175    };
    12276}
  • code/branches/physics_merge/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r2371 r2442  
    3333
    3434#include "OrxonoxStableHeaders.h"
     35#include "ParticleEmitter.h"
    3536
    36 #include "ParticleEmitter.h"
     37#include <OgreParticleSystem.h>
    3738
    3839#include "tools/ParticleInterface.h"
     
    4647    CreateFactory(ParticleEmitter);
    4748
    48     ParticleEmitter::ParticleEmitter(BaseObject* creator) : PositionableEntity(creator)
     49    ParticleEmitter::ParticleEmitter(BaseObject* creator) : StaticEntity(creator)
    4950    {
    5051        RegisterObject(ParticleEmitter);
     
    6263    {
    6364        if (this->isInitialized() && this->particles_)
     65        {
     66            this->detachOgreObject(this->particles_->getParticleSystem());
    6467            delete this->particles_;
     68        }
    6569    }
    6670
     
    105109            {
    106110                this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), this->source_, this->LOD_);
    107                 this->particles_->addToSceneNode(this->getNode());
     111                this->attachOgreObject(particles_->getParticleSystem());
    108112                this->particles_->setVisible(this->isVisible());
    109113                this->particles_->setEnabled(this->isActive());
  • code/branches/physics_merge/src/orxonox/objects/worldentities/ParticleEmitter.h

    r2087 r2442  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434
    3535namespace orxonox
    3636{
    37     class _OrxonoxExport ParticleEmitter : public PositionableEntity
     37    class _OrxonoxExport ParticleEmitter : public StaticEntity
    3838    {
    3939        public:
  • code/branches/physics_merge/src/orxonox/objects/worldentities/ParticleSpawner.cc

  • code/branches/physics_merge/src/orxonox/objects/worldentities/ParticleSpawner.h

  • code/branches/physics_merge/src/orxonox/objects/worldentities/Planet.cc

    r2436 r2442  
    6363    {
    6464        if (this->isInitialized() && this->mesh_.getEntity())
    65             this->getNode()->detachObject(this->mesh_.getEntity());
     65            this->detachOgreObject(this->mesh_.getEntity());
    6666    }   
    6767
     
    108108        billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));
    109109
    110         this->getNode()->attachObject(this->billboard_.getBillboardSet());   
     110        this->attachOgreObject(this->billboard_.getBillboardSet());   
    111111        this->billboard_.getBillboardSet()->setUseAccurateFacing(true);
    112112        this->setCastShadows(true);
     
    118118    {
    119119        if (this->mesh_.getEntity())
    120             this->getNode()->detachObject(this->mesh_.getEntity());
     120            this->detachOgreObject(this->mesh_.getEntity());
    121121
    122122        this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
     
    124124        if (this->mesh_.getEntity())
    125125        {
    126             this->getNode()->attachObject(this->mesh_.getEntity());
     126            this->attachOgreObject(this->mesh_.getEntity());
    127127            this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
    128128            this->mesh_.setVisible(this->isVisible());
  • code/branches/physics_merge/src/orxonox/objects/worldentities/SpawnPoint.cc

    r2087 r2442  
    3838    CreateFactory(SpawnPoint);
    3939
    40     SpawnPoint::SpawnPoint(BaseObject* creator) : PositionableEntity(creator)
     40    SpawnPoint::SpawnPoint(BaseObject* creator) : StaticEntity(creator)
    4141    {
    4242        RegisterObject(SpawnPoint);
  • code/branches/physics_merge/src/orxonox/objects/worldentities/SpawnPoint.h

    r2087 r2442  
    3434#include "core/Identifier.h"
    3535#include "core/Template.h"
    36 #include "PositionableEntity.h"
    3736#include "objects/worldentities/pawns/Pawn.h"
     37#include "objects/worldentities/StaticEntity.h"
    3838
    3939namespace orxonox
    4040{
    41     class _OrxonoxExport SpawnPoint : public PositionableEntity
     41    class _OrxonoxExport SpawnPoint : public StaticEntity
    4242    {
    4343        public:
  • code/branches/physics_merge/src/orxonox/objects/worldentities/StaticEntity.cc

    r2440 r2442  
    4444    {
    4545        RegisterObject(StaticEntity);
     46       
     47        this->setPriority(priority::very_low);
    4648
    4749        this->registerVariables();
     
    5456    void StaticEntity::registerVariables()
    5557    {
    56         REGISTERDATA(this->getPosition(),    network::direction::toclient, new network::NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
    57         REGISTERDATA(this->getOrientation(), network::direction::toclient, new network::NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
     58        registerVariable(this->getPosition(),    variableDirection::toclient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
     59        registerVariable(this->getOrientation(), variableDirection::toclient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
    5860    }
    5961
  • code/branches/physics_merge/src/orxonox/objects/worldentities/WorldEntity.cc

    r2371 r2442  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder (physics)
    2425 *   Co-authors:
    2526 *      ...
     
    3132
    3233#include <cassert>
     34#include <OgreSceneNode.h>
    3335#include <OgreSceneManager.h>
    34 
     36#include "BulletDynamics/Dynamics/btRigidBody.h"
     37
     38#include "util/Exception.h"
     39#include "util/Convert.h"
    3540#include "core/CoreIncludes.h"
    3641#include "core/XMLPort.h"
    37 #include "util/Convert.h"
    38 #include "util/Exception.h"
    3942
    4043#include "objects/Scene.h"
     44#include "objects/collisionshapes/CompoundCollisionShape.h"
    4145
    4246namespace orxonox
     
    6468        this->node_->setOrientation(Quaternion::IDENTITY);
    6569
     70        // Default behaviour does not include physics
     71        this->physicalBody_ = 0;
     72        this->bPhysicsActive_ = false;
     73        this->collisionShape_ = new CompoundCollisionShape(this);
     74        this->collisionType_ = None;
     75        this->collisionTypeSynchronised_ = None;
     76        this->mass_           = 0;
     77        this->childrenMass_   = 0;
     78        // Use bullet default values
     79        this->restitution_    = 0;
     80        this->angularFactor_  = 1;
     81        this->linearDamping_  = 0;
     82        this->angularDamping_ = 0;
     83        this->friction_       = 0.5;
     84
    6685        this->registerVariables();
    6786    }
     
    7493            if (this->getScene()->getSceneManager())
    7594                this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
     95
     96            // TODO: Detach from parent and detach all children.
     97
     98            if (this->physicalBody_)
     99            {
     100                this->deactivatePhysics();
     101                delete this->physicalBody_;
     102            }
     103            delete this->collisionShape_;
    76104        }
    77105    }
     
    81109        SUPER(WorldEntity, XMLPort, xmlelement, mode);
    82110
    83         XMLPortParamTemplate(WorldEntity, "position", setPosition, getPosition, xmlelement, mode, const Vector3&);
     111        XMLPortParamTemplate(WorldEntity, "position",    setPosition,    getPosition,    xmlelement, mode, const Vector3&);
    84112        XMLPortParamTemplate(WorldEntity, "orientation", setOrientation, getOrientation, xmlelement, mode, const Quaternion&);
    85         XMLPortParamLoadOnly(WorldEntity, "lookat", lookAt_xmlport, xmlelement, mode);
    86         XMLPortParamLoadOnly(WorldEntity, "direction", setDirection_xmlport, xmlelement, mode);
    87         XMLPortParamLoadOnly(WorldEntity, "yaw", yaw_xmlport, xmlelement, mode);
    88         XMLPortParamLoadOnly(WorldEntity, "pitch", pitch_xmlport, xmlelement, mode);
    89         XMLPortParamLoadOnly(WorldEntity, "roll", roll_xmlport, xmlelement, mode);
    90         XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&);
    91         XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, mode);
    92 
     113        XMLPortParamTemplate(WorldEntity, "scale3D",     setScale3D,     getScale3D,     xmlelement, mode, const Vector3&);
     114        XMLPortParam        (WorldEntity, "scale",       setScale,       getScale,       xmlelement, mode);
     115        XMLPortParamLoadOnly(WorldEntity, "lookat",      lookAt_xmlport,       xmlelement, mode);
     116        XMLPortParamLoadOnly(WorldEntity, "direction",   setDirection_xmlport, xmlelement, mode);
     117        XMLPortParamLoadOnly(WorldEntity, "yaw",         yaw_xmlport,          xmlelement, mode);
     118        XMLPortParamLoadOnly(WorldEntity, "pitch",       pitch_xmlport,        xmlelement, mode);
     119        XMLPortParamLoadOnly(WorldEntity, "roll",        roll_xmlport,         xmlelement, mode);
     120
     121        // Physics
     122        XMLPortParam(WorldEntity, "collisionType",  setCollisionTypeStr, getCollisionTypeStr, xmlelement, mode);
     123        XMLPortParam(WorldEntity, "mass",           setMass,             getMass,             xmlelement, mode);
     124        XMLPortParam(WorldEntity, "restitution",    setRestitution,      getRestitution,      xmlelement, mode);
     125        XMLPortParam(WorldEntity, "angularFactor",  setAngularFactor,    getAngularFactor,    xmlelement, mode);
     126        XMLPortParam(WorldEntity, "linearDamping",  setLinearDamping,    getLinearDamping,    xmlelement, mode);
     127        XMLPortParam(WorldEntity, "angularDamping", setAngularDamping,   getAngularDamping,   xmlelement, mode);
     128        XMLPortParam(WorldEntity, "friction",       setFriction,         getFriction,         xmlelement, mode);
     129
     130        // Other attached WorldEntities
    93131        XMLPortObject(WorldEntity, WorldEntity, "attached", attach, getAttachedObject, xmlelement, mode);
     132        // Attached collision shapes
     133        XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode);
    94134    }
    95135
    96136    void WorldEntity::registerVariables()
    97137    {
    98         registerVariable(this->bActive_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
    99         registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
    100  
    101         registerVariable(this->getScale3D().x, variableDirection::toclient);
    102         registerVariable(this->getScale3D().y, variableDirection::toclient);
    103         registerVariable(this->getScale3D().z, variableDirection::toclient);
    104  
    105         registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
    106     }
    107 
    108     void WorldEntity::updateParent()
     138        registerVariable(this->bActive_,        variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
     139        registerVariable(this->bVisible_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
     140
     141        registerVariable(this->getScale3D(),    variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged));
     142
     143        registerVariable((int&)this->collisionTypeSynchronised_,
     144                                                variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged));
     145        registerVariable(this->mass_,           variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged));
     146        registerVariable(this->restitution_,    variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::restitutionChanged));
     147        registerVariable(this->angularFactor_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularFactorChanged));
     148        registerVariable(this->linearDamping_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::linearDampingChanged));
     149        registerVariable(this->angularDamping_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged));
     150        registerVariable(this->friction_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged));
     151        registerVariable(this->bPhysicsActiveSynchronised_,
     152                                                variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged));
     153
     154        registerVariable(this->parentID_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::parentChanged));
     155    }
     156
     157    void WorldEntity::parentChanged()
    109158    {
    110159        if (this->parentID_ != OBJECTID_UNKNOWN)
     
    116165    }
    117166
     167    void WorldEntity::collisionTypeChanged()
     168    {
     169        if (this->collisionTypeSynchronised_ != Dynamic &&
     170            this->collisionTypeSynchronised_ != Kinematic &&
     171            this->collisionTypeSynchronised_ != Static &&
     172            this->collisionTypeSynchronised_ != None)
     173        {
     174            CCOUT(1) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << std::endl;
     175        }
     176        else if (this->collisionTypeSynchronised_ != collisionType_)
     177        {
     178            if (this->parent_)
     179                CCOUT(2) << "Warning: Network connection tried to set the collision type of an attached WE. Ignoring." << std::endl;
     180            else
     181                this->setCollisionType(this->collisionTypeSynchronised_);
     182        }
     183    }
     184
     185    void WorldEntity::physicsActivityChanged()
     186    {
     187        if (this->bPhysicsActiveSynchronised_)
     188            this->activatePhysics();
     189        else
     190            this->deactivatePhysics();
     191    }
     192
    118193    void WorldEntity::attach(WorldEntity* object)
    119194    {
     195        // check first whether attaching is even allowed
     196        if (object->hasPhysics())
     197        {
     198            if (!this->hasPhysics())
     199            {
     200                COUT(2) << "Warning: Cannot attach a physical object to a non physical one." << std::endl;
     201                return;
     202            }
     203            else if (object->isDynamic())
     204            {
     205                COUT(2) << "Warning: Cannot attach a dynamic object to a WorldEntity." << std::endl;
     206                return;
     207            }
     208            else if (object->isKinematic() && this->isDynamic())
     209            {
     210                COUT(2) << "Warning: Cannot attach a kinematic object to a dynamic one." << std::endl;
     211                return;
     212            }
     213            else if (object->isKinematic())
     214            {
     215                COUT(2) << "Warning: Cannot attach a kinematic object to a static or kinematic one: Not yet implemented." << std::endl;
     216                return;
     217            }
     218            else
     219            {
     220                object->deactivatePhysics();
     221            }
     222        }
     223
    120224        if (object->getParent())
    121225            object->detachFromParent();
     
    131235        object->parent_ = this;
    132236        object->parentID_ = this->getObjectID();
     237
     238        // collision shapes
     239        this->attachCollisionShape(object->getCollisionShape());
     240        // mass
     241        this->childrenMass_ += object->getMass();
     242        recalculateMassProps();
    133243    }
    134244
    135245    void WorldEntity::detach(WorldEntity* object)
    136246    {
     247        // collision shapes
     248        this->detachCollisionShape(object->getCollisionShape());
     249        // mass
     250        if (object->getMass() > 0.0f)
     251        {
     252            this->childrenMass_ -= object->getMass();
     253            recalculateMassProps();
     254        }
     255
    137256        this->node_->removeChild(object->node_);
    138257        this->children_.erase(object);
    139258        object->parent_ = 0;
    140259        object->parentID_ = OBJECTID_UNKNOWN;
    141 
    142260//        this->getScene()->getRootSceneNode()->addChild(object->node_);
     261
     262        // Note: It is possible that the object has physics but was disabled when attaching
     263        object->activatePhysics();
    143264    }
    144265
     
    154275        return 0;
    155276    }
     277
     278    void WorldEntity::attachOgreObject(Ogre::MovableObject* object)
     279    {
     280        this->node_->attachObject(object);
     281    }
     282
     283    void WorldEntity::detachOgreObject(Ogre::MovableObject* object)
     284    {
     285        this->node_->detachObject(object);
     286    }
     287
     288    Ogre::MovableObject* WorldEntity::detachOgreObject(const Ogre::String& name)
     289    {
     290        return this->node_->detachObject(name);
     291    }
     292
     293    void WorldEntity::attachCollisionShape(CollisionShape* shape)
     294    {
     295        this->collisionShape_->addChildShape(shape);
     296        // Note: this->collisionShape_ already notifies us of any changes.
     297    }
     298
     299    void WorldEntity::detachCollisionShape(CollisionShape* shape)
     300    {
     301        this->collisionShape_->removeChildShape(shape);
     302        // Note: this->collisionShape_ already notifies us of any changes.
     303    }
     304
     305    CollisionShape* WorldEntity::getAttachedCollisionShape(unsigned int index) const
     306    {
     307        return this->collisionShape_->getChildShape(index);
     308    }
     309
     310    void WorldEntity::activatePhysics()
     311    {
     312        if (this->isActive() && this->hasPhysics() && !this->isPhysicsActive() && !this->parent_)
     313        {
     314            this->getScene()->addRigidBody(this->physicalBody_);
     315            this->bPhysicsActive_ = true;
     316        }
     317    }
     318
     319    void WorldEntity::deactivatePhysics()
     320    {
     321        if (this->isPhysicsActive())
     322        {
     323            this->getScene()->removeRigidBody(this->physicalBody_);
     324            this->bPhysicsActive_ = false;
     325        }
     326    }
     327
     328    bool WorldEntity::addedToPhysicalWorld() const
     329    {
     330        return this->physicalBody_ && this->physicalBody_->isInWorld();
     331    }
     332
     333#ifndef _NDEBUG
     334    const Vector3& WorldEntity::getPosition() const
     335    {
     336        return this->node_->getPosition();
     337    }
     338
     339    const Quaternion& WorldEntity::getOrientation() const
     340    {
     341        return this->node_->getOrientation();
     342    }
     343
     344    const Vector3& WorldEntity::getScale3D() const
     345    {
     346        return this->node_->getScale();
     347    }
     348#endif
     349
     350    const Vector3& WorldEntity::getWorldPosition() const
     351    {
     352        return this->node_->_getDerivedPosition();
     353    }
     354
     355    const Quaternion& WorldEntity::getWorldOrientation() const
     356    {
     357        return this->node_->_getDerivedOrientation();
     358    }
     359
     360    void WorldEntity::translate(const Vector3& distance, TransformSpace::Space relativeTo)
     361    {
     362        switch (relativeTo)
     363        {
     364        case TransformSpace::Local:
     365            // position is relative to parent so transform downwards
     366            this->setPosition(this->getPosition() + this->getOrientation() * distance);
     367            break;
     368        case TransformSpace::Parent:
     369            this->setPosition(this->getPosition() + distance);
     370            break;
     371        case TransformSpace::World:
     372            // position is relative to parent so transform upwards
     373            if (this->node_->getParent())
     374                setPosition(getPosition() + (node_->getParent()->_getDerivedOrientation().Inverse() * distance)
     375                    / node_->getParent()->_getDerivedScale());
     376            else
     377                this->setPosition(this->getPosition() + distance);
     378            break;
     379        }
     380    }
     381
     382    void WorldEntity::rotate(const Quaternion& rotation, TransformSpace::Space relativeTo)
     383    {
     384        switch(relativeTo)
     385        {
     386        case TransformSpace::Local:
     387            this->setOrientation(this->getOrientation() * rotation);
     388            break;
     389        case TransformSpace::Parent:
     390            // Rotations are normally relative to local axes, transform up
     391            this->setOrientation(rotation * this->getOrientation());
     392            break;
     393        case TransformSpace::World:
     394            // Rotations are normally relative to local axes, transform up
     395            this->setOrientation(this->getOrientation() * this->getWorldOrientation().Inverse()
     396                * rotation * this->getWorldOrientation());
     397            break;
     398        }
     399    }
     400
     401    void WorldEntity::lookAt(const Vector3& target, TransformSpace::Space relativeTo, const Vector3& localDirectionVector)
     402    {
     403        Vector3 origin;
     404        switch (relativeTo)
     405        {
     406        case TransformSpace::Local:
     407            origin = Vector3::ZERO;
     408            break;
     409        case TransformSpace::Parent:
     410            origin = this->getPosition();
     411            break;
     412        case TransformSpace::World:
     413            origin = this->getWorldPosition();
     414            break;
     415        }
     416        this->setDirection(target - origin, relativeTo, localDirectionVector);
     417    }
     418
     419    void WorldEntity::setDirection(const Vector3& direction, TransformSpace::Space relativeTo, const Vector3& localDirectionVector)
     420    {
     421        Quaternion savedOrientation(this->getOrientation());
     422        Ogre::Node::TransformSpace ogreRelativeTo;
     423        switch (relativeTo)
     424        {
     425        case TransformSpace::Local:
     426            ogreRelativeTo = Ogre::Node::TS_LOCAL; break;
     427        case TransformSpace::Parent:
     428            ogreRelativeTo = Ogre::Node::TS_PARENT; break;
     429        case TransformSpace::World:
     430            ogreRelativeTo = Ogre::Node::TS_WORLD; break;
     431        }
     432        this->node_->setDirection(direction, ogreRelativeTo, localDirectionVector);
     433        Quaternion newOrientation(this->node_->getOrientation());
     434        this->node_->setOrientation(savedOrientation);
     435        this->setOrientation(newOrientation);
     436    }
     437
     438    void WorldEntity::setScale3D(const Vector3& scale)
     439    {
     440        if (this->hasPhysics())
     441        {
     442            CCOUT(2) << "Warning: Cannot set the scale of a physical object: Not yet implemented." << std::endl;
     443            return;
     444        }
     445
     446        this->node_->setScale(scale);
     447    }
     448
     449    void WorldEntity::setCollisionType(CollisionType type)
     450    {
     451        // If we are already attached to a parent, this would be a bad idea..
     452        if (this->parent_)
     453        {
     454            CCOUT(2) << "Warning: Cannot set the collision type of a WorldEntity with a parent." << std::endl;
     455            return;
     456        }
     457        else if (this->addedToPhysicalWorld())
     458        {
     459            CCOUT(2) << "Warning: Cannot set the collision type at run time." << std::endl;
     460            return;
     461        }
     462
     463        // Check for type legality. Could be StaticEntity or MobileEntity
     464        if (!this->isCollisionTypeLegal(type))
     465            return; // exception gets issued anyway
     466        if (type != None && !this->getScene()->hasPhysics())
     467        {
     468            CCOUT(2) << "Warning: Cannot have physical bodies in a non physical scene." << std::endl;
     469            return;
     470        }
     471
     472        // Check whether we have to create or destroy.
     473        if (type != None && this->collisionType_ == None)
     474        {
     475            // Check whether there was some scaling applied.
     476            if (!this->node_->getScale().positionEquals(Vector3(1, 1, 1), 0.001))
     477            {
     478                CCOUT(2) << "Warning: Cannot create a physical body if there is scaling applied to the node: Not yet implemented." << std::endl;
     479                return;
     480            }
     481
     482            // Create new rigid body
     483            btRigidBody::btRigidBodyConstructionInfo bodyConstructionInfo(0, this, this->collisionShape_->getCollisionShape());
     484            this->physicalBody_ = new btRigidBody(bodyConstructionInfo);
     485            this->physicalBody_->setUserPointer(this);
     486            this->physicalBody_->setActivationState(DISABLE_DEACTIVATION);
     487        }
     488        else if (type == None && this->collisionType_ != None)
     489        {
     490            // Destroy rigid body
     491            assert(this->physicalBody_);
     492            deactivatePhysics();
     493            delete this->physicalBody_;
     494            this->physicalBody_ = 0;
     495            this->collisionType_ = None;
     496            this->collisionTypeSynchronised_ = None;
     497            return;
     498        }
     499
     500        // Change type
     501        switch (type)
     502        {
     503        case Dynamic:
     504            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !(btCollisionObject::CF_STATIC_OBJECT | btCollisionObject::CF_KINEMATIC_OBJECT));
     505            break;
     506        case Kinematic:
     507            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT | btCollisionObject::CF_KINEMATIC_OBJECT);
     508            break;
     509        case Static:
     510            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_STATIC_OBJECT);
     511            break;
     512        case None:
     513            return; // this->collisionType_ was None too
     514        }
     515
     516        // Only sets this->collisionShape_
     517        // However the assertion is to ensure that the internal bullet setting is right
     518        updateCollisionType();
     519        assert(this->collisionType_ == type);
     520
     521        // update mass and inertia tensor
     522        recalculateMassProps();
     523        resetPhysicsProps();
     524        activatePhysics();
     525    }
     526
     527    void WorldEntity::setCollisionTypeStr(const std::string& typeStr)
     528    {
     529        std::string typeStrLower = getLowercase(typeStr);
     530        CollisionType type;
     531        if (typeStrLower == "dynamic")
     532            type = Dynamic;
     533        else if (typeStrLower == "static")
     534            type = Static;
     535        else if (typeStrLower == "kinematic")
     536            type = Kinematic;
     537        else if (typeStrLower == "none")
     538            type = None;
     539        else
     540            ThrowException(ParseError, std::string("Attempting to set an unknown collision type: '") + typeStr + "'.");
     541        this->setCollisionType(type);
     542    }
     543
     544    std::string WorldEntity::getCollisionTypeStr() const
     545    {
     546        switch (this->getCollisionType())
     547        {
     548            case Dynamic:
     549                return "dynamic";
     550            case Kinematic:
     551                return "kinematic";
     552            case Static:
     553                return "static";
     554            case None:
     555                return "none";
     556            default:
     557                assert(false);
     558                return "";
     559        }
     560    }
     561
     562    void WorldEntity::updateCollisionType()
     563    {
     564        if (!this->physicalBody_)
     565            this->collisionType_ = None;
     566        else if (this->physicalBody_->isKinematicObject())
     567            this->collisionType_ = Kinematic;
     568        else if (this->physicalBody_->isStaticObject())
     569            this->collisionType_ = Static;
     570        else
     571            this->collisionType_ = Dynamic;
     572        this->collisionTypeSynchronised_ = this->collisionType_;
     573    }
     574
     575    void WorldEntity::notifyChildMassChanged() // Called by a child WE
     576    {
     577        // Note: CollisionShape changes of a child get handled over the internal CompoundCollisionShape already
     578        // Recalculate mass
     579        this->childrenMass_ = 0.0f;
     580        for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
     581            this->childrenMass_ += (*it)->getMass();
     582        recalculateMassProps();
     583        // Notify parent WE
     584        if (this->parent_)
     585            parent_->notifyChildMassChanged();
     586    }
     587
     588    void WorldEntity::notifyCollisionShapeChanged() // called by this->collisionShape_
     589    {
     590        if (hasPhysics())
     591        {
     592            // Bullet doesn't like sudden changes of the collision shape, so we remove and add it again
     593            if (this->addedToPhysicalWorld())
     594            {
     595                this->deactivatePhysics();
     596                this->physicalBody_->setCollisionShape(this->collisionShape_->getCollisionShape());
     597                this->activatePhysics();
     598            }
     599            else
     600                this->physicalBody_->setCollisionShape(this->collisionShape_->getCollisionShape());
     601        }
     602        recalculateMassProps();
     603    }
     604
     605    void WorldEntity::recalculateMassProps()
     606    {
     607        if (this->hasPhysics())
     608        {
     609            if (this->isStatic())
     610            {
     611                // Just set everything to zero
     612                this->physicalBody_->setMassProps(0.0f, btVector3(0, 0, 0));
     613            }
     614            else if ((this->mass_ + this->childrenMass_) == 0.0f)
     615            {
     616                // Use default values to avoid very large or very small values
     617                CCOUT(4) << "Warning: Setting the internal physical mass to 1.0 because mass_ is 0.0." << std::endl;
     618                this->physicalBody_->setMassProps(1.0f, this->collisionShape_->getLocalInertia(1.0f));
     619            }
     620            else
     621            {
     622                float mass = this->mass_ + this->childrenMass_;
     623                this->physicalBody_->setMassProps(mass, this->collisionShape_->getLocalInertia(mass));
     624            }
     625        }
     626    }
     627
     628    void WorldEntity::resetPhysicsProps()
     629    {
     630        if (this->hasPhysics())
     631        {
     632            this->physicalBody_->setRestitution(this->restitution_);
     633            this->physicalBody_->setAngularFactor(this->angularFactor_);
     634            this->physicalBody_->setDamping(this->linearDamping_, this->angularDamping_);
     635            this->physicalBody_->setFriction(this->friction_);
     636        }
     637    }
    156638}
  • code/branches/physics_merge/src/orxonox/objects/worldentities/WorldEntity.h

    r2371 r2442  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder (physics)
    2425 *   Co-authors:
    2526 *      ...
     
    3233#include "OrxonoxPrereqs.h"
    3334
    34 #define OGRE_FORCE_ANGLE_TYPES
    35 
     35#ifdef _NDEBUG
    3636#include <OgreSceneNode.h>
     37#else
     38#include <OgrePrerequisites.h>
     39#endif
     40#include "LinearMath/btMotionState.h"
    3741
    3842#include "network/synchronisable/Synchronisable.h"
     
    4246namespace orxonox
    4347{
    44     class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable
     48    class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState
    4549    {
    4650        public:
     
    5155            void registerVariables();
    5256
    53             inline Ogre::SceneNode* getNode() const
     57            inline const Ogre::SceneNode* getNode() const
    5458                { return this->node_; }
    5559
     
    6468            inline void setPosition(float x, float y, float z)
    6569                { this->setPosition(Vector3(x, y, z)); }
    66             inline const Vector3& getPosition() const
    67                 { return this->node_->getPosition(); }
    68             inline const Vector3& getWorldPosition() const
    69                 { return this->node_->getWorldPosition(); }
    70 
    71             virtual void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    72             inline void translate(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
     70            const Vector3& getPosition() const;
     71            const Vector3& getWorldPosition() const;
     72
     73            void translate(const Vector3& distance, TransformSpace::Space relativeTo = TransformSpace::Parent);
     74            inline void translate(float x, float y, float z, TransformSpace::Space relativeTo = TransformSpace::Parent)
    7375                { this->translate(Vector3(x, y, z), relativeTo); }
    7476
     
    8082            inline void setOrientation(const Vector3& axis, const Degree& angle)
    8183                { this->setOrientation(Quaternion(angle, axis)); }
    82             inline const Quaternion& getOrientation() const
    83                 { return this->node_->getOrientation(); }
    84             inline const Quaternion& getWorldOrientation() const
    85                 { return this->node_->getWorldOrientation(); }
    86 
    87             virtual void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    88             inline void rotate(const Vector3& axis, const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
     84            const Quaternion& getOrientation() const;
     85            const Quaternion& getWorldOrientation() const;
     86
     87            void rotate(const Quaternion& rotation, TransformSpace::Space relativeTo = TransformSpace::Local);
     88            inline void rotate(const Vector3& axis, const Degree& angle, TransformSpace::Space relativeTo = TransformSpace::Local)
    8989                { this->rotate(Quaternion(angle, axis), relativeTo); }
    90             inline void rotate(const Vector3& axis, const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    91                 { this->rotate(Quaternion(angle, axis), relativeTo); }
    92 
    93             virtual void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    94             inline void yaw(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    95                 { this->yaw(Degree(angle), relativeTo); }
    96             virtual void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    97             inline void pitch(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    98                 { this->pitch(Degree(angle), relativeTo); }
    99             virtual void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    100             inline void roll(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    101                 { this->roll(Degree(angle), relativeTo); }
    102 
    103             virtual void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0;
    104             virtual void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0;
    105             inline void setDirection(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
     90
     91            inline void yaw(const Degree& angle, TransformSpace::Space relativeTo = TransformSpace::Local)
     92                { this->rotate(Quaternion(angle, Vector3::UNIT_Y), relativeTo); }
     93            inline void pitch(const Degree& angle, TransformSpace::Space relativeTo = TransformSpace::Local)
     94                { this->rotate(Quaternion(angle, Vector3::UNIT_X), relativeTo); }
     95            inline void roll(const Degree& angle, TransformSpace::Space relativeTo = TransformSpace::Local)
     96                { this->rotate(Quaternion(angle, Vector3::UNIT_Z), relativeTo); }
     97
     98            void lookAt(const Vector3& target, TransformSpace::Space relativeTo = TransformSpace::Parent, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     99            void setDirection(const Vector3& direction, TransformSpace::Space relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     100            inline void setDirection(float x, float y, float z, TransformSpace::Space relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
    106101                { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); }
    107102
    108             inline void setScale3D(const Vector3& scale)
    109                 { this->node_->setScale(scale); }
     103            virtual void setScale3D(const Vector3& scale);
    110104            inline void setScale3D(float x, float y, float z)
    111                 { this->node_->setScale(x, y, z); }
    112             inline const Vector3& getScale3D(void) const
    113                 { return this->node_->getScale(); }
    114 
    115             inline void setScale(float scale)
    116                 { this->node_->setScale(scale, scale, scale); }
     105                { this->setScale3D(Vector3(x, y, z)); }
     106            const Vector3& getScale3D(void) const;
     107
     108            void setScale(float scale)
     109                { this->setScale3D(scale, scale, scale); }
    117110            inline float getScale() const
    118111                { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
    119112
    120113            inline void scale3D(const Vector3& scale)
    121                 { this->node_->scale(scale); }
     114                { this->setScale3D(this->getScale3D() * scale); }
    122115            inline void scale3D(float x, float y, float z)
    123                 { this->node_->scale(x, y, z); }
     116                { this->scale3D(Vector3(x, y, z)); }
    124117            inline void scale(float scale)
    125                 { this->node_->scale(scale, scale, scale); }
     118                { this->scale3D(scale, scale, scale); }
    126119
    127120            void attach(WorldEntity* object);
     
    130123            inline const std::set<WorldEntity*>& getAttachedObjects() const
    131124                { return this->children_; }
     125
     126            void attachOgreObject(Ogre::MovableObject* object);
     127            void detachOgreObject(Ogre::MovableObject* object);
     128            Ogre::MovableObject* detachOgreObject(const Ogre::String& name);
    132129
    133130            inline void attachToParent(WorldEntity* parent)
     
    138135                { return this->parent_; }
    139136
     137            void notifyChildPropsChanged();
     138
    140139        protected:
    141140            Ogre::SceneNode* node_;
    142141
    143142        private:
    144             void updateParent();
    145 
    146143            inline void lookAt_xmlport(const Vector3& target)
    147144                { this->lookAt(target); }
     
    155152                { this->roll(angle); }
    156153
     154            // network callbacks
     155            void parentChanged();
     156            inline void scaleChanged()
     157                { this->setScale3D(this->getScale3D()); }
     158
    157159            WorldEntity* parent_;
    158160            unsigned int parentID_;
    159161            std::set<WorldEntity*> children_;
     162
     163
     164        /////////////
     165        // Physics //
     166        /////////////
     167
     168        public:
     169            enum CollisionType
     170            {
     171                Dynamic,
     172                Kinematic,
     173                Static,
     174                None
     175            };
     176
     177            bool hasPhysics()       const { return getCollisionType() != None     ; }
     178            bool isStatic()         const { return getCollisionType() == Static   ; }
     179            bool isKinematic()      const { return getCollisionType() == Kinematic; }
     180            bool isDynamic()        const { return getCollisionType() == Dynamic  ; }
     181            bool isPhysicsActive()  const { return this->bPhysicsActive_; }
     182            bool addedToPhysicalWorld() const;
     183
     184            void activatePhysics();
     185            void deactivatePhysics();
     186
     187            inline CollisionType getCollisionType() const
     188                { return this->collisionType_; }
     189            void setCollisionType(CollisionType type);
     190
     191            void setCollisionTypeStr(const std::string& type);
     192            std::string getCollisionTypeStr() const;
     193
     194            inline void setMass(float mass)
     195                { this->mass_ = mass; recalculateMassProps(); }
     196            inline float getMass() const
     197                { return this->mass_; }
     198
     199            inline float getTotalMass() const
     200                { return this->mass_ + this->childrenMass_; }
     201
     202            inline void setRestitution(float restitution)
     203                { this->restitution_ = restitution; resetPhysicsProps(); }
     204            inline float getRestitution() const
     205                { return this->restitution_; }
     206
     207            inline void setAngularFactor(float angularFactor)
     208                { this->angularFactor_ = angularFactor; resetPhysicsProps(); }
     209            inline float getAngularFactor() const
     210                { return this->angularFactor_; }
     211
     212            inline void setLinearDamping(float linearDamping)
     213                { this->linearDamping_ = linearDamping; resetPhysicsProps(); }
     214            inline float getLinearDamping() const
     215                { return this->linearDamping_; }
     216
     217            inline void setAngularDamping(float angularDamping)
     218                { this->angularDamping_ = angularDamping; resetPhysicsProps(); }
     219            inline float getAngularDamping() const
     220                { return this->angularDamping_; }
     221
     222            inline void setFriction(float friction)
     223                { this->friction_ = friction; resetPhysicsProps(); }
     224            inline float getFriction() const
     225                { return this->friction_; }
     226
     227            void attachCollisionShape(CollisionShape* shape);
     228            void detachCollisionShape(CollisionShape* shape);
     229            CollisionShape* getAttachedCollisionShape(unsigned int index) const;
     230
     231            inline CompoundCollisionShape* getCollisionShape()
     232                { return this->collisionShape_; }
     233            inline btRigidBody* getPhysicalBody()
     234                { return this->physicalBody_; }
     235
     236            void notifyCollisionShapeChanged();
     237            void notifyChildMassChanged();
     238
     239        protected:
     240            virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
     241
     242            btRigidBody*  physicalBody_;
     243
     244        private:
     245            void updateCollisionType();
     246            void recalculateMassProps();
     247            void resetPhysicsProps();
     248
     249            // network callbacks
     250            void collisionTypeChanged();
     251            void physicsActivityChanged();
     252            inline void massChanged()
     253                { this->setMass(this->mass_); }
     254            inline void restitutionChanged()
     255                { this->setRestitution(this->restitution_); }
     256            inline void angularFactorChanged()
     257                { this->setAngularFactor(this->angularFactor_); }
     258            inline void linearDampingChanged()
     259                { this->setLinearDamping(this->linearDamping_); }
     260            inline void angularDampingChanged()
     261                { this->setAngularDamping(this->angularDamping_); }
     262            inline void frictionChanged()
     263                { this->setFriction(this->friction_); }
     264
     265            CollisionType                collisionType_;
     266            CollisionType                collisionTypeSynchronised_;
     267            bool                         bPhysicsActive_;
     268            bool                         bPhysicsActiveSynchronised_;
     269            CompoundCollisionShape*      collisionShape_;
     270            btScalar                     mass_;
     271            btScalar                     restitution_;
     272            btScalar                     angularFactor_;
     273            btScalar                     linearDamping_;
     274            btScalar                     angularDamping_;
     275            btScalar                     friction_;
     276            btScalar                     childrenMass_;
    160277    };
     278
     279    // Inline heavily used functions for release builds. In debug, we better avoid including OgreSceneNode here.
     280#ifdef _NDEBUG
     281    inline const Vector3& WorldEntity::getPosition() const
     282        { return this->node_->getPosition(); }
     283    inline const Quaternion& WorldEntity::getOrientation() const
     284        { return this->node_->getrOrientation(); }
     285    inline const Vector3& WorldEntity::getScale3D(void) const
     286        { return this->node_->getScale(); }
     287#endif
    161288}
    162289
  • code/branches/physics_merge/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2371 r2442  
    3030#include "SpaceShip.h"
    3131
     32#include "BulletDynamics/Dynamics/btRigidBody.h"
     33
     34#include "util/Math.h"
     35#include "util/Exception.h"
    3236#include "core/CoreIncludes.h"
    3337#include "core/ConfigValueIncludes.h"
    3438#include "core/XMLPort.h"
    35 #include "util/Math.h"
    3639
    3740namespace orxonox
    3841{
     42    const float orientationGain = 100;
    3943    CreateFactory(SpaceShip);
    4044
     
    7882        XMLPortParam(SpaceShip, "rotacc",            setRotAcc,            getRotAcc,            xmlelement, mode);
    7983        XMLPortParam(SpaceShip, "transdamp",         setTransDamp,         getTransDamp,         xmlelement, mode);
     84
     85        if (this->physicalBody_)
     86        {
     87            this->physicalBody_->setDamping(0.7, 0.3);
     88        }
    8089    }
    8190
     
    97106    void SpaceShip::tick(float dt)
    98107    {
    99         if (this->isLocallyControlled())
    100         {
    101             // #####################################
    102             // ############# STEERING ##############
    103             // #####################################
    104 
    105             Vector3 velocity = this->getVelocity();
    106             if (velocity.x > this->maxSecondarySpeed_)
    107                 velocity.x = this->maxSecondarySpeed_;
    108             if (velocity.x < -this->maxSecondarySpeed_)
    109                 velocity.x = -this->maxSecondarySpeed_;
    110             if (velocity.y > this->maxSecondarySpeed_)
    111                 velocity.y = this->maxSecondarySpeed_;
    112             if (velocity.y < -this->maxSecondarySpeed_)
    113                 velocity.y = -this->maxSecondarySpeed_;
    114             if (velocity.z > this->maxSecondarySpeed_)
    115                 velocity.z = this->maxSecondarySpeed_;
    116             if (velocity.z < -this->maxSpeed_)
    117                 velocity.z = -this->maxSpeed_;
    118 
    119             // normalize velocity and acceleration
    120             for (size_t dimension = 0; dimension < 3; ++dimension)
    121             {
    122                 if (this->acceleration_[dimension] == 0)
    123                 {
    124                     if (velocity[dimension] > 0)
    125                     {
    126                         velocity[dimension] -= (this->translationDamping_ * dt);
    127                         if (velocity[dimension] < 0)
    128                             velocity[dimension] = 0;
    129                     }
    130                     else if (velocity[dimension] < 0)
    131                     {
    132                         velocity[dimension] += (this->translationDamping_ * dt);
    133                         if (velocity[dimension] > 0)
    134                             velocity[dimension] = 0;
    135                     }
    136                 }
    137             }
    138 
    139             this->setVelocity(velocity);
    140         }
    141 
    142 
    143108        SUPER(SpaceShip, tick, dt);
    144 
    145 
    146         if (this->isLocallyControlled())
    147         {
    148             this->yaw(this->yawRotation_ * dt);
    149             if (this->bInvertYAxis_)
    150                 this->pitch(Degree(-this->pitchRotation_ * dt));
    151             else
    152                 this->pitch(Degree( this->pitchRotation_ * dt));
    153             this->roll(this->rollRotation_ * dt);
    154 
    155             this->acceleration_.x = 0;
    156             this->acceleration_.y = 0;
    157             this->acceleration_.z = 0;
    158 
    159             this->yawRotation_   = this->zeroDegree_;
    160             this->pitchRotation_ = this->zeroDegree_;
    161             this->rollRotation_  = this->zeroDegree_;
    162         }
    163109    }
    164110
    165111    void SpaceShip::moveFrontBack(const Vector2& value)
    166112    {
    167         this->acceleration_.z = -this->translationAcceleration_ * value.x;
     113        assert(this->physicalBody_);
     114        this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 0.0f, -getMass() * value.x * 100));
    168115    }
    169116
    170117    void SpaceShip::moveRightLeft(const Vector2& value)
    171118    {
    172         this->acceleration_.x = this->translationAcceleration_ * value.x;
     119        this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(getMass() * value.x * 100, 0.0f, 0.0f));
    173120    }
    174121
    175122    void SpaceShip::moveUpDown(const Vector2& value)
    176123    {
    177         this->acceleration_.y = this->translationAcceleration_ * value.x;
     124        this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, getMass() * value.x * 100, 0.0f));
    178125    }
    179126
    180127    void SpaceShip::rotateYaw(const Vector2& value)
    181128    {
    182         Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    183         if (temp > this->maxRotation_)
    184             temp = this->maxRotation_;
    185         if (temp < -this->maxRotation_)
    186             temp = -this->maxRotation_;
    187         this->yawRotation_ = Degree(temp);
     129        this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 1 / this->physicalBody_->getInvInertiaDiagLocal().y() * value.y * orientationGain, 0.0f));
    188130    }
    189131
    190132    void SpaceShip::rotatePitch(const Vector2& value)
    191133    {
    192         Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    193         if (temp > this->maxRotation_)
    194             temp = this->maxRotation_;
    195         if (temp < -this->maxRotation_)
    196             temp = -this->maxRotation_;
    197         this->pitchRotation_ = Degree(temp);
     134        this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(1 / this->physicalBody_->getInvInertiaDiagLocal().x() * value.y * orientationGain, 0.0f, 0.0f));
    198135    }
    199136
    200137    void SpaceShip::rotateRoll(const Vector2& value)
    201138    {
    202         Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    203         if (temp > this->maxRotation_)
    204             temp = this->maxRotation_;
    205         if (temp < -this->maxRotation_)
    206             temp = -this->maxRotation_;
    207         this->rollRotation_ = Degree(temp);
     139        this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * btVector3(0.0f, 0.0f, -1 / this->physicalBody_->getInvInertiaDiagLocal().z() * value.y * orientationGain));
    208140    }
    209141
  • code/branches/physics_merge/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2371 r2442  
    2929#include "OrxonoxStableHeaders.h"
    3030#include "Spectator.h"
     31
     32#include <OgreBillboardSet.h>
    3133
    3234#include "core/CoreIncludes.h"
     
    6365        this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1);
    6466        if (this->greetingFlare_->getBillboardSet())
    65             this->getNode()->attachObject(this->greetingFlare_->getBillboardSet());
     67            this->attachOgreObject(this->greetingFlare_->getBillboardSet());
    6668        this->greetingFlare_->setVisible(false);
    6769        this->bGreetingFlareVisible_ = false;
     
    7880            {
    7981                if (this->greetingFlare_->getBillboardSet())
    80                     this->getNode()->detachObject(this->greetingFlare_->getBillboardSet());
     82                    this->detachOgreObject(this->greetingFlare_->getBillboardSet());
    8183                delete this->greetingFlare_;
    8284            }
     
    110112            Vector3 velocity = this->getVelocity();
    111113            velocity.normalise();
    112             this->setVelocity(velocity * this->speed_);
     114            this->setVelocity(this->getOrientation() * velocity * this->speed_);
    113115
    114116            this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
  • code/branches/physics_merge/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

  • code/branches/physics_merge/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

  • code/branches/physics_merge/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r2420 r2442  
    3131
    3232#include <OgreBillboard.h>
     33#include <OgreBillboardSet.h>
    3334#include "util/Debug.h"
    3435#include "core/CoreIncludes.h"
     
    4445  CreateFactory(Trigger);
    4546
    46   Trigger::Trigger(BaseObject* creator) : PositionableEntity(creator)
     47  Trigger::Trigger(BaseObject* creator) : StaticEntity(creator)
    4748  {
    4849    RegisterObject(Trigger);
     
    7172
    7273      if (this->debugBillboard_.getBillboardSet())
    73         this->getNode()->attachObject(this->debugBillboard_.getBillboardSet());
     74          this->attachOgreObject(this->debugBillboard_.getBillboardSet());
    7475    }
    7576
  • code/branches/physics_merge/src/orxonox/objects/worldentities/triggers/Trigger.h

    r2420 r2442  
    3636
    3737#include "objects/Tickable.h"
    38 #include "objects/worldentities/PositionableEntity.h"
     38#include "objects/worldentities/StaticEntity.h"
    3939#include "tools/BillboardSet.h"
    4040
     
    4848  };
    4949
    50   class _OrxonoxExport Trigger : public PositionableEntity, public Tickable
     50  class _OrxonoxExport Trigger : public StaticEntity, public Tickable
    5151  {
    5252    public:
  • code/branches/physics_merge/src/orxonox/tools/BillboardSet.cc

    r2171 r2442  
    3434
    3535#include <OgreSceneManager.h>
     36#include <OgreBillboardSet.h>
    3637#include <OgreBillboard.h>
    3738
  • code/branches/physics_merge/src/orxonox/tools/BillboardSet.h

    r2087 r2442  
    3333
    3434#include <string>
    35 #include <OgreBillboardSet.h>
     35#include <OgrePrerequisites.h>
    3636
    3737#include "util/Math.h"
  • code/branches/physics_merge/src/orxonox/tools/BulletConversions.h

    r2440 r2442  
    3737#include "LinearMath/btVector3.h"
    3838
    39 // Vector3 to btVector3
    40 template <>
    41 struct ConverterExplicit<orxonox::Vector3, btVector3>
     39namespace orxonox
    4240{
    43     static bool convert(btVector3* output, const orxonox::Vector3& input)
     41    // Vector3 to btVector3
     42    template <>
     43    struct ConverterExplicit<orxonox::Vector3, btVector3>
    4444    {
    45         output->setX(input.x);
    46         output->setY(input.y);
    47         output->setZ(input.z);
    48         return true;
    49     }
    50 };
     45        static bool convert(btVector3* output, const orxonox::Vector3& input)
     46        {
     47            output->setX(input.x);
     48            output->setY(input.y);
     49            output->setZ(input.z);
     50            return true;
     51        }
     52    };
    5153
    52 // btVector3 to Vector3
    53 template <>
    54 struct ConverterExplicit<btVector3, orxonox::Vector3>
    55 {
    56     static bool convert(orxonox::Vector3* output, const btVector3& input)
     54    // btVector3 to Vector3
     55    template <>
     56    struct ConverterExplicit<btVector3, orxonox::Vector3>
    5757    {
    58         output->x = input.x();
    59         output->y = input.y();
    60         output->z = input.z();
    61         return true;
    62     }
    63 };
     58        static bool convert(orxonox::Vector3* output, const btVector3& input)
     59        {
     60            output->x = input.x();
     61            output->y = input.y();
     62            output->z = input.z();
     63            return true;
     64        }
     65    };
    6466
    65 // Quaternion to btQuaternion
    66 template <>
    67 struct ConverterExplicit<orxonox::Quaternion, btQuaternion>
    68 {
    69     static bool convert(btQuaternion* output, const orxonox::Quaternion& input)
     67    // Quaternion to btQuaternion
     68    template <>
     69    struct ConverterExplicit<orxonox::Quaternion, btQuaternion>
    7070    {
    71         output->setW(input.w);
    72         output->setX(input.x);
    73         output->setY(input.y);
    74         output->setZ(input.z);
    75         return true;
    76     }
    77 };
     71        static bool convert(btQuaternion* output, const orxonox::Quaternion& input)
     72        {
     73            output->setW(input.w);
     74            output->setX(input.x);
     75            output->setY(input.y);
     76            output->setZ(input.z);
     77            return true;
     78        }
     79    };
    7880
    79 // btQuaternion to Vector3
    80 template <>
    81 struct ConverterExplicit<btQuaternion, orxonox::Quaternion>
    82 {
    83     static bool convert(orxonox::Quaternion* output, const btQuaternion& input)
     81    // btQuaternion to Vector3
     82    template <>
     83    struct ConverterExplicit<btQuaternion, orxonox::Quaternion>
    8484    {
    85         output->w = input.w();
    86         output->x = input.x();
    87         output->y = input.y();
    88         output->z = input.z();
    89         return true;
    90     }
    91 };
     85        static bool convert(orxonox::Quaternion* output, const btQuaternion& input)
     86        {
     87            output->w = input.w();
     88            output->x = input.x();
     89            output->y = input.y();
     90            output->z = input.z();
     91            return true;
     92        }
     93    };
     94}
    9295
    9396#endif /* _BulletConversions_H__ */
  • code/branches/physics_merge/src/orxonox/tools/Mesh.cc

    r2171 r2442  
    3131
    3232#include <sstream>
     33#include <OgreEntity.h>
    3334#include <OgreSceneManager.h>
    3435#include <cassert>
  • code/branches/physics_merge/src/orxonox/tools/Mesh.h

    r2087 r2442  
    3333
    3434#include <string>
    35 #include <OgreEntity.h>
     35#include <OgrePrerequisites.h>
    3636
    3737namespace orxonox
  • code/branches/physics_merge/src/orxonox/tools/ParticleInterface.cc

    r2171 r2442  
    5757
    5858        this->scenemanager_ = scenemanager;
    59         this->sceneNode_ = 0;
    6059        this->particleSystem_ = 0;
    6160
     
    8786        {
    8887            this->particleSystem_->removeAllEmitters();
    89             this->detachFromSceneNode();
    9088            this->scenemanager_->destroyParticleSystem(this->particleSystem_);
    91         }
    92     }
    93 
    94     void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode)
    95     {
    96         if (this->sceneNode_)
    97             this->detachFromSceneNode();
    98 
    99         if (this->particleSystem_)
    100         {
    101             this->sceneNode_ = sceneNode;
    102             this->sceneNode_->attachObject(this->particleSystem_);
    103         }
    104     }
    105 
    106     void ParticleInterface::detachFromSceneNode()
    107     {
    108         if (this->sceneNode_)
    109         {
    110             if (this->particleSystem_)
    111                 this->sceneNode_->detachObject(this->particleSystem_);
    112             this->sceneNode_ = 0;
    11389        }
    11490    }
  • code/branches/physics_merge/src/orxonox/tools/ParticleInterface.h

    r2087 r2442  
    3333
    3434#include <string>
    35 #include <OgreParticleEmitter.h>
     35#include <OgrePrerequisites.h>
    3636
    3737#include "core/OrxonoxClass.h"
     
    5353            inline Ogre::ParticleSystem* getParticleSystem() const
    5454                { return this->particleSystem_; }
    55 
    56             void addToSceneNode(Ogre::SceneNode* sceneNode);
    57             void detachFromSceneNode();
    5855
    5956            Ogre::ParticleEmitter* createNewEmitter();
     
    9693            static unsigned int       counter_s;
    9794
    98             Ogre::SceneNode*          sceneNode_;
    9995            Ogre::ParticleSystem*     particleSystem_;
    10096            bool                      bVisible_;
Note: See TracChangeset for help on using the changeset viewer.