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/StaticEntity.cc

    r2423 r2426  
    3131#include "StaticEntity.h"
    3232
     33#include <OgreSceneNode.h>
    3334#include "BulletDynamics/Dynamics/btRigidBody.h"
    3435
     
    7273    }
    7374
    74     void StaticEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
    75     {
    76         if (this->addedToPhysicalWorld())
    77             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    78         if (this->isStatic())
    79         {
    80             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot translate physical object relative \
    81                                                           to any other space than TS_LOCAL.");
    82             this->physicalBody_->translate(btVector3(distance.x, distance.y, distance.z));
    83         }
    84 
    85         this->node_->translate(distance, relativeTo);
    86     }
    87 
    8875    void StaticEntity::setOrientation(const Quaternion& orientation)
    8976    {
     
    9885
    9986        this->node_->setOrientation(orientation);
    100     }
    101 
    102     void StaticEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    103     {
    104         if (this->addedToPhysicalWorld())
    105             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    106         if (this->isStatic())
    107         {
    108             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot rotate physical object relative \
    109                                                           to any other space than TS_LOCAL.");
    110             btTransform transf = this->physicalBody_->getWorldTransform();
    111             this->physicalBody_->setWorldTransform(transf * btTransform(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)));
    112         }
    113 
    114         this->node_->rotate(rotation, relativeTo);
    115     }
    116 
    117     void StaticEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    118     {
    119         if (this->addedToPhysicalWorld())
    120             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    121         if (this->isStatic())
    122         {
    123             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot yaw physical object relative \
    124                                                           to any other space than TS_LOCAL.");
    125             btTransform transf = this->physicalBody_->getWorldTransform();
    126             btTransform rotation(btQuaternion(angle.valueRadians(), 0.0f, 0.0f));
    127             this->physicalBody_->setWorldTransform(transf * rotation);
    128         }
    129 
    130         this->node_->yaw(angle, relativeTo);
    131     }
    132 
    133     void StaticEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    134     {
    135         if (this->addedToPhysicalWorld())
    136             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    137         if (this->isStatic())
    138         {
    139             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot pitch physical object relative \
    140                                                           to any other space than TS_LOCAL.");
    141             btTransform transf = this->physicalBody_->getWorldTransform();
    142             btTransform rotation(btQuaternion(0.0f, angle.valueRadians(), 0.0f));
    143             this->physicalBody_->setWorldTransform(transf * rotation);
    144         }
    145 
    146         this->node_->pitch(angle, relativeTo);
    147     }
    148 
    149     void StaticEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    150     {
    151         if (this->addedToPhysicalWorld())
    152             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    153         if (this->isStatic())
    154         {
    155             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot roll physical object relative \
    156                                                           to any other space than TS_LOCAL.");
    157             btTransform transf = this->physicalBody_->getWorldTransform();
    158             btTransform rotation(btQuaternion(angle.valueRadians(), 0.0f, 0.0f));
    159             this->physicalBody_->setWorldTransform(transf * rotation);
    160         }
    161 
    162         this->node_->roll(angle, relativeTo);
    163     }
    164 
    165     void StaticEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    166     {
    167         if (this->addedToPhysicalWorld())
    168             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    169         if (this->isStatic())
    170         {
    171             ThrowException(NotImplemented, "ControllableEntity::lookAt() is not yet supported for physical objects.");
    172             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    173                                                           to any other space than TS_LOCAL.");
    174         }
    175 
    176         this->node_->lookAt(target, relativeTo, localDirectionVector);
    177     }
    178 
    179     void StaticEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    180     {
    181         if (this->addedToPhysicalWorld())
    182             ThrowException(PhysicsViolation, "Cannot change position or orientation of a StaticEntity with physics at run time.");
    183         if (this->isStatic())
    184         {
    185             ThrowException(NotImplemented, "ControllableEntity::setDirection() is not yet supported for physical objects.");
    186             OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    187                                                           to any other space than TS_LOCAL.");
    188         }
    189 
    190         this->node_->setDirection(direction, relativeTo, localDirectionVector);
    19187    }
    19288
Note: See TracChangeset for help on using the changeset viewer.