PhysicsGhostObject.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef PHYSICSGHOSTOBJECT_H_
  2. #define PHYSICSGHOSTOBJECT_H_
  3. #include "PhysicsCollisionObject.h"
  4. #include "PhysicsRigidBody.h"
  5. #include "Transform.h"
  6. namespace gameplay
  7. {
  8. class PhysicsMotionState;
  9. /**
  10. * Defines a class for physics ghost objects.
  11. */
  12. class PhysicsGhostObject : public PhysicsCollisionObject, public Transform::Listener
  13. {
  14. friend class Node;
  15. friend class PhysicsController;
  16. public:
  17. /**
  18. * @see PhysicsCollisionObject#getType
  19. */
  20. PhysicsCollisionObject::Type getType() const;
  21. /**
  22. * Used to synchronize the transform between GamePlay and Bullet.
  23. */
  24. void transformChanged(Transform* transform, long cookie);
  25. protected:
  26. /**
  27. * @see PhysicsCollisionObject::getCollisionObject
  28. */
  29. btCollisionObject* getCollisionObject() const;
  30. protected:
  31. /**
  32. * Constructor.
  33. *
  34. * @param node The node to attach the ghost object to.
  35. * @param shape The collision shape definition for the ghost object.
  36. */
  37. PhysicsGhostObject(Node* node, const PhysicsCollisionShape::Definition& shape);
  38. /**
  39. * Destructor.
  40. */
  41. virtual ~PhysicsGhostObject();
  42. /**
  43. * Creates a ghost object from the specified properties object.
  44. *
  45. * @param node The node to create a ghost object for; note that the node must have
  46. * a model attached to it prior to creating a ghost object for it.
  47. * @param properties The properties object defining the ghost object (must have namespace equal to 'ghost').
  48. * @return The newly created ghost object, or <code>NULL</code> if the ghost object failed to load.
  49. */
  50. static PhysicsGhostObject* create(Node* node, Properties* properties);
  51. btPairCachingGhostObject* _ghostObject;
  52. };
  53. }
  54. #endif