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