[Orxonox-commit 176] r2851 - trunk/src/orxonox/objects/worldentities

landauf at orxonox.net landauf at orxonox.net
Thu Mar 26 11:59:40 CET 2009


Author: landauf
Date: 2009-03-26 10:59:39 +0000 (Thu, 26 Mar 2009)
New Revision: 2851

Modified:
   trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
   trunk/src/orxonox/objects/worldentities/ControllableEntity.h
   trunk/src/orxonox/objects/worldentities/WorldEntity.cc
   trunk/src/orxonox/objects/worldentities/WorldEntity.h
Log:
Fixed attachment of "absolute" CameraPosition-Nodes in the Network (this refers to the top-down camera in Pong)

Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-03-25 22:53:04 UTC (rev 2850)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-03-26 10:59:39 UTC (rev 2851)
@@ -334,6 +334,19 @@
         }
     }
 
+    void ControllableEntity::parentChanged()
+    {
+        WorldEntity::parentChanged();
+
+        WorldEntity* parent = this->getParent();
+        if (parent)
+        {
+            for (std::list<CameraPosition*>::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+                if ((*it)->getIsAbsolute())
+                    parent->attach((*it));
+        }
+    }
+
     void ControllableEntity::tick(float dt)
     {
         MobileEntity::tick(dt);

Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.h	2009-03-25 22:53:04 UTC (rev 2850)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.h	2009-03-26 10:59:39 UTC (rev 2851)
@@ -136,6 +136,7 @@
         protected:
             virtual void startLocalHumanControl();
             virtual void stopLocalHumanControl();
+            virtual void parentChanged();
 
             inline void setHudTemplate(const std::string& name)
                 { this->hudtemplate_ = name; }

Modified: trunk/src/orxonox/objects/worldentities/WorldEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/WorldEntity.cc	2009-03-25 22:53:04 UTC (rev 2850)
+++ trunk/src/orxonox/objects/worldentities/WorldEntity.cc	2009-03-26 10:59:39 UTC (rev 2851)
@@ -180,14 +180,14 @@
                                                 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged));
 
         // Attach to parent if necessary
-        registerVariable(this->parentID_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::parentChanged));
+        registerVariable(this->parentID_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::networkcallback_parentChanged));
     }
 
     /**
     @brief
         Network function that object this instance to its correct parent.
     */
-    void WorldEntity::parentChanged()
+    void WorldEntity::networkcallback_parentChanged()
     {
         if (this->parentID_ != OBJECTID_UNKNOWN)
         {
@@ -361,11 +361,13 @@
         this->parent_ = newParent;
         this->parentID_ = newParent->getObjectID();
 
+        this->parentChanged();
+
         // apply transform to collision shape
         this->collisionShape_->setPosition(this->getPosition());
         this->collisionShape_->setOrientation(this->getOrientation());
         // TODO: Scale
-        
+
         return true;
     }
 
@@ -406,6 +408,8 @@
         this->parent_ = 0;
         this->parentID_ = OBJECTID_UNKNOWN;
 
+        this->parentChanged();
+
         // reset orientation of the collisionShape (cannot be set within a WE usually)
         this->collisionShape_->setPosition(Vector3::ZERO);
         this->collisionShape_->setOrientation(Quaternion::IDENTITY);

Modified: trunk/src/orxonox/objects/worldentities/WorldEntity.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/WorldEntity.h	2009-03-25 22:53:04 UTC (rev 2850)
+++ trunk/src/orxonox/objects/worldentities/WorldEntity.h	2009-03-26 10:59:39 UTC (rev 2851)
@@ -175,6 +175,8 @@
             void notifyChildPropsChanged();
 
         protected:
+            virtual void parentChanged() {}
+
             Ogre::SceneNode* node_;
 
         private:
@@ -190,7 +192,7 @@
                 { this->roll(angle); }
 
             // network callbacks
-            void parentChanged();
+            void networkcallback_parentChanged();
             inline void scaleChanged()
                 { this->setScale3D(this->getScale3D()); }
 
@@ -268,7 +270,7 @@
             /**
             @brief
                 Sets how much reaction is applied in a collision.
-                
+
                 Consider two equal spheres colliding with equal velocities:
                 Restitution 1 means that both spheres simply reverse their velocity (no loss of energy)
                 Restitution 0 means that both spheres will immediately stop moving




More information about the Orxonox-commit mailing list