2
0

particle_system.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. */
  5. #ifndef PARTICLE_SYSTEM_H_HEADER_GUARD
  6. #define PARTICLE_SYSTEM_H_HEADER_GUARD
  7. #include <bx/allocator.h>
  8. #include <bx/easing.h>
  9. #include <bx/rng.h>
  10. #include "../bounds.h"
  11. struct EmitterShape
  12. {
  13. enum Enum
  14. {
  15. Sphere,
  16. Hemisphere,
  17. Circle,
  18. Disc,
  19. Rect,
  20. Count
  21. };
  22. };
  23. struct EmitterDirection
  24. {
  25. enum Enum
  26. {
  27. Up,
  28. Outward,
  29. Count
  30. };
  31. };
  32. struct EmitterUniforms
  33. {
  34. void reset();
  35. float m_position[3];
  36. float m_angle[3];
  37. float m_blendStart[2];
  38. float m_blendEnd[2];
  39. float m_offsetStart[2];
  40. float m_offsetEnd[2];
  41. float m_scaleStart[2];
  42. float m_scaleEnd[2];
  43. float m_lifeSpan[2];
  44. float m_gravityScale;
  45. uint32_t m_rgba[5];
  46. uint32_t m_particlesPerSecond;
  47. bx::Easing::Enum m_easePos;
  48. bx::Easing::Enum m_easeRgba;
  49. bx::Easing::Enum m_easeBlend;
  50. bx::Easing::Enum m_easeScale;
  51. };
  52. struct EmitterHandle { uint16_t idx; };
  53. ///
  54. void psInit(uint16_t _maxEmitters = 64, bx::AllocatorI* _allocator = NULL);
  55. ///
  56. void psShutdown();
  57. ///
  58. EmitterHandle psCreateEmitter(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles);
  59. ///
  60. void psUpdateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms = NULL);
  61. ///
  62. void psGetAabb(EmitterHandle _handle, Aabb& _outAabb);
  63. ///
  64. void psDestroyEmitter(EmitterHandle _handle);
  65. ///
  66. void psUpdate(float _dt);
  67. ///
  68. void psRender(uint8_t _view, const float* _mtxView, const float* _eye);
  69. #endif // PARTICLE_SYSTEM_H_HEADER_GUARD