25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

81 lines
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 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. void SetShapeToBox(lol::vec3& box_size);
  32. void SetShapeToSphere(float radius);
  33. void SetShapeToCone(float radius, float height);
  34. void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f)));
  35. void SetMass(float mass);
  36. void InitBodyToRigid();
  37. void AddToSimulation(class Simulation* current_simulation);
  38. mat4 GetTransform();
  39. protected:
  40. void SetLocalInertia(float mass);
  41. void SetShapeTo(btCollisionShape* collision_shape);
  42. btCollisionObject* m_collision_object;
  43. btRigidBody* m_rigid_body;
  44. btScalar m_mass;
  45. btVector3 m_local_inertia;
  46. btCollisionShape* m_collision_shape;
  47. btMotionState* m_motion_state;
  48. lol::mat4 m_local_to_world;
  49. #else
  50. public:
  51. EasyPhysics() { }
  52. void SetShapeToBox(lol::vec3& BoxSize) { }
  53. void SetShapeToSphere(float radius) { }
  54. void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { }
  55. void SetMass(float mass) { }
  56. void InitBodyToRigid() { }
  57. void AddToSimulation(class Simulation* current_simulation) { }
  58. mat4 GetTransform() { return mat4(1.0f); }
  59. #endif
  60. };
  61. } /* namespace phys */
  62. } /* namespace lol */
  63. #endif /* __EASYPHYSICS_EASYPHYSICS_H__ */