particles.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*************************************************************************/
  2. /* particles.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef PARTICLES_H
  31. #define PARTICLES_H
  32. #include "core/rid.h"
  33. #include "scene/3d/visual_instance.h"
  34. #include "scene/resources/material.h"
  35. /**
  36. @author Juan Linietsky <reduzio@gmail.com>
  37. */
  38. class Particles : public GeometryInstance {
  39. private:
  40. GDCLASS(Particles, GeometryInstance);
  41. public:
  42. enum DrawOrder {
  43. DRAW_ORDER_INDEX,
  44. DRAW_ORDER_LIFETIME,
  45. DRAW_ORDER_VIEW_DEPTH,
  46. };
  47. enum {
  48. MAX_DRAW_PASSES = 4
  49. };
  50. private:
  51. RID particles;
  52. bool one_shot;
  53. int amount;
  54. float lifetime;
  55. float pre_process_time;
  56. float explosiveness_ratio;
  57. float randomness_ratio;
  58. float speed_scale;
  59. AABB visibility_aabb;
  60. bool local_coords;
  61. int fixed_fps;
  62. bool fractional_delta;
  63. Ref<Material> process_material;
  64. DrawOrder draw_order;
  65. Vector<Ref<Mesh> > draw_passes;
  66. protected:
  67. static void _bind_methods();
  68. void _notification(int p_what);
  69. virtual void _validate_property(PropertyInfo &property) const;
  70. public:
  71. AABB get_aabb() const;
  72. PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
  73. void set_emitting(bool p_emitting);
  74. void set_amount(int p_amount);
  75. void set_lifetime(float p_lifetime);
  76. void set_one_shot(bool p_one_shot);
  77. void set_pre_process_time(float p_time);
  78. void set_explosiveness_ratio(float p_ratio);
  79. void set_randomness_ratio(float p_ratio);
  80. void set_visibility_aabb(const AABB &p_aabb);
  81. void set_use_local_coordinates(bool p_enable);
  82. void set_process_material(const Ref<Material> &p_material);
  83. void set_speed_scale(float p_scale);
  84. bool is_emitting() const;
  85. int get_amount() const;
  86. float get_lifetime() const;
  87. bool get_one_shot() const;
  88. float get_pre_process_time() const;
  89. float get_explosiveness_ratio() const;
  90. float get_randomness_ratio() const;
  91. AABB get_visibility_aabb() const;
  92. bool get_use_local_coordinates() const;
  93. Ref<Material> get_process_material() const;
  94. float get_speed_scale() const;
  95. void set_fixed_fps(int p_count);
  96. int get_fixed_fps() const;
  97. void set_fractional_delta(bool p_enable);
  98. bool get_fractional_delta() const;
  99. void set_draw_order(DrawOrder p_order);
  100. DrawOrder get_draw_order() const;
  101. void set_draw_passes(int p_count);
  102. int get_draw_passes() const;
  103. void set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh);
  104. Ref<Mesh> get_draw_pass_mesh(int p_pass) const;
  105. virtual String get_configuration_warning() const;
  106. void restart();
  107. AABB capture_aabb() const;
  108. Particles();
  109. ~Particles();
  110. };
  111. VARIANT_ENUM_CAST(Particles::DrawOrder)
  112. #endif // PARTICLES_H