[Orxonox-commit 1334] r6052 - in code/branches/steering/src/orxonox: graphics worldentities

rgrieder at orxonox.net rgrieder at orxonox.net
Thu Nov 12 20:00:42 CET 2009


Author: rgrieder
Date: 2009-11-12 20:00:42 +0100 (Thu, 12 Nov 2009)
New Revision: 6052

Modified:
   code/branches/steering/src/orxonox/graphics/Camera.cc
   code/branches/steering/src/orxonox/worldentities/WorldEntity.cc
   code/branches/steering/src/orxonox/worldentities/WorldEntity.h
Log:
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.

Modified: code/branches/steering/src/orxonox/graphics/Camera.cc
===================================================================
--- code/branches/steering/src/orxonox/graphics/Camera.cc	2009-11-12 18:41:20 UTC (rev 6051)
+++ code/branches/steering/src/orxonox/graphics/Camera.cc	2009-11-12 19:00:42 UTC (rev 6052)
@@ -60,6 +60,7 @@
             ThrowException(AbortLoading, "Can't create Camera, no root-scene-node given.");
 
         this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
+        this->camera_->setUserObject(this);
         this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
         this->attachNode(this->cameraNode_);
         this->cameraNode_->attachObject(this->camera_);

Modified: code/branches/steering/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/steering/src/orxonox/worldentities/WorldEntity.cc	2009-11-12 18:41:20 UTC (rev 6051)
+++ code/branches/steering/src/orxonox/worldentities/WorldEntity.cc	2009-11-12 19:00:42 UTC (rev 6052)
@@ -471,27 +471,35 @@
 
     //! Attaches an Ogre::MovableObject to this WorldEntity.
     void WorldEntity::attachOgreObject(Ogre::MovableObject* object)
-        { this->node_->attachObject(object); }
+    {
+        this->node_->attachObject(object);
+        object->setUserObject(this);
+    }
+
     void WorldEntity::attachOgreObject(Ogre::BillboardSet* object)
-        { this->node_->attachObject(object); }
+        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
     void WorldEntity::attachOgreObject(Ogre::Camera* object)
-        { this->node_->attachObject(object); }
+        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
     void WorldEntity::attachOgreObject(Ogre::Entity* object)
-        { this->node_->attachObject(object); }
+        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
     void WorldEntity::attachOgreObject(Ogre::ParticleSystem* object)
-        { this->node_->attachObject(object); }
+        { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
 
     //! Detaches an Ogre::MovableObject from this WorldEntity.
     void WorldEntity::detachOgreObject(Ogre::MovableObject* object)
-        { this->node_->detachObject(object); }
+    {
+        object->setUserObject(NULL);
+        this->node_->detachObject(object);
+    }
+
     void WorldEntity::detachOgreObject(Ogre::BillboardSet* object)
-        { this->node_->detachObject(object); }
+        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
     void WorldEntity::detachOgreObject(Ogre::Camera* object)
-        { this->node_->detachObject(object); }
+        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
     void WorldEntity::detachOgreObject(Ogre::Entity* object)
-        { this->node_->detachObject(object); }
+        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
     void WorldEntity::detachOgreObject(Ogre::ParticleSystem* object)
-        { this->node_->detachObject(object); }
+        { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
 
     //! Detaches an Ogre::MovableObject (by string) from this WorldEntity.
     Ogre::MovableObject* WorldEntity::detachOgreObject(const Ogre::String& name)
@@ -912,7 +920,7 @@
         }
     }
 
-    //! Copies our own parameters for restitution, angular factor, dampings and friction to the bullet rigid body.
+    //! Copies our own parameters for restitution, angular factor, damping and friction to the bullet rigid body.
     void WorldEntity::internalSetPhysicsProps()
     {
         if (this->hasPhysics())

Modified: code/branches/steering/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- code/branches/steering/src/orxonox/worldentities/WorldEntity.h	2009-11-12 18:41:20 UTC (rev 6051)
+++ code/branches/steering/src/orxonox/worldentities/WorldEntity.h	2009-11-12 19:00:42 UTC (rev 6052)
@@ -32,6 +32,7 @@
 
 #include "OrxonoxPrereqs.h"
 
+#include <OgreUserDefinedObject.h>
 #ifdef ORXONOX_RELEASE
 #  include <OgreSceneNode.h>
 #endif
@@ -54,7 +55,7 @@
         as more advanced ones.
 
         The basic task of the WorldEntity is provide a location, a direction and a scaling and the possibility
-        to create an entire hierarchy of derivated objects.
+        to create an entire hierarchy of derived objects.
         It is also the basis for the physics interface to the Bullet physics engine.
         Every WorldEntity can have a specific collision type: @see CollisionType
         This would then imply that every scene object could have any collision type. To limit this, you can always
@@ -62,13 +63,13 @@
         for a specific object.
         There is also support for attaching WorldEntities with physics to each other. Currently, the collision shape
         of both objects simply get merged into one larger shape (for static collision type).
-        The phyiscal body that is internally stored and administrated has the following supported properties:
-        - Restitution, angular factor, linear damping, angular damping, fricition, mass and collision shape.
+        The physical body that is internally stored and administrated has the following supported properties:
+        - Restitution, angular factor, linear damping, angular damping, friction, mass and collision shape.
         You can get more information at the corresponding set function.
 
         Collision shapes: These are controlled by the internal WorldEntityCollisionShape. @see WorldEntityCollisionShape.
     */
-    class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState
+    class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState, public Ogre::UserDefinedObject
     {
         friend class Scene;
 
@@ -317,7 +318,7 @@
             @brief
                 Sets an artificial parameter that tells how much torque is applied when you apply a non-central force.
 
-                Normally the angular factor is 1, which means it's physically 'correct'. Howerver if you have a player
+                Normally the angular factor is 1, which means it's physically 'correct'. However if you have a player
                 character that should not rotate when hit sideways, you can set the angular factor to 0.
             */
             inline void setAngularFactor(float angularFactor)
@@ -393,7 +394,7 @@
 
                 You can override this function in a derived class to constrain the collision to e.g. None or Dynamic.
                 A projectile may not prove very useful if there is no physical body. Simply set the CollisionType
-                in its constructor and override this method. But be careful that a derived classe's virtual functions
+                in its constructor and override this method. But be careful that a derived class's virtual functions
                 don't yet exist in the constructor if a base class.
             */
             virtual bool isCollisionTypeLegal(CollisionType type) const = 0;




More information about the Orxonox-commit mailing list