Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 1:38:17 PM (15 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/CollisionShape.cc

    r2306 r2374  
    3737#include "tools/BulletConversions.h"
    3838
     39#include "CompoundCollisionShape.h"
     40
    3941namespace orxonox
    4042{
    4143    CreateFactory(CollisionShape);
    4244
    43     CollisionShape::CollisionShape(BaseObject* creator) : StaticEntity(creator)
     45    CollisionShape::CollisionShape(BaseObject* creator)
     46        : BaseObject(creator)
     47        , network::Synchronisable(creator)
    4448    {
    4549        RegisterObject(CollisionShape);
    4650
    47         this->bIsCompound_ = false;
     51        this->parent_ = 0;
     52        this->parentID_ = (unsigned int)-1;
     53        this->collisionShape_ = 0;
    4854    }
    4955
     
    5561    {
    5662        SUPER(CollisionShape, XMLPort, xmlelement, mode);
     63
     64        XMLPortParamTemplate(CollisionShape, "position", setPosition, getPosition, xmlelement, mode, const Vector3&);
     65        XMLPortParamTemplate(CollisionShape, "orientation", setOrientation, getOrientation, xmlelement, mode, const Quaternion&);
     66        XMLPortParamLoadOnly(CollisionShape, "yaw",   yaw,   xmlelement, mode);
     67        XMLPortParamLoadOnly(CollisionShape, "pitch", pitch, xmlelement, mode);
     68        XMLPortParamLoadOnly(CollisionShape, "roll",  roll,  xmlelement, mode);
     69        XMLPortParamTemplate(CollisionShape, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&);
     70        XMLPortParamLoadOnly(CollisionShape, "scale", setScale, xmlelement, mode);
    5771    }
    5872
    59     bool CollisionShape::isCollisionTypeLegal(WorldEntity::CollisionType type) const
     73    void CollisionShape::registerVariables()
    6074    {
    61         if (type != WorldEntity::None)
    62         {
    63             ThrowException(PhysicsViolation, "A CollisionShape can only have CollisionType 'None'.");
    64             return false;
    65         }
    66         else
    67             return true;
     75        REGISTERDATA(this->parentID_, network::direction::toclient, new network::NetworkCallback<CollisionShape>(this, &CollisionShape::updateParent));
    6876    }
    6977
    70     bool CollisionShape::hasNoTransform() const
     78    void CollisionShape::updateParent()
    7179    {
    72         return (this->getPosition().positionEquals(Vector3(0, 0, 0), 0.001) &&
    73                 this->getOrientation().equals(Quaternion(1,0,0,0), Degree(0.1)));
     80        CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_));
     81        if (parent)
     82            parent->addChildShape(this);
    7483    }
    7584
    76     btVector3 CollisionShape::getTotalScaling()
     85    bool CollisionShape::hasTransform() const
    7786    {
    78         return omni_cast<btVector3>(this->node_->getScale());
     87        return (!this->position_.positionEquals(Vector3(0, 0, 0), 0.001) ||
     88                !this->orientation_.equals(Quaternion(1,0,0,0), Degree(0.1)));
    7989    }
    8090
     
    8494    }
    8595
    86     void CollisionShape::scale3D(const Vector3& scale)
     96    void CollisionShape::setScale(float scale)
    8797    {
    8898        ThrowException(NotImplemented, "Cannot set the scale of a collision shape: Not yet implemented.");
Note: See TracChangeset for help on using the changeset viewer.