- Timestamp:
- May 8, 2011, 11:45:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup/src/modules/objects/collisionshapes/BoxCollisionShape.h
r7601 r8422 43 43 namespace orxonox 44 44 { 45 46 /** 47 @brief 48 Wrapper for the bullet box collision shape class btBoxShape. 49 50 @author 51 Reto Grieder 52 53 @ingroup Collisionshapes 54 */ 45 55 class _ObjectsExport BoxCollisionShape : public CollisionShape 46 56 { … … 51 61 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 62 53 inline void setHalfExtents(const Vector3& extents) 54 { this->halfExtents_ = extents; updateShape(); } 63 /** 64 @brief Set the half extents of the BoxCollisionShape. 65 If the half extent changes, this causes the internal collision shape to be recreated. 66 @param extents A vector with the half extents. 67 The x-component is half the length, the y-component is half the height and the z-component is half the width. 68 @return Returns true if the half extent has changed, false if not. 69 */ 70 inline bool setHalfExtents(const Vector3& extents) 71 { if(this->halfExtents_ == extents) return false; this->halfExtents_ = extents; updateShape(); return true; } 72 /** 73 @brief Get the half extents of the BoxCollisionShape. 74 @return Returns a vector containing the half extents. 75 */ 55 76 inline const Vector3& getHalfExtents() const 56 77 { return halfExtents_;} 57 78 58 inline void setWidth(float value) 59 { this->halfExtents_.z = value / 2; updateShape(); } 79 /** 80 @brief Set the width of the BoxCollisionShape. 81 If the width changes, this causes the internal collision shape to be recreated. 82 @param value The width to be set. 83 @return Returns true if the width has changed, false if not. 84 */ 85 inline bool setWidth(float value) 86 { if(this->halfExtents_.z == value/2.0f) return false; this->halfExtents_.z = value / 2.0f; updateShape(); return true; } 87 /** 88 @brief Get the width of the BoxCollisionShape. 89 @return Returns the width of the BoxCollisionShape. 90 */ 60 91 inline float getWidth() const 61 { return this->halfExtents_.z * 2 ; }92 { return this->halfExtents_.z * 2.0f; } 62 93 63 inline void setHeight(float value) 64 { this->halfExtents_.y = value / 2; updateShape(); } 94 /** 95 @brief Set the height of the BoxCollisionShape. 96 If the height changes, this causes the internal collision shape to be recreated. 97 @param value The height to be set. 98 @return Returns true if the height has changed, false if not. 99 */ 100 inline bool setHeight(float value) 101 { if(this->halfExtents_.y == value/2.0f) return false; this->halfExtents_.y = value / 2.0f; updateShape(); return true; } 102 /** 103 @brief Get the height of the BoxCollisionShape. 104 @return Returns the height of the BoxCollisionShape. 105 */ 65 106 inline float getHeight() const 66 { return this->halfExtents_.y * 2 ; }107 { return this->halfExtents_.y * 2.0f; } 67 108 68 inline void setLength(float value) 69 { this->halfExtents_.x = value / 2; updateShape(); } 109 /** 110 @brief Set the length of the BoxCollisionShape. 111 If the length changes, this causes the internal collision shape to be recreated. 112 @param value The length to be set. 113 @return Returns true if the length has changed, false if not. 114 */ 115 inline bool setLength(float value) 116 { if(this->halfExtents_.x == value/2.0f) return false; this->halfExtents_.x = value / 2.0f; updateShape(); return true; } 117 /** 118 @brief Get the length of the BoxCollisionShape. 119 @return Returns the length of the BoxCollisionShape. 120 */ 70 121 inline float getLength() const 71 { return this->halfExtents_.x * 2; } 122 { return this->halfExtents_.x * 2.0f; } 123 124 virtual void changedScale(); // Is called when the scale of the BoxCollisionShape has changed. 72 125 73 126 private: 74 127 void registerVariables(); 75 128 76 btCollisionShape* createNewShape() const; 129 btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the BoxCollisionShape. 77 130 78 Vector3 halfExtents_; 131 Vector3 halfExtents_; //!< The half extents of the BoxCollisionShape. The x-component is half the length, the y-component is half the height and the z-component is half the width. 79 132 }; 80 133 }
Note: See TracChangeset
for help on using the changeset viewer.