particles_2d.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*************************************************************************/
  2. /* particles_2d.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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_FRAME_H
  31. #define PARTICLES_FRAME_H
  32. #include "scene/2d/node_2d.h"
  33. #include "scene/resources/color_ramp.h"
  34. #include "scene/resources/texture.h"
  35. class Particles2D : public Node2D {
  36. private:
  37. GDCLASS(Particles2D, Node2D)
  38. public:
  39. enum DrawOrder {
  40. DRAW_ORDER_INDEX,
  41. DRAW_ORDER_LIFETIME,
  42. };
  43. private:
  44. RID particles;
  45. bool emitting;
  46. bool one_shot;
  47. int amount;
  48. float lifetime;
  49. float pre_process_time;
  50. float explosiveness_ratio;
  51. float randomness_ratio;
  52. float speed_scale;
  53. Rect2 visibility_rect;
  54. bool local_coords;
  55. int fixed_fps;
  56. bool fractional_delta;
  57. int v_frames;
  58. int h_frames;
  59. Ref<Material> process_material;
  60. DrawOrder draw_order;
  61. Ref<Texture> texture;
  62. Ref<Texture> normal_map;
  63. void _update_particle_emission_transform();
  64. protected:
  65. static void _bind_methods();
  66. virtual void _validate_property(PropertyInfo &property) const;
  67. void _notification(int p_what);
  68. public:
  69. void set_emitting(bool p_emitting);
  70. void set_amount(int p_amount);
  71. void set_lifetime(float p_lifetime);
  72. void set_one_shot(bool p_enable);
  73. void set_pre_process_time(float p_time);
  74. void set_explosiveness_ratio(float p_ratio);
  75. void set_randomness_ratio(float p_ratio);
  76. void set_visibility_rect(const Rect2 &p_aabb);
  77. void set_use_local_coordinates(bool p_enable);
  78. void set_process_material(const Ref<Material> &p_material);
  79. void set_speed_scale(float p_scale);
  80. bool is_emitting() const;
  81. int get_amount() const;
  82. float get_lifetime() const;
  83. bool get_one_shot() const;
  84. float get_pre_process_time() const;
  85. float get_explosiveness_ratio() const;
  86. float get_randomness_ratio() const;
  87. Rect2 get_visibility_rect() const;
  88. bool get_use_local_coordinates() const;
  89. Ref<Material> get_process_material() const;
  90. float get_speed_scale() const;
  91. void set_fixed_fps(int p_count);
  92. int get_fixed_fps() const;
  93. void set_fractional_delta(bool p_enable);
  94. bool get_fractional_delta() const;
  95. void set_draw_order(DrawOrder p_order);
  96. DrawOrder get_draw_order() const;
  97. void set_texture(const Ref<Texture> &p_texture);
  98. Ref<Texture> get_texture() const;
  99. void set_normal_map(const Ref<Texture> &p_normal_map);
  100. Ref<Texture> get_normal_map() const;
  101. virtual String get_configuration_warning() const;
  102. void set_v_frames(int p_count);
  103. int get_v_frames() const;
  104. void set_h_frames(int p_count);
  105. int get_h_frames() const;
  106. void restart();
  107. Rect2 capture_rect() const;
  108. Particles2D();
  109. ~Particles2D();
  110. };
  111. VARIANT_ENUM_CAST(Particles2D::DrawOrder)
  112. #endif // PARTICLES_FRAME_H