83 行
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 "core.h"
  19. #include "EasyPhysics.h"
  20. #include <BulletDynamics/Character/btKinematicCharacterController.h>
  21. #endif
  22. namespace lol
  23. {
  24. namespace phys
  25. {
  26. class EasyCharacterController : public EasyPhysic
  27. {
  28. #ifdef HAVE_PHYS_USE_BULLET
  29. public:
  30. EasyCharacterController() :
  31. EasyPhysic(),
  32. m_character(NULL)
  33. {
  34. m_up_axis = 1;
  35. }
  36. ~EasyCharacterController()
  37. {
  38. delete m_character;
  39. }
  40. virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false);
  41. virtual void InitBodyToGhost();
  42. virtual void AddToSimulation(class Simulation* current_simulation);
  43. virtual void RemoveFromSimulation(class Simulation* current_simulation);
  44. virtual void SetMovementForFrame(vec3 const &MoveQuantity);
  45. protected:
  46. virtual btGhostObject* GetGhostObject();
  47. btPairCachingGhostObject* m_pair_caching_object;
  48. btKinematicCharacterController* m_character;
  49. float m_step_height;
  50. int m_up_axis;
  51. #else // NO PHYSIC IMPLEMENTATION
  52. virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false) { }
  53. virtual void InitBodyToGhost() { }
  54. virtual void AddToSimulation(class Simulation* current_simulation) { }
  55. virtual void RemoveFromSimulation(class Simulation* current_simulation) { }
  56. virtual void SetMovementForFrame(vec3 const &MoveQuantity) { }
  57. #endif // PHYSIC IMPLEMENTATION
  58. };
  59. } /* namespace phys */
  60. } /* namespace lol */
  61. #endif /* __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ */