particle_system_sw.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*************************************************************************/
  2. /* particle_system_sw.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef PARTICLE_SYSTEM_SW_H
  30. #define PARTICLE_SYSTEM_SW_H
  31. /**
  32. @author Juan Linietsky <reduzio@gmail.com>
  33. */
  34. #include "servers/visual_server.h"
  35. struct ParticleSystemSW {
  36. enum {
  37. MAX_PARTICLES=1024
  38. };
  39. float particle_vars[VS::PARTICLE_VAR_MAX];
  40. float particle_randomness[VS::PARTICLE_VAR_MAX];
  41. Vector3 emission_half_extents;
  42. DVector<Vector3> emission_points;
  43. Vector3 gravity_normal;
  44. Vector3 emission_base_velocity;
  45. int amount;
  46. bool emitting;
  47. bool height_from_velocity;
  48. AABB visibility_aabb;
  49. bool sort;
  50. bool local_coordinates;
  51. struct ColorPhase {
  52. float pos;
  53. Color color;
  54. ColorPhase() { pos=1.0; color=Color(0.0,0.0,1.0,1.0); }
  55. };
  56. int color_phase_count;
  57. ColorPhase color_phases[VS::MAX_PARTICLE_COLOR_PHASES];
  58. struct Attractor {
  59. Vector3 pos;
  60. float force;
  61. };
  62. int attractor_count;
  63. Attractor attractors[VS::MAX_PARTICLE_ATTRACTORS];
  64. ParticleSystemSW();
  65. ~ParticleSystemSW();
  66. };
  67. struct ParticleSystemProcessSW {
  68. enum {
  69. PARTICLE_RANDOM_NUMBERS = 8,
  70. };
  71. struct ParticleData {
  72. Vector3 pos;
  73. Vector3 vel;
  74. float rot;
  75. bool active;
  76. float random[PARTICLE_RANDOM_NUMBERS];
  77. ParticleData() { active=0; rot=0; }
  78. };
  79. bool valid;
  80. float particle_system_time;
  81. uint32_t rand_seed;
  82. Vector<ParticleData> particle_data;
  83. void process(const ParticleSystemSW *p_system,const Transform& p_transform,float p_time);
  84. ParticleSystemProcessSW();
  85. };
  86. struct ParticleSystemDrawInfoSW {
  87. struct ParticleDrawInfo {
  88. const ParticleSystemProcessSW::ParticleData *data;
  89. float d;
  90. Transform transform;
  91. Color color;
  92. };
  93. ParticleDrawInfo draw_info[ParticleSystemSW::MAX_PARTICLES];
  94. ParticleDrawInfo *draw_info_order[ParticleSystemSW::MAX_PARTICLES];
  95. void prepare(const ParticleSystemSW *p_system,const ParticleSystemProcessSW *p_process,const Transform& p_system_transform,const Transform& p_camera_transform);
  96. };
  97. #endif