Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 1, 2008, 11:09:43 PM (15 years ago)
Author:
rgrieder
Message:
  • Added support for attaching physical WorldEntities to each other. Currently you can only add static objects to kinematic/dynamic/static other objects. Future plans involve attaching kinematic objects to static/kinematic ones. All other combinations don't make sense at all.
  • Added CollisionShape, SphereCollisionShape and CompoundCollisionShape

Usage for collision shapes (example):

<LinearEntity collisionType="kinematic">

<attached>

<Model position="0,0,0" scale=10 mesh="ast1.mesh" />
<StaticEntity position="0,10,0" collisionType="static"> # Everything else than "static" fails!

<collisionShapes>

<SphereCollisionShape radius=40 position="10,10,-10"/>
<CompoundCollisionShape position="4,4,4"> # You can also make compound shapes directly

<SphereCollisionShape radius=10/>

</CompoundCollisionShape>

</collisionShapes>

</StaticEntity>

</attached>

</LinearEntity>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h

    r2300 r2303  
    3636
    3737#include "LinearMath/btMotionState.h"
    38 #include "BulletDynamics/Dynamics/btRigidBody.h"
    3938
    4039#include "network/Synchronisable.h"
     
    108107                { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); }
    109108
    110             inline void setScale3D(const Vector3& scale)
    111                 { this->node_->setScale(scale); }
     109            void setScale3D(const Vector3& scale);
    112110            inline void setScale3D(float x, float y, float z)
    113                 { this->node_->setScale(x, y, z); }
     111                { this->setScale3D(Vector3(x, y, z)); }
    114112            inline const Vector3& getScale3D(void) const
    115113                { return this->node_->getScale(); }
    116114
    117             inline void setScale(float scale)
    118                 { this->node_->setScale(scale, scale, scale); }
     115            void setScale(float scale)
     116                { this->setScale3D(scale, scale, scale); }
    119117            inline float getScale() const
    120118                { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
    121119
    122             inline void scale3D(const Vector3& scale)
    123                 { this->node_->scale(scale); }
     120            void scale3D(const Vector3& scale);
    124121            inline void scale3D(float x, float y, float z)
    125                 { this->node_->scale(x, y, z); }
     122                { this->scale3D(Vector3(x, y, z)); }
    126123            inline void scale(float scale)
    127                 { this->node_->scale(scale, scale, scale); }
     124                { this->scale3D(scale, scale, scale); }
    128125
    129126            void attach(WorldEntity* object);
     127//            void attachAsdf(BlinkingBillboard* object);
    130128            void detach(WorldEntity* object);
    131129            WorldEntity* getAttachedObject(unsigned int index) const;
     130//            BlinkingBillboard* getAttachedAsdfObject(unsigned int index) const;
    132131            inline const std::set<WorldEntity*>& getAttachedObjects() const
    133132                { return this->children_; }
     
    195194
    196195            void setMass(float mass);
    197             float getMass() const;
    198 
    199             void setCollisionRadius(float radius);
    200             float getCollisionRadius() const;
     196            inline float getMass() const
     197                { return this->mass_; }
     198
     199            void attachCollisionShape(CollisionShape* shape);
     200            CollisionShape* getAttachedCollisionShape(unsigned int index) const;
     201
     202            CollisionShape* getCollisionShape() { return this->collisionShape_; }
     203            btRigidBody* getPhysicalBody() { return this->physicalBody_; }
    201204
    202205        protected:
     
    211214
    212215        private:
    213             CollisionType collisionType_;
    214 
     216            void mergeCollisionShape(CollisionShape* shape);
     217
     218            CollisionType                collisionType_;
     219            std::vector<CollisionShape*> attachedShapes_;
     220            CollisionShape*              collisionShape_;
     221            btScalar                     mass_;
    215222    };
    216223}
Note: See TracChangeset for help on using the changeset viewer.