Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 12, 2009, 8:00:42 PM (15 years ago)
Author:
rgrieder
Message:

Making use of Ogre::UserDefinedObject by subclassing it in WorldEntity: This way we can access a WE from an Ogre::MovableObject (e.g. Ogre::Entity or Ogre::ParticleSystem), but with a dynamic_cast of course.

Location:
code/branches/steering/src/orxonox/worldentities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/steering/src/orxonox/worldentities/WorldEntity.cc

    r5929 r6052  
    472472    //! Attaches an Ogre::MovableObject to this WorldEntity.
    473473    void WorldEntity::attachOgreObject(Ogre::MovableObject* object)
    474         { this->node_->attachObject(object); }
     474    {
     475        this->node_->attachObject(object);
     476        object->setUserObject(this);
     477    }
     478
    475479    void WorldEntity::attachOgreObject(Ogre::BillboardSet* object)
    476         { this->node_->attachObject(object); }
     480        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    477481    void WorldEntity::attachOgreObject(Ogre::Camera* object)
    478         { this->node_->attachObject(object); }
     482        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    479483    void WorldEntity::attachOgreObject(Ogre::Entity* object)
    480         { this->node_->attachObject(object); }
     484        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    481485    void WorldEntity::attachOgreObject(Ogre::ParticleSystem* object)
    482         { this->node_->attachObject(object); }
     486        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    483487
    484488    //! Detaches an Ogre::MovableObject from this WorldEntity.
    485489    void WorldEntity::detachOgreObject(Ogre::MovableObject* object)
    486         { this->node_->detachObject(object); }
     490    {
     491        object->setUserObject(NULL);
     492        this->node_->detachObject(object);
     493    }
     494
    487495    void WorldEntity::detachOgreObject(Ogre::BillboardSet* object)
    488         { this->node_->detachObject(object); }
     496        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    489497    void WorldEntity::detachOgreObject(Ogre::Camera* object)
    490         { this->node_->detachObject(object); }
     498        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    491499    void WorldEntity::detachOgreObject(Ogre::Entity* object)
    492         { this->node_->detachObject(object); }
     500        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    493501    void WorldEntity::detachOgreObject(Ogre::ParticleSystem* object)
    494         { this->node_->detachObject(object); }
     502        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
    495503
    496504    //! Detaches an Ogre::MovableObject (by string) from this WorldEntity.
     
    913921    }
    914922
    915     //! Copies our own parameters for restitution, angular factor, dampings and friction to the bullet rigid body.
     923    //! Copies our own parameters for restitution, angular factor, damping and friction to the bullet rigid body.
    916924    void WorldEntity::internalSetPhysicsProps()
    917925    {
  • code/branches/steering/src/orxonox/worldentities/WorldEntity.h

    r5781 r6052  
    3333#include "OrxonoxPrereqs.h"
    3434
     35#include <OgreUserDefinedObject.h>
    3536#ifdef ORXONOX_RELEASE
    3637#  include <OgreSceneNode.h>
     
    5556
    5657        The basic task of the WorldEntity is provide a location, a direction and a scaling and the possibility
    57         to create an entire hierarchy of derivated objects.
     58        to create an entire hierarchy of derived objects.
    5859        It is also the basis for the physics interface to the Bullet physics engine.
    5960        Every WorldEntity can have a specific collision type: @see CollisionType
     
    6364        There is also support for attaching WorldEntities with physics to each other. Currently, the collision shape
    6465        of both objects simply get merged into one larger shape (for static collision type).
    65         The phyiscal body that is internally stored and administrated has the following supported properties:
    66         - Restitution, angular factor, linear damping, angular damping, fricition, mass and collision shape.
     66        The physical body that is internally stored and administrated has the following supported properties:
     67        - Restitution, angular factor, linear damping, angular damping, friction, mass and collision shape.
    6768        You can get more information at the corresponding set function.
    6869
    6970        Collision shapes: These are controlled by the internal WorldEntityCollisionShape. @see WorldEntityCollisionShape.
    7071    */
    71     class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState
     72    class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState, public Ogre::UserDefinedObject
    7273    {
    7374        friend class Scene;
     
    318319                Sets an artificial parameter that tells how much torque is applied when you apply a non-central force.
    319320
    320                 Normally the angular factor is 1, which means it's physically 'correct'. Howerver if you have a player
     321                Normally the angular factor is 1, which means it's physically 'correct'. However if you have a player
    321322                character that should not rotate when hit sideways, you can set the angular factor to 0.
    322323            */
     
    394395                You can override this function in a derived class to constrain the collision to e.g. None or Dynamic.
    395396                A projectile may not prove very useful if there is no physical body. Simply set the CollisionType
    396                 in its constructor and override this method. But be careful that a derived classe's virtual functions
     397                in its constructor and override this method. But be careful that a derived class's virtual functions
    397398                don't yet exist in the constructor if a base class.
    398399            */
Note: See TracChangeset for help on using the changeset viewer.