Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 11, 2015, 3:40:41 PM (9 years ago)
Author:
landauf
Message:

added new collision shape (cylinder)

File:
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc

    r10184 r10189  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Fabian 'x3n' Landau
    2626 *
    2727 */
    2828
    2929/**
    30     @file ConeCollisionShape.cc
    31     @brief Implementation of the ConeCollisionShape class.
     30    @file AbstractRadiusHeightCollisionShape.cc
     31    @brief Implementation of the AbstractRadiusHeightCollisionShape class.
    3232*/
    3333
    34 #include "ConeCollisionShape.h"
    35 
    36 #include <BulletCollision/CollisionShapes/btConeShape.h>
     34#include "AbstractRadiusHeightCollisionShape.h"
    3735
    3836#include "core/CoreIncludes.h"
     
    4240namespace orxonox
    4341{
    44     RegisterClass(ConeCollisionShape);
     42    RegisterAbstractClass(AbstractRadiusHeightCollisionShape).inheritsFrom(Class(CollisionShape));
    4543
    4644    /**
     
    4846        Constructor. Registers and initializes the object.
    4947    */
    50     ConeCollisionShape::ConeCollisionShape(Context* context) : CollisionShape(context)
     48    AbstractRadiusHeightCollisionShape::AbstractRadiusHeightCollisionShape(Context* context) : CollisionShape(context)
    5149    {
    52         RegisterObject(ConeCollisionShape);
     50        RegisterObject(AbstractRadiusHeightCollisionShape);
    5351
    5452        this->radius_ = 1.0f;
    5553        this->height_ = 1.0f;
    56         updateShape();
    5754
    5855        this->registerVariables();
    5956    }
    6057
    61     ConeCollisionShape::~ConeCollisionShape()
    62     {
    63         if (this->isInitialized())
    64             delete this->collisionShape_;
    65     }
    66 
    67     void ConeCollisionShape::registerVariables()
     58    void AbstractRadiusHeightCollisionShape::registerVariables()
    6859    {
    6960        registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
     
    7162    }
    7263
    73     void ConeCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     64    void AbstractRadiusHeightCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7465    {
    75         SUPER(ConeCollisionShape, XMLPort, xmlelement, mode);
     66        SUPER(AbstractRadiusHeightCollisionShape, XMLPort, xmlelement, mode);
    7667
    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);
    7970    }
    8071
    8172    /**
    8273    @brief
    83         Is called when the scale of the ConeCollisionShape has changed.
     74        Is called when the scale of the AbstractRadiusHeightCollisionShape has changed.
    8475    */
    85     void ConeCollisionShape::changedScale()
     76    void AbstractRadiusHeightCollisionShape::changedScale()
    8677    {
    8778        CollisionShape::changedScale();
     
    9283        if(!this->hasUniformScaling())
    9384        {
    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;
    9586            return;
    9687        }
     
    10091        this->updateShape();
    10192    }
    102 
    103     /**
    104     @brief
    105         Creates a new internal collision shape for the ConeCollisionShape.
    106     @return
    107         Returns a pointer to the newly created btConeShape.
    108     */
    109     btCollisionShape* ConeCollisionShape::createNewShape() const
    110     {
    111         return new btConeShape(this->radius_, this->height_);
    112     }
    11393}
Note: See TracChangeset for help on using the changeset viewer.