Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 8:55:40 PM (17 years ago)
Author:
rgrieder
Message:
  • Handled translate, rotate, yaw, pitch, roll, lookAt and setDirection internally in WE. That only leaves setPosition and setOrientation to be pure virtual.
  • Removed loads of redundant and now obsolete code in MobileEntity and StaticEntity
  • Removed OgreSceneNode.h from WorldEntity in debug builds. getPosition, getOrientation and getScale3D are only inline in release mode. That should speed up dev builds a lot (the include is about 8300 line without Vector3, Quaternion, etc.)

Important:

  • Fixed a bug or introduced one: the lookAt(…) function in WE had default TransformSpace "TS_LOCAL", but that makes no sense the way I see it. Consider a SpaceShip and you would like it to face an asteroid. Then TS_LOCAL would yield weird results. The XMLPort attribute "lookAt" used the default value. That's where the bug might have been fixed or (I don't believe so) introduced.
File:
1 edited

Legend:

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

    r2408 r2426  
    3030#include "MobileEntity.h"
    3131
     32#include <OgreSceneNode.h>
    3233#include "BulletDynamics/Dynamics/btRigidBody.h"
    3334
     
    117118    }
    118119
    119     void MobileEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
    120     {
    121         if (this->isDynamic())
    122         {
    123             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot translate physical object relative \
    124                                                           to any other space than TS_LOCAL.");
    125             this->physicalBody_->translate(btVector3(distance.x, distance.y, distance.z));
    126         }
    127 
    128         this->node_->translate(distance, relativeTo);
    129         positionChanged(false);
    130     }
    131 
    132120    void MobileEntity::setOrientation(const Quaternion& orientation)
    133121    {
     
    140128
    141129        this->node_->setOrientation(orientation);
    142         orientationChanged(false);
    143     }
    144 
    145     void MobileEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    146     {
    147         if (this->isDynamic())
    148         {
    149             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot rotate physical object relative \
    150                                                           to any other space than TS_LOCAL.");
    151             btTransform transf = this->physicalBody_->getWorldTransform();
    152             this->physicalBody_->setWorldTransform(transf * btTransform(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)));
    153         }
    154 
    155         this->node_->rotate(rotation, relativeTo);
    156         orientationChanged(false);
    157     }
    158 
    159     void MobileEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    160     {
    161         if (this->isDynamic())
    162         {
    163             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot yaw physical object relative \
    164                                                           to any other space than TS_LOCAL.");
    165             btTransform transf = this->physicalBody_->getWorldTransform();
    166             btTransform rotation(btQuaternion(angle.valueRadians(), 0.0f, 0.0f));
    167             this->physicalBody_->setWorldTransform(transf * rotation);
    168         }
    169 
    170         this->node_->yaw(angle, relativeTo);
    171         orientationChanged(false);
    172     }
    173 
    174     void MobileEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    175     {
    176         if (this->isDynamic())
    177         {
    178             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot pitch physical object relative \
    179                                                           to any other space than TS_LOCAL.");
    180             btTransform transf = this->physicalBody_->getWorldTransform();
    181             btTransform rotation(btQuaternion(0.0f, angle.valueRadians(), 0.0f));
    182             this->physicalBody_->setWorldTransform(transf * rotation);
    183         }
    184 
    185         this->node_->pitch(angle, relativeTo);
    186         orientationChanged(false);
    187     }
    188 
    189     void MobileEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    190     {
    191         if (this->isDynamic())
    192         {
    193             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot roll physical object relative \
    194                                                           to any other space than TS_LOCAL.");
    195             btTransform transf = this->physicalBody_->getWorldTransform();
    196             btTransform rotation(btQuaternion(angle.valueRadians(), 0.0f, 0.0f));
    197             this->physicalBody_->setWorldTransform(transf * rotation);
    198         }
    199 
    200         this->node_->roll(angle, relativeTo);
    201         orientationChanged(false);
    202     }
    203 
    204     void MobileEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    205     {
    206         if (this->isDynamic())
    207         {
    208             ThrowException(NotImplemented, "ControllableEntity::lookAt() is not yet supported for physical objects.");
    209             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    210                                                           to any other space than TS_LOCAL.");
    211         }
    212 
    213         this->node_->lookAt(target, relativeTo, localDirectionVector);
    214         orientationChanged(false);
    215     }
    216 
    217     void MobileEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    218     {
    219         if (this->isDynamic())
    220         {
    221             ThrowException(NotImplemented, "ControllableEntity::setDirection() is not yet supported for physical objects.");
    222             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    223                                                           to any other space than TS_LOCAL.");
    224         }
    225 
    226         this->node_->setDirection(direction, relativeTo, localDirectionVector);
    227130        orientationChanged(false);
    228131    }
Note: See TracChangeset for help on using the changeset viewer.