Sirikata
libspace/plugins/physics/BulletObject.hpp
Go to the documentation of this file.
00001 // Copyright (c) 2011 Sirikata Authors. All rights reserved.
00002 // Use of this source code is governed by a BSD-style license that can
00003 // be found in the LICENSE file.
00004 
00005 #ifndef _SIRIKATA_BULLET_PHYSICS_OBJECT_HPP_
00006 #define _SIRIKATA_BULLET_PHYSICS_OBJECT_HPP_
00007 
00008 #include "Defs.hpp"
00009 
00010 class btCollisionShape;
00011 
00012 namespace Sirikata {
00013 
00018 class BulletObject {
00019 public:
00020     // Gets the collision mask for a given type of object
00021     static void getCollisionMask(bulletObjTreatment treatment, bulletObjCollisionMaskGroup* mygroup, bulletObjCollisionMaskGroup* collide_with);
00022 
00023     BulletObject(BulletPhysicsService* parent)
00024      : mParent(parent)
00025     {}
00026     virtual ~BulletObject() {}
00027 
00028     virtual bool fixed() = 0;
00029     virtual bulletObjTreatment treatment() = 0;
00030     virtual bulletObjBBox bbox() = 0;
00031     virtual float32 mass() = 0;
00032 
00037     virtual void load(Mesh::MeshdataPtr mesh) = 0;
00038 
00041     virtual void unload() = 0;
00042 
00045     virtual void preTick(const Time& t) {}
00046 
00049     virtual void postTick(const Time& t) {}
00050 
00054     virtual void internalTick(const Time& t) {}
00055 
00060     virtual void deactivationTick(const Time& t) {}
00061 
00062 
00063 
00069     virtual bool applyRequestedLocation(const TimedMotionVector3f& loc, uint64 epoch) = 0;
00075     virtual bool applyRequestedOrientation(const TimedMotionQuaternion& orient, uint64 epoch) = 0;
00076 
00083     virtual void applyForcedLocation(const TimedMotionVector3f& loc, uint64 epoch) = 0;
00090     virtual void applyForcedOrientation(const TimedMotionQuaternion& orient, uint64 epoch) = 0;
00091 
00092 protected:
00093 
00094     // Helper for computing the collision
00095     btCollisionShape* computeCollisionShape(const UUID& id, bulletObjBBox shape_type, bulletObjTreatment treatment, Mesh::MeshdataPtr retrievedMesh);
00096 
00097     BulletPhysicsService* mParent;
00098 }; // class BulletObject
00099 
00100 } // namespace Sirikata
00101 
00102 #endif //_SIRIKATA_BULLET_PHYSICS_OBJECT_HPP_