Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

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