- Timestamp:
- Nov 12, 2008, 4:17:02 PM (16 years ago)
- Location:
- code/branches/physics/src/orxonox/objects
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/HelloBullet.cc
r2192 r2201 30 30 #include "HelloBullet.h" 31 31 32 #include <OgreSceneNode.h> 32 33 #include <OgreStaticGeometry.h> 33 34 #include <OgreSceneManager.h> -
code/branches/physics/src/orxonox/objects/HelloBullet.h
r2192 r2201 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "core/BaseObject.h" 34 #include <OgrePrerequisites.h> 34 35 35 36 #include "btBulletCollisionCommon.h" -
code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc
r2192 r2201 326 326 327 327 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 { 339 338 this->client_position_ = position; 340 339 } … … 355 354 } 356 355 } 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) 359 358 { 360 359 if (Core::isMaster()) … … 370 369 } 371 370 } 372 373 void ControllableEntity:: setOrientation(const Quaternion& orientation)371 // virtual void orientationChanged() { } 372 void ControllableEntity::orientationChanged(const Quaternion& orientation) 374 373 { 375 374 if (Core::isMaster()) … … 385 384 } 386 385 } 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) 389 388 { 390 389 if (Core::isMaster()) … … 400 399 } 401 400 } 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) 404 403 { 405 404 if (Core::isMaster()) … … 415 414 } 416 415 } 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) 419 418 { 420 419 if (Core::isMaster()) … … 430 429 } 431 430 } 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) 434 433 { 435 434 if (Core::isMaster()) … … 445 444 } 446 445 } 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) 449 448 { 450 449 if (Core::isMaster()) … … 460 459 } 461 460 } 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) 464 463 { 465 464 if (Core::isMaster()) -
code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h
r2192 r2201 79 79 { return this->hudtemplate_; } 80 80 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(); 92 82 void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL); 93 83 void setOrientation(const Quaternion& orientation); -
code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.cc
r2192 r2201 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Martin Stypinski 26 26 * 27 27 */ … … 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "MovableEntity.h" 31 32 #include "objects/Scene.h" 31 33 32 34 #include "core/CoreIncludes.h" … … 54 56 { 55 57 } 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 56 141 } -
code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h
r2192 r2201 47 47 void registerVariables(); 48 48 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 49 70 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( ) { } 50 81 51 82 //void attachPhysicalObject(WorldEntity* object); -
code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc
r2192 r2201 148 148 } 149 149 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 150 168 void WorldEntity::detach(WorldEntity* object) 151 169 {
Note: See TracChangeset
for help on using the changeset viewer.