Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

89 řádky
2.3 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 EasyPhysics class
  13. // ------------------
  14. //
  15. #if !defined __EASYPHYSICS_EASYPHYSICS_H__
  16. #define __EASYPHYSICS_EASYPHYSICS_H__
  17. #ifdef HAVE_PHYS_USE_BULLET
  18. #include "core.h"
  19. #include <bullet/btBulletDynamicsCommon.h>
  20. #include <bullet/btBulletCollisionCommon.h>
  21. #endif
  22. namespace lol
  23. {
  24. namespace phys
  25. {
  26. class EasyPhysics
  27. {
  28. #ifdef HAVE_PHYS_USE_BULLET
  29. public:
  30. EasyPhysics();
  31. ~EasyPhysics();
  32. void SetShapeToBox(lol::vec3& box_size);
  33. void SetShapeToSphere(float radius);
  34. void SetShapeToCone(float radius, float height);
  35. void SetShapeToCylinder(lol::vec3& cyl_size);
  36. void SetShapeToCapsule(float radius, float height);
  37. void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f)));
  38. void SetMass(float mass);
  39. void InitBodyToRigid();
  40. void AddToSimulation(class Simulation* current_simulation);
  41. mat4 GetTransform();
  42. protected:
  43. void SetLocalInertia(float mass);
  44. void SetShapeTo(btCollisionShape* collision_shape);
  45. btCollisionObject* m_collision_object;
  46. btRigidBody* m_rigid_body;
  47. btScalar m_mass;
  48. btVector3 m_local_inertia;
  49. btCollisionShape* m_collision_shape;
  50. btMotionState* m_motion_state;
  51. lol::mat4 m_local_to_world;
  52. #else
  53. public:
  54. EasyPhysics() { }
  55. void SetShapeToBox(lol::vec3& BoxSize) { }
  56. void SetShapeToSphere(float radius) { }
  57. void SetShapeToCone(float radius, float height) { }
  58. void SetShapeToCylinder(lol::vec3& cyl_size) { }
  59. void SetShapeToCapsule(float radius, float height) { }
  60. void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { }
  61. void SetMass(float mass) { }
  62. void InitBodyToRigid() { }
  63. void AddToSimulation(class Simulation* current_simulation) { }
  64. mat4 GetTransform() { return mat4(1.0f); }
  65. #endif
  66. };
  67. } /* namespace phys */
  68. } /* namespace lol */
  69. #endif /* __EASYPHYSICS_EASYPHYSICS_H__ */