BsPhysicsMaterial.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsResource.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup Physics
  9. * @{
  10. */
  11. /** Physics material that controls how objects react when they collide. */
  12. class BS_CORE_EXPORT PhysicsMaterial : public Resource
  13. {
  14. public:
  15. virtual ~PhysicsMaterial() { }
  16. /**
  17. * Sets static friction of the material. Controls friction when two in-contact objects are not moving lateral to
  18. * each other (for example how difficult is to get an object moving from a static state while it is in contact
  19. * other object(s)).
  20. */
  21. virtual void setStaticFriction(float value) = 0;
  22. /** Gets static friction of the material. */
  23. virtual float getStaticFriction() const = 0;
  24. /**
  25. * Sets dynamic friction of the material. Controls friction when two in-contact objects are moving lateral to each
  26. * other (for example how quickly does an object slow down when sliding along another object).
  27. */
  28. virtual void setDynamicFriction(float value) = 0;
  29. /** Gets dynamic friction of the material .*/
  30. virtual float getDynamicFriction() const = 0;
  31. /**
  32. * Sets restitution coefficient of the material. Controls "bounciness" of an object during a collision. Value of 1
  33. * means the collision is elastic, and value of 0 means the value is inelastic. Must be in [0, 1] range.
  34. */
  35. virtual void setRestitutionCoefficient(float value) = 0;
  36. /** Gets restitution coefficient of the material. */
  37. virtual float getRestitutionCoefficient() const = 0;
  38. /**
  39. * Creates a new physics material.
  40. *
  41. * @param[in] staticFriction Controls friction when two in-contact objects are not moving lateral to each other
  42. * (for example how difficult is to get an object moving from a static state while it
  43. * is in contact other object(s)).
  44. * @param[in] dynamicFriction Sets dynamic friction of the material. Controls friction when two in-contact objects
  45. * are moving lateral to each other (for example how quickly does an object slow down
  46. * when sliding along another object).
  47. * @param[in] restitution Controls "bounciness" of an object during a collision. Value of 1 means the
  48. * collision is elastic, and value of 0 means the value is inelastic. Must be in
  49. * [0, 1] range.
  50. */
  51. static HPhysicsMaterial create(float staticFriction = 0.0f, float dynamicFriction = 0.0f, float restitution = 0.0f);
  52. /** @name Internal
  53. * @{
  54. */
  55. /**
  56. * @copydoc create()
  57. *
  58. * For internal use. Requires manual initialization after creation.
  59. */
  60. static SPtr<PhysicsMaterial> _createPtr(float staticFriction = 0.0f, float dynamicFriction = 0.0f,
  61. float restitution = 0.0f);
  62. /** @} */
  63. /************************************************************************/
  64. /* SERIALIZATION */
  65. /************************************************************************/
  66. public:
  67. friend class PhysicsMaterialRTTI;
  68. static RTTITypeBase* getRTTIStatic();
  69. RTTITypeBase* getRTTI() const override;
  70. };
  71. /** @} */
  72. }