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 edited

Legend:

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

    r9667 r10189  
    3737
    3838#include "core/CoreIncludes.h"
    39 #include "core/XMLPort.h"
    4039#include "tools/BulletConversions.h"
    4140
     
    4847        Constructor. Registers and initializes the object.
    4948    */
    50     ConeCollisionShape::ConeCollisionShape(Context* context) : CollisionShape(context)
     49    ConeCollisionShape::ConeCollisionShape(Context* context) : AbstractRadiusHeightCollisionShape(context)
    5150    {
    5251        RegisterObject(ConeCollisionShape);
    5352
    54         this->radius_ = 1.0f;
    55         this->height_ = 1.0f;
    5653        updateShape();
    57 
    58         this->registerVariables();
    5954    }
    6055
     
    6358        if (this->isInitialized())
    6459            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     @brief
    83         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 shape
    90         // 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();
    10160    }
    10261
     
    10968    btCollisionShape* ConeCollisionShape::createNewShape() const
    11069    {
    111         return new btConeShape(this->radius_, this->height_);
     70        return new btConeShape(this->getRadius(), this->getHeight());
    11271    }
    11372}
Note: See TracChangeset for help on using the changeset viewer.