82 line
2.0 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
  5. // (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
  6. // This program is free software; you can redistribute it and/or
  7. // modify it under the terms of the Do What The Fuck You Want To
  8. // Public License, Version 2, as published by Sam Hocevar. See
  9. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  10. //
  11. //
  12. // The EasyPhysic class
  13. // ------------------
  14. //
  15. #if !defined __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__
  16. #define __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__
  17. #ifdef HAVE_PHYS_USE_BULLET
  18. #include <BulletDynamics/Character/btKinematicCharacterController.h>
  19. #include "EasyPhysics.h"
  20. #endif
  21. namespace lol
  22. {
  23. namespace phys
  24. {
  25. class EasyCharacterController : public EasyPhysic
  26. {
  27. #ifdef HAVE_PHYS_USE_BULLET
  28. public:
  29. EasyCharacterController() :
  30. EasyPhysic(),
  31. m_character(NULL)
  32. {
  33. m_up_axis = 1;
  34. }
  35. ~EasyCharacterController()
  36. {
  37. delete m_character;
  38. }
  39. virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false);
  40. virtual void InitBodyToGhost();
  41. virtual void AddToSimulation(class Simulation* current_simulation);
  42. virtual void RemoveFromSimulation(class Simulation* current_simulation);
  43. virtual void SetMovementForFrame(vec3 const &MoveQuantity);
  44. protected:
  45. virtual btGhostObject* GetGhostObject();
  46. btPairCachingGhostObject* m_pair_caching_object;
  47. btKinematicCharacterController* m_character;
  48. float m_step_height;
  49. int m_up_axis;
  50. #else // NO PHYSIC IMPLEMENTATION
  51. virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false) { }
  52. virtual void InitBodyToGhost() { }
  53. virtual void AddToSimulation(class Simulation* current_simulation) { }
  54. virtual void RemoveFromSimulation(class Simulation* current_simulation) { }
  55. virtual void SetMovementForFrame(vec3 const &MoveQuantity) { }
  56. #endif // PHYSIC IMPLEMENTATION
  57. };
  58. } /* namespace phys */
  59. } /* namespace lol */
  60. #endif /* __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ */