- 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/MobileEntity.cc
r2408 r2426 30 30 #include "MobileEntity.h" 31 31 32 #include <OgreSceneNode.h> 32 33 #include "BulletDynamics/Dynamics/btRigidBody.h" 33 34 … … 117 118 } 118 119 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 132 120 void MobileEntity::setOrientation(const Quaternion& orientation) 133 121 { … … 140 128 141 129 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);227 130 orientationChanged(false); 228 131 }
Note: See TracChangeset
for help on using the changeset viewer.