PhysicNode.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #pragma once
  23. #include "Shape.h"
  24. #include "Vec3.h"
  25. #include "Angles.h"
  26. namespace Crown
  27. {
  28. class PhysicNode
  29. {
  30. public:
  31. //! Constructor
  32. PhysicNode(const Vec3& position, const Angles& axis, bool visible, int collisionGroupId);
  33. //! Destructor
  34. virtual ~PhysicNode();
  35. //! Gets the velocity
  36. const Vec3& GetVelocity() const;
  37. //! Sets the velocity
  38. void SetVelocity(const Vec3 velocity);
  39. //! Gets the inverse mass
  40. real GetInverseMass() const;
  41. //! Sets the inverse mass
  42. void SetInverseMass(real inverseMass);
  43. //! Gets the shape
  44. Shape* GetShape() const;
  45. //! Sets the shape
  46. void SetShape(Shape* shape);
  47. //! Update that applies the velocity
  48. virtual void Update(real dt);
  49. //! Called when a collision occours
  50. virtual void Collision(PhysicNode* other);
  51. //! Returns the collision group id
  52. int GetCollisionGroupId() const;
  53. private:
  54. Vec3 mPosition;
  55. Vec3 mVelocity;
  56. real mInverseMass;
  57. Shape* mShape;
  58. int mCollisionGroupId;
  59. };
  60. }