Changeset 2374 for code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/CollisionShape.cc
- Timestamp:
- Dec 10, 2008, 1:38:17 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/CollisionShape.cc
r2306 r2374 37 37 #include "tools/BulletConversions.h" 38 38 39 #include "CompoundCollisionShape.h" 40 39 41 namespace orxonox 40 42 { 41 43 CreateFactory(CollisionShape); 42 44 43 CollisionShape::CollisionShape(BaseObject* creator) : StaticEntity(creator) 45 CollisionShape::CollisionShape(BaseObject* creator) 46 : BaseObject(creator) 47 , network::Synchronisable(creator) 44 48 { 45 49 RegisterObject(CollisionShape); 46 50 47 this->bIsCompound_ = false; 51 this->parent_ = 0; 52 this->parentID_ = (unsigned int)-1; 53 this->collisionShape_ = 0; 48 54 } 49 55 … … 55 61 { 56 62 SUPER(CollisionShape, XMLPort, xmlelement, mode); 63 64 XMLPortParamTemplate(CollisionShape, "position", setPosition, getPosition, xmlelement, mode, const Vector3&); 65 XMLPortParamTemplate(CollisionShape, "orientation", setOrientation, getOrientation, xmlelement, mode, const Quaternion&); 66 XMLPortParamLoadOnly(CollisionShape, "yaw", yaw, xmlelement, mode); 67 XMLPortParamLoadOnly(CollisionShape, "pitch", pitch, xmlelement, mode); 68 XMLPortParamLoadOnly(CollisionShape, "roll", roll, xmlelement, mode); 69 XMLPortParamTemplate(CollisionShape, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&); 70 XMLPortParamLoadOnly(CollisionShape, "scale", setScale, xmlelement, mode); 57 71 } 58 72 59 bool CollisionShape::isCollisionTypeLegal(WorldEntity::CollisionType type) const73 void CollisionShape::registerVariables() 60 74 { 61 if (type != WorldEntity::None) 62 { 63 ThrowException(PhysicsViolation, "A CollisionShape can only have CollisionType 'None'."); 64 return false; 65 } 66 else 67 return true; 75 REGISTERDATA(this->parentID_, network::direction::toclient, new network::NetworkCallback<CollisionShape>(this, &CollisionShape::updateParent)); 68 76 } 69 77 70 bool CollisionShape::hasNoTransform() const78 void CollisionShape::updateParent() 71 79 { 72 return (this->getPosition().positionEquals(Vector3(0, 0, 0), 0.001) && 73 this->getOrientation().equals(Quaternion(1,0,0,0), Degree(0.1))); 80 CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_)); 81 if (parent) 82 parent->addChildShape(this); 74 83 } 75 84 76 b tVector3 CollisionShape::getTotalScaling()85 bool CollisionShape::hasTransform() const 77 86 { 78 return omni_cast<btVector3>(this->node_->getScale()); 87 return (!this->position_.positionEquals(Vector3(0, 0, 0), 0.001) || 88 !this->orientation_.equals(Quaternion(1,0,0,0), Degree(0.1))); 79 89 } 80 90 … … 84 94 } 85 95 86 void CollisionShape::s cale3D(const Vector3&scale)96 void CollisionShape::setScale(float scale) 87 97 { 88 98 ThrowException(NotImplemented, "Cannot set the scale of a collision shape: Not yet implemented.");
Note: See TracChangeset
for help on using the changeset viewer.