2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #ifndef __DECLPARTICLE_H__
30 #define __DECLPARTICLE_H__
33 ===============================================================================
37 ===============================================================================
40 class idParticleParm {
42 idParticleParm( void ) { table = NULL; from = to = 0.0f; }
44 const idDeclTable * table;
48 float Eval( float frac, idRandom &rand ) const;
49 float Integrate( float frac, idRandom &rand ) const;
54 PDIST_RECT, // ( sizeX sizeY sizeZ )
55 PDIST_CYLINDER, // ( sizeX sizeY sizeZ )
56 PDIST_SPHERE // ( sizeX sizeY sizeZ ringFraction )
57 // a ringFraction of zero allows the entire sphere, 0.9 would only
58 // allow the outer 10% of the sphere
62 PDIR_CONE, // parm0 is the solid cone angle
63 PDIR_OUTWARD // direction is relative to offset from origin, parm0 is an upward bias
68 PPATH_HELIX, // ( sizeX sizeY sizeZ radialSpeed climbSpeed )
76 POR_AIMED, // angle and aspect are disregarded
82 typedef struct renderEntity_s renderEntity_t;
83 typedef struct renderView_s renderView_t;
86 const renderEntity_t * renderEnt; // for shaderParms, etc
87 const renderView_t * renderView;
88 int index; // particle number in the system
89 float frac; // 0.0 to 1.0
91 idVec3 origin; // dynamic smoke particles can have individual origins and axis
95 float age; // in seconds, calculated as fraction * stage->particleLife
96 idRandom originalRandom; // needed so aimed particles can reset the random for another origin calculation
97 float animationFrameFrac; // set by ParticleTexCoords, used to make the cross faded version
102 // single particle stage
104 class idParticleStage {
106 idParticleStage( void );
107 virtual ~idParticleStage( void ) {}
110 virtual int NumQuadsPerParticle() const; // includes trails and cross faded animations
111 // returns the number of verts created, which will range from 0 to 4*NumQuadsPerParticle()
112 virtual int CreateParticle( particleGen_t *g, idDrawVert *verts ) const;
114 void ParticleOrigin( particleGen_t *g, idVec3 &origin ) const;
115 int ParticleVerts( particleGen_t *g, const idVec3 origin, idDrawVert *verts ) const;
116 void ParticleTexCoords( particleGen_t *g, idDrawVert *verts ) const;
117 void ParticleColors( particleGen_t *g, idDrawVert *verts ) const;
119 const char * GetCustomPathName();
120 const char * GetCustomPathDesc();
121 int NumCustomPathParms();
122 void SetCustomPathType( const char *p );
123 void operator=( const idParticleStage &src );
126 //------------------------------
128 const idMaterial * material;
130 int totalParticles; // total number of particles, although some may be invisible at a given time
131 float cycles; // allows things to oneShot ( 1 cycle ) or run for a set number of cycles
132 // on a per stage basis
134 int cycleMsec; // ( particleLife + deadTime ) in msec
136 float spawnBunching; // 0.0 = all come out at first instant, 1.0 = evenly spaced over cycle time
137 float particleLife; // total seconds of life for each particle
138 float timeOffset; // time offset from system start for the first particle to spawn
139 float deadTime; // time after particleLife before respawning
141 //------------------------------- // standard path parms
143 prtDistribution_t distributionType;
144 float distributionParms[4];
146 prtDirection_t directionType;
147 float directionParms[4];
149 idParticleParm speed;
150 float gravity; // can be negative to float up
151 bool worldGravity; // apply gravity in world space
152 bool randomDistribution; // randomly orient the quad on emission ( defaults to true )
153 bool entityColor; // force color from render entity ( fadeColor is still valid )
155 //------------------------------ // custom path will completely replace the standard path calculations
157 prtCustomPth_t customPathType; // use custom C code routines for determining the origin
158 float customPathParms[8];
160 //--------------------------------
162 idVec3 offset; // offset from origin to spawn all particles, also applies to customPath
164 int animationFrames; // if > 1, subdivide the texture S axis into frames and crossfade
165 float animationRate; // frames per second
167 float initialAngle; // in degrees, random angle is used if zero ( default )
168 idParticleParm rotationSpeed; // half the particles will have negative rotation speeds
170 prtOrientation_t orientation; // view, aimed, or axis fixed
171 float orientationParms[4];
174 idParticleParm aspect; // greater than 1 makes the T axis longer
177 idVec4 fadeColor; // either 0 0 0 0 for additive, or 1 1 1 0 for blended materials
178 float fadeInFraction; // in 0.0 to 1.0 range
179 float fadeOutFraction; // in 0.0 to 1.0 range
180 float fadeIndexFraction; // in 0.0 to 1.0 range, causes later index smokes to be more faded
182 bool hidden; // for editor use
183 //-----------------------------------
185 float boundsExpansion; // user tweak to fix poorly calculated bounds
187 idBounds bounds; // derived
192 // group of particle stages
194 class idDeclParticle : public idDecl {
197 virtual size_t Size( void ) const;
198 virtual const char * DefaultDefinition( void ) const;
199 virtual bool Parse( const char *text, const int textLength );
200 virtual void FreeData( void );
202 bool Save( const char *fileName = NULL );
204 idList<idParticleStage *>stages;
209 bool RebuildTextSource( void );
210 void GetStageBounds( idParticleStage *stage );
211 idParticleStage * ParseParticleStage( idLexer &src );
212 void ParseParms( idLexer &src, float *parms, int maxParms );
213 void ParseParametric( idLexer &src, idParticleParm *parm );
214 void WriteStage( idFile *f, idParticleStage *stage );
215 void WriteParticleParm( idFile *f, idParticleParm *parm, const char *name );
218 #endif /* !__DECLPARTICLE_H__ */