particle_emitter.hh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /********************************************************************** <BR>
  2. This file is part of Crack dot Com's free source code release of
  3. Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
  4. information about compiling & licensing issues visit this URL</a>
  5. <PRE> If that doesn't help, contact Jonathan Clark at
  6. golgotha_source@usa.net (Subject should have "GOLG" in it)
  7. ***********************************************************************/
  8. #ifndef PARTICLE_EMITTER_HH
  9. #define PARTICLE_EMITTER_HH
  10. #include "g1_object.hh"
  11. #include "tex_id.hh"
  12. #include "file/file.hh"
  13. struct g1_particle_emitter_params
  14. {
  15. r1_texture_handle texture;
  16. i4_float start_size;
  17. i4_float start_size_random_range; // added to start size
  18. i4_float grow_speed;
  19. i4_float grow_accel;
  20. i4_3d_vector speed; // travel speed
  21. sw32 num_create_attempts_per_tick;
  22. i4_float creation_probability; // 0..1 likelyhood each tick of creating a new particle
  23. i4_float max_speed;
  24. i4_float air_friction;
  25. i4_float gravity;
  26. sw32 particle_lifetime; // ticks particles will be around (they also die if size<0)
  27. sw32 emitter_lifetime; // ticks the emitter will be around
  28. void defaults();
  29. };
  30. struct g1_particle_class
  31. {
  32. float x,y,z, lx,ly,lz;
  33. float xv, yv, zv;
  34. float grow_speed;
  35. float size;
  36. int ticks_left;
  37. i4_bool in_use;
  38. void load(i4_file_class *fp);
  39. void save(i4_file_class *fp);
  40. };
  41. class g1_particle_emitter_class : public g1_object_class
  42. {
  43. g1_object_chain_class cell_on;
  44. enum { DATA_VERSION=0xabce };
  45. public:
  46. float x1,y1, x2,y2; // ground plane bounds for occupy location
  47. float radius;
  48. i4_bool stopping;
  49. enum { MAX_PARTICLES=40 };
  50. g1_particle_class particles[MAX_PARTICLES];
  51. g1_particle_emitter_params params;
  52. int t_in_use;
  53. g1_particle_emitter_class(g1_object_type id, g1_loader_class *fp);
  54. virtual void save(g1_saver_class *fp);
  55. virtual i4_float occupancy_radius() const { return radius; }
  56. void occupy_bounds();
  57. void setup(float x, float y, float h, g1_particle_emitter_params &params);
  58. virtual void draw(g1_draw_context_class *context);
  59. virtual void think();
  60. void stop() { stopping=i4_T; }
  61. void move(float new_x, float new_y, float new_h);
  62. i4_bool occupy_location();
  63. void unoccupy_location();
  64. };
  65. #endif