]> icculus.org git repositories - taylor/freespace2.git/blob - include/particle.h
Initial revision
[taylor/freespace2.git] / include / particle.h
1 /*
2  * $Logfile: /Freespace2/code/Particle/Particle.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Includes for particle system
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:12  root
11  * Initial revision
12  *
13  * 
14  * 7     7/21/99 8:10p Dave
15  * First run of supernova effect.
16  * 
17  * 6     1/29/99 12:47a Dave
18  * Put in sounds for beam weapon. A bunch of interface screens (tech
19  * database stuff).
20  * 
21  * 5     1/27/99 9:56a Dave
22  * Temporary checkin of beam weapons for Dan to make cool sounds.
23  * 
24  * 4     1/24/99 11:37p Dave
25  * First full rev of beam weapons. Very customizable. Removed some bogus
26  * Int3()'s in low level net code.
27  * 
28  * 3     1/21/99 2:06p Dave
29  * Final checkin for multiplayer testing.
30  * 
31  * 2     10/07/98 10:53a Dave
32  * Initial checkin.
33  * 
34  * 1     10/07/98 10:50a Dave
35  * 
36  * 6     5/13/98 3:25p John
37  * Added code to make explosion impacts not get removed by other
38  * particles.
39  * 
40  * 5     5/11/98 10:06a John
41  * Added new particle for Adam
42  * 
43  * 4     4/30/98 11:31a Andsager
44  * Added particles to big ship explosions.  Modified particle_emit() to
45  * take optional range to increase range at which pariticles are created.
46  * 
47  * 3     1/29/98 11:48a John
48  * Added new counter measure rendering as model code.   Made weapons be
49  * able to have impact explosion.
50  * 
51  * 2     1/02/98 5:04p John
52  * Several explosion related changes.  Made fireballs not be used as
53  * ani's.  Made ship spark system expell particles.  Took away impact
54  * explosion for weapon hitting ship... this needs to get added to weapon
55  * info and makes shield hit more obvious.  Only make sparks when hit
56  * hull, not shields.
57  * 
58  * 1     12/23/97 8:26a John
59  *
60  * $NoKeywords: $
61  */
62
63 #ifndef _PARTICLE_H
64 #define _PARTICLE_H
65
66 //============================================================================
67 //==================== PARTICLE SYSTEM GAME SEQUENCING CODE ==================
68 //============================================================================
69
70 // Resets particle system.  Call between levels.
71 void particle_init();
72
73 // Moves the particles for each frame
74 void particle_move_all(float frametime);
75
76 // Renders all the particles
77 void particle_render_all();
78
79 // kill all active particles
80 void particle_kill_all();
81
82
83 //============================================================================
84 //=============== LOW-LEVEL SINGLE PARTICLE CREATION CODE ====================
85 //============================================================================
86
87 // The different types of particles...
88 #define PARTICLE_DEBUG          0                       // A red sphere, no optional data required
89 #define PARTICLE_BITMAP         1                       // A bitmap, optional data is the bitmap number.  If bitmap is an animation,
90                                                                                                 // lifetime is calculated by the number of frames and fps.
91 #define PARTICLE_FIRE           2                       // The vclip used for explosions, optional means nothing
92 #define PARTICLE_SMOKE          3                       // The vclip used for smoke, optional means nothing
93 #define PARTICLE_SMOKE2         4                       // The vclip used for smoke, optional means nothing
94 #define PARTICLE_BITMAP_PERSISTENT              5               // A bitmap, optional data is the bitmap number.  If bitmap is an animation,
95                                                                                                                         // lifetime is calculated by the number of frames and fps.
96
97 // particle creation stuff
98 typedef struct particle_info {
99         // old-style particle info
100         vector pos;
101         vector vel;
102         float lifetime;
103         float rad;
104         int type;
105         uint optional_data;     
106
107         // new-style particle info
108         float tracer_length;
109         short attached_objnum;                  // if these are set, the pos is relative to the pos of the origin of the attached object
110         int     attached_sig;                           // to make sure the object hasn't changed or died. velocity is ignored in this case
111         ubyte   reverse;                                                // play any animations in reverse
112 } particle_info;
113
114 // Creates a single particle. See the PARTICLE_?? defines for types.
115 void particle_create( particle_info *pinfo );
116 void particle_create( vector *pos, vector *vel, float lifetime, float rad, int type, uint optional_data = 0 );
117
118
119 //============================================================================
120 //============== HIGH-LEVEL PARTICLE SYSTEM CREATION CODE ====================
121 //============================================================================
122
123 // Use a structure rather than pass a ton of parameters to particle_emit
124 typedef struct particle_emitter {
125         int             num_low;                                // Lowest number of particles to create
126         int             num_high;                       // Highest number of particles to create
127         vector  pos;                                    // Where the particles emit from
128         vector  vel;                                    // Initial velocity of all the particles
129         float           min_life;                       // How long the particles live
130         float           max_life;                       // How long the particles live
131         vector  normal;                         // What normal the particle emit arond
132         float           normal_variance;        //      How close they stick to that normal 0=good, 1=360 degree
133         float           min_vel;                                // How fast the slowest particle can move
134         float           max_vel;                                // How fast the fastest particle can move
135         float           min_rad;                                // Min radius
136         float           max_rad;                                // Max radius
137 } particle_emitter;
138
139 // Creates a bunch of particles. You pass a structure
140 // rather than a bunch of parameters.
141 void particle_emit( particle_emitter *pe, int type, uint optional_data, float range=1.0 );
142
143 #endif // _PARTICLE_H
144