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 |
|
---|
9 | #ifndef PARTICLE_EMITTER_HH
|
---|
10 | #define PARTICLE_EMITTER_HH
|
---|
11 |
|
---|
12 | #include "g1_object.hh"
|
---|
13 | #include "tex_id.hh"
|
---|
14 | #include "file/file.hh"
|
---|
15 |
|
---|
16 | struct g1_particle_emitter_params
|
---|
17 | {
|
---|
18 | r1_texture_handle texture;
|
---|
19 |
|
---|
20 | i4_float start_size;
|
---|
21 | i4_float start_size_random_range; // added to start size
|
---|
22 |
|
---|
23 | i4_float grow_speed;
|
---|
24 | i4_float grow_accel;
|
---|
25 | i4_3d_vector speed; // travel speed
|
---|
26 |
|
---|
27 | sw32 num_create_attempts_per_tick;
|
---|
28 | i4_float creation_probability; // 0..1 likelyhood each tick of creating a new particle
|
---|
29 | i4_float max_speed;
|
---|
30 | i4_float air_friction;
|
---|
31 | i4_float gravity;
|
---|
32 |
|
---|
33 | sw32 particle_lifetime; // ticks particles will be around (they also die if size<0)
|
---|
34 | sw32 emitter_lifetime; // ticks the emitter will be around
|
---|
35 |
|
---|
36 | void defaults();
|
---|
37 | };
|
---|
38 |
|
---|
39 | struct g1_particle_class
|
---|
40 | {
|
---|
41 | float x,y,z, lx,ly,lz;
|
---|
42 | float xv, yv, zv;
|
---|
43 | float grow_speed;
|
---|
44 | float size;
|
---|
45 | int ticks_left;
|
---|
46 | i4_bool in_use;
|
---|
47 |
|
---|
48 | void load(i4_file_class *fp);
|
---|
49 | void save(i4_file_class *fp);
|
---|
50 | };
|
---|
51 |
|
---|
52 | class g1_particle_emitter_class : public g1_object_class
|
---|
53 | {
|
---|
54 | g1_object_chain_class cell_on;
|
---|
55 | enum { DATA_VERSION=0xabce };
|
---|
56 | public:
|
---|
57 | float x1,y1, x2,y2; // ground plane bounds for occupy location
|
---|
58 | float radius;
|
---|
59 | i4_bool stopping;
|
---|
60 |
|
---|
61 | enum { MAX_PARTICLES=40 };
|
---|
62 | g1_particle_class particles[MAX_PARTICLES];
|
---|
63 | g1_particle_emitter_params params;
|
---|
64 |
|
---|
65 | int t_in_use;
|
---|
66 |
|
---|
67 | g1_particle_emitter_class(g1_object_type id, g1_loader_class *fp);
|
---|
68 | virtual void save(g1_saver_class *fp);
|
---|
69 |
|
---|
70 |
|
---|
71 | virtual i4_float occupancy_radius() const { return radius; }
|
---|
72 |
|
---|
73 | void occupy_bounds();
|
---|
74 |
|
---|
75 | void setup(float x, float y, float h, g1_particle_emitter_params ¶ms);
|
---|
76 | virtual void draw(g1_draw_context_class *context);
|
---|
77 | virtual void think();
|
---|
78 |
|
---|
79 | void stop() { stopping=i4_T; }
|
---|
80 | void move(float new_x, float new_y, float new_h);
|
---|
81 | i4_bool occupy_location();
|
---|
82 | void unoccupy_location();
|
---|
83 | };
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 | #endif
|
---|