Changeset 10189 for code/trunk/src
- Timestamp:
- Jan 11, 2015, 3:40:41 PM (10 years ago)
- Location:
- code/trunk/src
- Files:
-
- 2 added
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/CoreIncludes.h
r9667 r10189 114 114 115 115 /** 116 @brief Registers an abstract class in the framework. 116 @brief Registers an abstract class in the framework. Should be used in combination with inheritsFrom(base-class-identifier). 117 117 @param ClassName The name of the class 118 118 */ -
code/trunk/src/modules/objects/ObjectsPrereqs.h
r9526 r10189 76 76 77 77 // collisionshapes 78 class AbstractRadiusHeightCollisionShape; 78 79 class BoxCollisionShape; 79 80 class ConeCollisionShape; 81 class CylinderCollisionShape; 80 82 class PlaneCollisionShape; 81 83 class SphereCollisionShape; -
code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc
r10184 r10189 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Fabian 'x3n' Landau 26 26 * 27 27 */ 28 28 29 29 /** 30 @file ConeCollisionShape.cc31 @brief Implementation of the ConeCollisionShape class.30 @file AbstractRadiusHeightCollisionShape.cc 31 @brief Implementation of the AbstractRadiusHeightCollisionShape class. 32 32 */ 33 33 34 #include "ConeCollisionShape.h" 35 36 #include <BulletCollision/CollisionShapes/btConeShape.h> 34 #include "AbstractRadiusHeightCollisionShape.h" 37 35 38 36 #include "core/CoreIncludes.h" … … 42 40 namespace orxonox 43 41 { 44 Register Class(ConeCollisionShape);42 RegisterAbstractClass(AbstractRadiusHeightCollisionShape).inheritsFrom(Class(CollisionShape)); 45 43 46 44 /** … … 48 46 Constructor. Registers and initializes the object. 49 47 */ 50 ConeCollisionShape::ConeCollisionShape(Context* context) : CollisionShape(context)48 AbstractRadiusHeightCollisionShape::AbstractRadiusHeightCollisionShape(Context* context) : CollisionShape(context) 51 49 { 52 RegisterObject( ConeCollisionShape);50 RegisterObject(AbstractRadiusHeightCollisionShape); 53 51 54 52 this->radius_ = 1.0f; 55 53 this->height_ = 1.0f; 56 updateShape();57 54 58 55 this->registerVariables(); 59 56 } 60 57 61 ConeCollisionShape::~ConeCollisionShape() 62 { 63 if (this->isInitialized()) 64 delete this->collisionShape_; 65 } 66 67 void ConeCollisionShape::registerVariables() 58 void AbstractRadiusHeightCollisionShape::registerVariables() 68 59 { 69 60 registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape)); … … 71 62 } 72 63 73 void ConeCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)64 void AbstractRadiusHeightCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode) 74 65 { 75 SUPER( ConeCollisionShape, XMLPort, xmlelement, mode);66 SUPER(AbstractRadiusHeightCollisionShape, XMLPort, xmlelement, mode); 76 67 77 XMLPortParam( ConeCollisionShape, "radius", setRadius, getRadius, xmlelement, mode);78 XMLPortParam( ConeCollisionShape, "height", setHeight, getHeight, xmlelement, mode);68 XMLPortParam(AbstractRadiusHeightCollisionShape, "radius", setRadius, getRadius, xmlelement, mode); 69 XMLPortParam(AbstractRadiusHeightCollisionShape, "height", setHeight, getHeight, xmlelement, mode); 79 70 } 80 71 81 72 /** 82 73 @brief 83 Is called when the scale of the ConeCollisionShape has changed.74 Is called when the scale of the AbstractRadiusHeightCollisionShape has changed. 84 75 */ 85 void ConeCollisionShape::changedScale()76 void AbstractRadiusHeightCollisionShape::changedScale() 86 77 { 87 78 CollisionShape::changedScale(); … … 92 83 if(!this->hasUniformScaling()) 93 84 { 94 orxout(internal_error) << " ConeCollisionShape: Non-uniform scaling is not yet supported." << endl;85 orxout(internal_error) << "AbstractRadiusHeightCollisionShape: Non-uniform scaling is not yet supported." << endl; 95 86 return; 96 87 } … … 100 91 this->updateShape(); 101 92 } 102 103 /**104 @brief105 Creates a new internal collision shape for the ConeCollisionShape.106 @return107 Returns a pointer to the newly created btConeShape.108 */109 btCollisionShape* ConeCollisionShape::createNewShape() const110 {111 return new btConeShape(this->radius_, this->height_);112 }113 93 } -
code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.h
r10184 r10189 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Fabian 'x3n' Landau 26 26 * 27 27 */ 28 28 29 29 /** 30 @file ConeCollisionShape.h31 @brief Definition of the ConeCollisionShape class.30 @file AbstractRadiusHeightCollisionShape.h 31 @brief Definition of the AbstractRadiusHeightCollisionShape class. 32 32 @ingroup Collisionshapes 33 33 */ 34 34 35 #ifndef _ ConeCollisionShape_H__36 #define _ ConeCollisionShape_H__35 #ifndef _AbstractRadiusHeightCollisionShape_H__ 36 #define _AbstractRadiusHeightCollisionShape_H__ 37 37 38 38 #include "objects/ObjectsPrereqs.h" … … 44 44 /** 45 45 @brief 46 Wrapper for the bullet co ne collision shape class btConeShape.46 Wrapper for the bullet collision shapes with radius and height. 47 47 48 @author49 Reto Grieder50 51 @see btConeShape52 48 @ingroup Collisionshapes 53 49 */ 54 class _ObjectsExport ConeCollisionShape : public CollisionShape50 class _ObjectsExport AbstractRadiusHeightCollisionShape : public CollisionShape 55 51 { 56 52 public: 57 ConeCollisionShape(Context* context); 58 virtual ~ConeCollisionShape(); 53 AbstractRadiusHeightCollisionShape(Context* context); 59 54 60 55 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 61 56 62 57 /** 63 @brief Set the radius of the ConeCollisionShape.58 @brief Set the radius of the AbstractRadiusHeightCollisionShape. 64 59 If the radius changes, this causes the internal collision shape to be recreated. 65 60 @param value The radius to be set. … … 69 64 { if(this->radius_ == value) return false; this->radius_ = value; updateShape(); return true; } 70 65 /** 71 @brief Get the radius of the ConeCollisionShape.72 @return Returns the radius of the ConeCollisionShape.66 @brief Get the radius of the AbstractRadiusHeightCollisionShape. 67 @return Returns the radius of the AbstractRadiusHeightCollisionShape. 73 68 */ 74 69 inline float getRadius() const … … 76 71 77 72 /** 78 @brief Set the height of the ConeCollisionShape.73 @brief Set the height of the AbstractRadiusHeightCollisionShape. 79 74 If the height changes, this causes the internal collision shape to be recreated. 80 75 @param value The height to be set. … … 84 79 { if(this->height_ == value) return false; this->height_ = value; updateShape(); return true; } 85 80 /** 86 @brief Get the height of the ConeCollisionShape.87 @return Returns the height of the ConeCollisionShape.81 @brief Get the height of the AbstractRadiusHeightCollisionShape. 82 @return Returns the height of the AbstractRadiusHeightCollisionShape. 88 83 */ 89 84 inline float getHeight() const 90 85 { return this->height_; } 91 86 92 virtual void changedScale(); // Is called when the scale of the ConeCollisionShape has changed.87 virtual void changedScale(); // Is called when the scale of the AbstractRadiusHeightCollisionShape has changed. 93 88 94 89 private: 95 90 void registerVariables(); 96 91 97 btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the ConeCollisionShape. 98 99 float radius_; //!< The radius of the ConeCollisionShape. 100 float height_; //!< The height of the ConeCollisionShape. 92 float radius_; //!< The radius of the AbstractRadiusHeightCollisionShape. 93 float height_; //!< The height of the AbstractRadiusHeightCollisionShape. 101 94 }; 102 95 } 103 96 104 #endif /* _ ConeCollisionShape_H__ */97 #endif /* _AbstractRadiusHeightCollisionShape_H__ */ -
code/trunk/src/modules/objects/collisionshapes/CMakeLists.txt
r5781 r10189 1 1 ADD_SOURCE_FILES(OBJECTS_SRC_FILES 2 AbstractRadiusHeightCollisionShape.cc 2 3 BoxCollisionShape.cc 3 4 ConeCollisionShape.cc 5 CylinderCollisionShape.cc 4 6 PlaneCollisionShape.cc 5 7 SphereCollisionShape.cc -
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
r9667 r10189 37 37 38 38 #include "core/CoreIncludes.h" 39 #include "core/XMLPort.h"40 39 #include "tools/BulletConversions.h" 41 40 … … 48 47 Constructor. Registers and initializes the object. 49 48 */ 50 ConeCollisionShape::ConeCollisionShape(Context* context) : CollisionShape(context)49 ConeCollisionShape::ConeCollisionShape(Context* context) : AbstractRadiusHeightCollisionShape(context) 51 50 { 52 51 RegisterObject(ConeCollisionShape); 53 52 54 this->radius_ = 1.0f;55 this->height_ = 1.0f;56 53 updateShape(); 57 58 this->registerVariables();59 54 } 60 55 … … 63 58 if (this->isInitialized()) 64 59 delete this->collisionShape_; 65 }66 67 void ConeCollisionShape::registerVariables()68 {69 registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));70 registerVariable(this->height_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));71 }72 73 void ConeCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)74 {75 SUPER(ConeCollisionShape, XMLPort, xmlelement, mode);76 77 XMLPortParam(ConeCollisionShape, "radius", setRadius, getRadius, xmlelement, mode);78 XMLPortParam(ConeCollisionShape, "height", setHeight, getHeight, xmlelement, mode);79 }80 81 /**82 @brief83 Is called when the scale of the ConeCollisionShape has changed.84 */85 void ConeCollisionShape::changedScale()86 {87 CollisionShape::changedScale();88 89 // Resize the internal collision shape90 // TODO: Assuming setLocalScaling works.91 //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));92 if(!this->hasUniformScaling())93 {94 orxout(internal_error) << "ConeCollisionShape: Non-uniform scaling is not yet supported." << endl;95 return;96 }97 98 this->radius_ *= this->getScale();99 this->height_ *= this->getScale();100 this->updateShape();101 60 } 102 61 … … 109 68 btCollisionShape* ConeCollisionShape::createNewShape() const 110 69 { 111 return new btConeShape(this-> radius_, this->height_);70 return new btConeShape(this->getRadius(), this->getHeight()); 112 71 } 113 72 } -
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h
r9667 r10189 37 37 38 38 #include "objects/ObjectsPrereqs.h" 39 #include " collisionshapes/CollisionShape.h"39 #include "AbstractRadiusHeightCollisionShape.h" 40 40 41 41 namespace orxonox … … 52 52 @ingroup Collisionshapes 53 53 */ 54 class _ObjectsExport ConeCollisionShape : public CollisionShape54 class _ObjectsExport ConeCollisionShape : public AbstractRadiusHeightCollisionShape 55 55 { 56 56 public: … … 58 58 virtual ~ConeCollisionShape(); 59 59 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);61 62 /**63 @brief Set the radius of the ConeCollisionShape.64 If the radius changes, this causes the internal collision shape to be recreated.65 @param value The radius to be set.66 @return Returns true if the radius has changed, false if not.67 */68 inline bool setRadius(float value)69 { if(this->radius_ == value) return false; this->radius_ = value; updateShape(); return true; }70 /**71 @brief Get the radius of the ConeCollisionShape.72 @return Returns the radius of the ConeCollisionShape.73 */74 inline float getRadius() const75 { return radius_; }76 77 /**78 @brief Set the height of the ConeCollisionShape.79 If the height changes, this causes the internal collision shape to be recreated.80 @param value The height to be set.81 @return Returns true if the height has changed, false if not.82 */83 inline bool setHeight(float value)84 { if(this->height_ == value) return false; this->height_ = value; updateShape(); return true; }85 /**86 @brief Get the height of the ConeCollisionShape.87 @return Returns the height of the ConeCollisionShape.88 */89 inline float getHeight() const90 { return this->height_; }91 92 virtual void changedScale(); // Is called when the scale of the ConeCollisionShape has changed.93 94 60 private: 95 void registerVariables();96 97 61 btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the ConeCollisionShape. 98 99 float radius_; //!< The radius of the ConeCollisionShape.100 float height_; //!< The height of the ConeCollisionShape.101 62 }; 102 63 }
Note: See TracChangeset
for help on using the changeset viewer.