- Timestamp:
- Dec 13, 2008, 8:55:40 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/StaticEntity.cc
r2423 r2426 31 31 #include "StaticEntity.h" 32 32 33 #include <OgreSceneNode.h> 33 34 #include "BulletDynamics/Dynamics/btRigidBody.h" 34 35 … … 72 73 } 73 74 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 88 75 void StaticEntity::setOrientation(const Quaternion& orientation) 89 76 { … … 98 85 99 86 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);191 87 } 192 88
Note: See TracChangeset
for help on using the changeset viewer.