Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 1:38:17 PM (17 years ago)
Author:
rgrieder
Message:

Trying to synchronise phyiscs over the network.

  • Removed derivation of CollisionShape from WorldEntity (BaseObject instead).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/PlaneCollisionShape.cc

    r2323 r2374  
    2121 *
    2222 *   Author:
    23  *      Reto Grieder
     23 *      Martin Stypinski
    2424 *   Co-authors:
    2525 *      ...
     
    3030#include "PlaneCollisionShape.h"
    3131
    32 #include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
    33 
    34 #include "tools/BulletConversions.h"
    3532#include "core/CoreIncludes.h"
    3633#include "core/XMLPort.h"
     
    4542        RegisterObject(PlaneCollisionShape);
    4643
    47         this->planeShape_ = new btStaticPlaneShape(btVector3(1,1,1), 0);
     44        this->planeShape_ = new btStaticPlaneShape(btVector3(1, 1, 1), 0);
    4845        this->collisionShape_ = this->planeShape_;
     46        this->planeNormal_ = Vector3(1, 1, 1);
     47        this->planeOffset_ = 0.0f;
    4948    }
    5049
     
    5251    {
    5352        if (this->isInitialized())
    54             delete this->collisionShape_;
     53            delete this->planeShape_;
    5554    }
    5655
    57     void PlaneCollisionShape::setNormal(const Vector3& normal)
     56    void PlaneCollisionShape::registerVariables()
    5857    {
    59         btScalar offset = this->planeShape_->getPlaneConstant();
    60         delete this->collisionShape_;
    61         this->planeShape_ = new btStaticPlaneShape(omni_cast<btVector3>(normal), offset);
    62         this->collisionShape_ = this->planeShape_;
    63     }
    64 
    65     void PlaneCollisionShape::setOffset(float offset)
    66     {
    67         btVector3 normal = this->planeShape_->getPlaneNormal();
    68         delete this->collisionShape_;
    69         this->planeShape_ = new btStaticPlaneShape(normal, offset);
    70         this->collisionShape_ = this ->planeShape_;
     58        REGISTERDATA(this->planeNormal_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::planeNormalChanged));
     59        REGISTERDATA(this->planeOffset_, network::direction::toclient, new network::NetworkCallback<PlaneCollisionShape>(this, &PlaneCollisionShape::planeOffsetChanged));
    7160    }
    7261
     
    7564        SUPER(PlaneCollisionShape, XMLPort, xmlelement, mode);
    7665
    77         XMLPortParam(PlaneCollisionShape, "normal", setNormal, getNormal, xmlelement, mode);
    78         XMLPortParam(PlaneCollisionShape, "offset", setOffset, getOffset, xmlelement, mode);   
     66        XMLPortParam(PlaneCollisionShape, "planeNormal", setNormal, getNormal, xmlelement, mode);
     67        XMLPortParam(PlaneCollisionShape, "planeOffset", setOffset, getOffset, xmlelement, mode);   
    7968    }
    8069
    81     btVector3 PlaneCollisionShape::getTotalScaling()
     70    void PlaneCollisionShape::setNormal(const Vector3& normal)
    8271    {
    83         return omni_cast<btVector3>(this->node_->getScale()); //* this->radius_;
     72        delete this->planeShape_;
     73        this->planeNormal_ = normal;
     74        this->planeShape_ = new btStaticPlaneShape(omni_cast<btVector3>(normal), this->planeOffset_);
     75        this->collisionShape_ = this->planeShape_;
     76    }
     77
     78    void PlaneCollisionShape::setOffset(float offset)
     79    {
     80        delete this->planeShape_;
     81        this->planeOffset_ = offset;
     82        this->planeShape_ = new btStaticPlaneShape(omni_cast<btVector3>(this->planeNormal_), offset);
     83        this->collisionShape_ = this->planeShape_;
    8484    }
    8585}
Note: See TracChangeset for help on using the changeset viewer.