BsPhysicsMaterial.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 bs
  7. {
  8. /** @addtogroup Physics
  9. * @{
  10. */
  11. /**
  12. * Material that controls how two physical objects interact with each other. Materials of both objects are used during
  13. * their interaction and their combined values are used.
  14. */
  15. class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Physics) PhysicsMaterial : public Resource
  16. {
  17. public:
  18. virtual ~PhysicsMaterial() { }
  19. /**
  20. * Controls friction when two in-contact objects are not moving lateral to each other (for example how difficult
  21. * it is to get an object moving from a static state while it is in contact with other object(s)).
  22. */
  23. BS_SCRIPT_EXPORT(n:StaticFriction,pr:setter)
  24. virtual void setStaticFriction(float value) = 0;
  25. /** @copydoc setStaticFriction() */
  26. BS_SCRIPT_EXPORT(n:StaticFriction,pr:getter)
  27. virtual float getStaticFriction() const = 0;
  28. /**
  29. * Controls friction when two in-contact objects are moving lateral to each other (for example how quickly does an
  30. * object slow down when sliding along another object).
  31. */
  32. BS_SCRIPT_EXPORT(n:DynamicFriction,pr:setter)
  33. virtual void setDynamicFriction(float value) = 0;
  34. /** @copydoc setDynamicFriction() */
  35. BS_SCRIPT_EXPORT(n:DynamicFriction,pr:getter)
  36. virtual float getDynamicFriction() const = 0;
  37. /**
  38. * Controls "bounciness" of an object during a collision. Value of 1 means the collision is elastic, and value of 0
  39. * means the value is inelastic. Must be in [0, 1] range.
  40. */
  41. BS_SCRIPT_EXPORT(n:Restitution,pr:setter)
  42. virtual void setRestitutionCoefficient(float value) = 0;
  43. /** @copydoc setRestitutionCoefficient() */
  44. BS_SCRIPT_EXPORT(n:Restitution,pr:getter)
  45. virtual float getRestitutionCoefficient() const = 0;
  46. /**
  47. * Creates a new physics material.
  48. *
  49. * @param[in] staticFriction Controls friction when two in-contact objects are not moving lateral to each other
  50. * (for example how difficult is to get an object moving from a static state while it
  51. * is in contact other object(s)).
  52. * @param[in] dynamicFriction Sets dynamic friction of the material. Controls friction when two in-contact objects
  53. * are moving lateral to each other (for example how quickly does an object slow down
  54. * when sliding along another object).
  55. * @param[in] restitution Controls "bounciness" of an object during a collision. Value of 1 means the
  56. * collision is elastic, and value of 0 means the value is inelastic. Must be in
  57. * [0, 1] range.
  58. */
  59. BS_SCRIPT_EXPORT(ec:PhysicsMaterial)
  60. static HPhysicsMaterial create(float staticFriction = 0.0f, float dynamicFriction = 0.0f, float restitution = 0.0f);
  61. /** @name Internal
  62. * @{
  63. */
  64. /**
  65. * @copydoc create()
  66. *
  67. * For internal use. Requires manual initialization after creation.
  68. */
  69. static SPtr<PhysicsMaterial> _createPtr(float staticFriction = 0.0f, float dynamicFriction = 0.0f,
  70. float restitution = 0.0f);
  71. /** @} */
  72. /************************************************************************/
  73. /* SERIALIZATION */
  74. /************************************************************************/
  75. public:
  76. friend class PhysicsMaterialRTTI;
  77. static RTTITypeBase* getRTTIStatic();
  78. RTTITypeBase* getRTTI() const override;
  79. };
  80. /** @} */
  81. }