Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 12, 2008, 4:17:02 PM (16 years ago)
Author:
martisty
Message:

loading objects and creating shapes…

Location:
code/branches/physics/src/orxonox/objects/worldentities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2192 r2201  
    326326
    327327
    328     void ControllableEntity::setPosition(const Vector3& position)
    329     {
    330         if (Core::isMaster())
    331         {
    332             this->node_->setPosition(position);
    333             this->server_position_ = position;
    334             ++this->server_overwrite_;
    335         }
    336         else if (this->bControlled_)
    337         {
    338             this->node_->setPosition(position);
     328    // virtual void PositionChanged() { }
     329    void ControllableEntity::positionChanged(const Vector3& position)
     330    {
     331        if (Core::isMaster())
     332        {
     333            this->server_position_ = this->getPosition();
     334            ++this->server_overwrite_;
     335        }
     336        else if (this->bControlled_)
     337        {
    339338            this->client_position_ = position;
    340339        }
     
    355354        }
    356355    }
    357 
    358     void ControllableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
     356    // virtual void translateChanged() { }
     357    void ControllableEntity::translateChanged(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
    359358    {
    360359        if (Core::isMaster())
     
    370369        }
    371370    }
    372 
    373     void ControllableEntity::setOrientation(const Quaternion& orientation)
     371    // virtual void orientationChanged() { }
     372    void ControllableEntity::orientationChanged(const Quaternion& orientation)
    374373    {
    375374        if (Core::isMaster())
     
    385384        }
    386385    }
    387 
    388     void ControllableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
     386    // virtual void rotateChanged() { }
     387    void ControllableEntity::rotateChanged(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    389388    {
    390389        if (Core::isMaster())
     
    400399        }
    401400    }
    402 
    403     void ControllableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
     401    // virtual void yawChanged() { }
     402    void ControllableEntity::yawChanged(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    404403    {
    405404        if (Core::isMaster())
     
    415414        }
    416415    }
    417 
    418     void ControllableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
     416    // virtual void pitchChanged() { }
     417    void ControllableEntity::pitchChanged(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    419418    {
    420419        if (Core::isMaster())
     
    430429        }
    431430    }
    432 
    433     void ControllableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
     431    // virtual void rollChanged() { }
     432    void ControllableEntity::rollChanged(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    434433    {
    435434        if (Core::isMaster())
     
    445444        }
    446445    }
    447 
    448     void ControllableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
     446    //virtual void lookAtChanged() { }
     447    void ControllableEntity::lookAtChanged(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    449448    {
    450449        if (Core::isMaster())
     
    460459        }
    461460    }
    462 
    463     void ControllableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
     461    // virtual void directionChanged( ) { }
     462    void ControllableEntity::directionChanged(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    464463    {
    465464        if (Core::isMaster())
  • code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h

    r2192 r2201  
    7979                { return this->hudtemplate_; }
    8080
    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);
     81            void setPosition();
    9282            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    9383            void setOrientation(const Quaternion& orientation);
  • code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.cc

    r2192 r2201  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Martin Stypinski
    2626 *
    2727 */
     
    2929#include "OrxonoxStableHeaders.h"
    3030#include "MovableEntity.h"
     31
     32#include "objects/Scene.h"
    3133
    3234#include "core/CoreIncludes.h"
     
    5456    {
    5557    }
     58
     59    void MovableEntity::setPosition(const Vector3& position){
     60        // Here the code
     61        if(isDynamic() && bAddedToPhysicalWorld_){
     62            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     63            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     64        }
     65        this->node_->setPosition(position);
     66        positionChanged();
     67    }
     68
     69    void MovableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo){
     70        if(isDynamic() && bAddedToPhysicalWorld_){
     71            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     72            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     73        }
     74        this->node_->translate(distance, relativeTo);
     75        translateChanged();
     76    }
     77
     78    void MovableEntity::setOrientation(const Quaternion& orientation){
     79        if(isDynamic() && bAddedToPhysicalWorld_){
     80            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     81            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     82        }
     83        this->node_->setOrientation(orientation);
     84        orientationChanged();
     85    }
     86
     87    void MovableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo){
     88        if(isDynamic() && bAddedToPhysicalWorld_){
     89            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     90            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     91        }
     92        this->node_->rotate(rotation, relativeTo);
     93        rotateChanged();
     94    }
     95
     96    void MovableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo){
     97        if(isDynamic() && bAddedToPhysicalWorld_){
     98            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     99            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     100        }
     101        this->node_->yaw(angle, relativeTo);
     102        yawChanged();
     103    }
     104
     105    void MovableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo){
     106        if(isDynamic() && bAddedToPhysicalWorld_){
     107            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     108            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     109        }
     110        this->node_->pitch(angle, relativeTo);
     111        pitchChanged();
     112    }
     113
     114    void MovableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo){
     115        if(isDynamic() && bAddedToPhysicalWorld_){
     116            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     117            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     118        }
     119        this->node_->roll(angle, relativeTo);
     120        rollChanged();
     121    }
     122
     123    void MovableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector){
     124        if(isDynamic() && bAddedToPhysicalWorld_){
     125            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     126            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     127        }
     128        this->node_->lookAt(target, relativeTo, localDirectionVector);
     129        lookAtChanged();
     130    }
     131
     132    void MovableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector){
     133        if(isDynamic() && bAddedToPhysicalWorld_){
     134            this->getScene()->getPhysicalWorld()->removeRigidBody(this->physicalBody_);
     135            this->getScene()->getPhysicalWorld()->addRigidBody(this->physicalBody_);
     136        }
     137        this->node_->setDirection(direction, relativeTo, localDirectionVector);
     138        directionChanged();
     139    }
     140
    56141}
  • code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h

    r2192 r2201  
    4747            void registerVariables();
    4848
     49            using WorldEntity::setPosition;
     50            using WorldEntity::translate;
     51            using WorldEntity::setOrientation;
     52            using WorldEntity::rotate;
     53            using WorldEntity::yaw;
     54            using WorldEntity::pitch;
     55            using WorldEntity::roll;
     56            using WorldEntity::lookAt;
     57            using WorldEntity::setDirection;
     58
     59            void setPosition(const Vector3& position);
     60            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
     61            void setOrientation(const Quaternion& orientation);
     62            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
     63            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
     64            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
     65            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
     66            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     67            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     68
     69
    4970        private:
     71
     72            virtual void rollChanged() { }
     73            virtual void positionChanged() { }
     74            virtual void translateChanged() { }
     75            virtual void orientationChanged() { }
     76            virtual void rotateChanged() { }
     77            virtual void yawChanged() { }
     78            virtual void pitchChanged() { }
     79            virtual void lookAtChanged() { }
     80            virtual void directionChanged( ) { }
    5081
    5182            //void attachPhysicalObject(WorldEntity* object);
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc

    r2192 r2201  
    148148    }
    149149
     150    void WorldEntitiy::attachPhysicalObject(WorldEntity* object){
     151    //function attachhysicalObject
     152        StaticEntity* staticObject = dynamic_cast<WorldEntity*>(object);
     153        if (staticObject != 0 && hasPhysics()){
     154           btCompountShape* compoundShape = dynamic_cast<btCompoundShape*>(physicalBody_->getCollisionShape());
     155           if(compoundShape == 0){
     156                //NEW
     157                btCompoundShape* newShape = new btCompoundShape();
     158                newShape->addChildShape(this->physcialBody_->getCollisionShape());
     159                newShape->addChildShape(staticObject->getCollisionShape());
     160                this->physicalBody_->setCollisionShape();
     161           }
     162           else{
     163               compoundShape -> addChildShape(staticObject->getCollisionShape());
     164           }
     165        }
     166    }
     167
    150168    void WorldEntity::detach(WorldEntity* object)
    151169    {
Note: See TracChangeset for help on using the changeset viewer.