doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DeclParticle.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
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.
13 
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.
18 
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/>.
21 
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.
23 
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.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __DECLPARTICLE_H__
30 #define __DECLPARTICLE_H__
31 
32 /*
33 ===============================================================================
34 
35  idDeclParticle
36 
37 ===============================================================================
38 */
39 
41 public:
42  idParticleParm( void ) { table = NULL; from = to = 0.0f; }
43 
44  const idDeclTable * table;
45  float from;
46  float to;
47 
48  float Eval( float frac, idRandom &rand ) const;
49  float Integrate( float frac, idRandom &rand ) const;
50 };
51 
52 
53 typedef enum {
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
60 
61 typedef enum {
62  PDIR_CONE, // parm0 is the solid cone angle
63  PDIR_OUTWARD // direction is relative to offset from origin, parm0 is an upward bias
65 
66 typedef enum {
68  PPATH_HELIX, // ( sizeX sizeY sizeZ radialSpeed climbSpeed )
73 
74 typedef enum {
76  POR_AIMED, // angle and aspect are disregarded
81 
83 typedef struct renderView_s renderView_t;
84 
85 typedef struct {
86  const renderEntity_t * renderEnt; // for shaderParms, etc
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
93 
94 
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
99 
100 
101 //
102 // single particle stage
103 //
105 public:
106  idParticleStage( void );
107  virtual ~idParticleStage( void ) {}
108 
109  void Default();
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;
113 
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;
118 
119  const char * GetCustomPathName();
120  const char * GetCustomPathDesc();
121  int NumCustomPathParms();
122  void SetCustomPathType( const char *p );
123  void operator=( const idParticleStage &src );
124 
125 
126  //------------------------------
127 
129 
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
133 
134  int cycleMsec; // ( particleLife + deadTime ) in msec
135 
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
140 
141  //------------------------------- // standard path parms
142 
145 
147  float directionParms[4];
148 
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 )
154 
155  //------------------------------ // custom path will completely replace the standard path calculations
156 
157  prtCustomPth_t customPathType; // use custom C code routines for determining the origin
158  float customPathParms[8];
159 
160  //--------------------------------
161 
162  idVec3 offset; // offset from origin to spawn all particles, also applies to customPath
163 
164  int animationFrames; // if > 1, subdivide the texture S axis into frames and crossfade
165  float animationRate; // frames per second
166 
167  float initialAngle; // in degrees, random angle is used if zero ( default )
168  idParticleParm rotationSpeed; // half the particles will have negative rotation speeds
169 
170  prtOrientation_t orientation; // view, aimed, or axis fixed
172 
174  idParticleParm aspect; // greater than 1 makes the T axis longer
175 
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
181 
182  bool hidden; // for editor use
183  //-----------------------------------
184 
185  float boundsExpansion; // user tweak to fix poorly calculated bounds
186 
187  idBounds bounds; // derived
188 };
189 
190 
191 //
192 // group of particle stages
193 //
194 class idDeclParticle : public idDecl {
195 public:
196 
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 );
201 
202  bool Save( const char *fileName = NULL );
203 
206  float depthHack;
207 
208 private:
209  bool RebuildTextSource( void );
210  void GetStageBounds( idParticleStage *stage );
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 );
216 };
217 
218 #endif /* !__DECLPARTICLE_H__ */
GLubyte g
Definition: glext.h:4662
float Eval(float frac, idRandom &rand) const
idParticleStage * ParseParticleStage(idLexer &src)
prtCustomPth_t
Definition: DeclParticle.h:66
float Integrate(float frac, idRandom &rand) const
void ParseParametric(idLexer &src, idParticleParm *parm)
virtual ~idParticleStage(void)
Definition: DeclParticle.h:107
prtDirection_t
Definition: DeclParticle.h:61
float fadeIndexFraction
Definition: DeclParticle.h:180
prtDistribution_t
Definition: DeclParticle.h:53
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:2846
Definition: Vector.h:316
const renderEntity_t * renderEnt
Definition: DeclParticle.h:86
virtual size_t Size(void) const
bool Save(const char *fileName=NULL)
GLuint src
Definition: glext.h:5390
virtual bool Parse(const char *text, const int textLength)
void ParticleOrigin(particleGen_t *g, idVec3 &origin) const
void GetStageBounds(idParticleStage *stage)
idParticleParm aspect
Definition: DeclParticle.h:174
idParticleParm rotationSpeed
Definition: DeclParticle.h:168
idRandom originalRandom
Definition: DeclParticle.h:96
void ParticleColors(particleGen_t *g, idDrawVert *verts) const
Definition: File.h:50
prtOrientation_t
Definition: DeclParticle.h:74
Definition: Lexer.h:137
void ParticleTexCoords(particleGen_t *g, idDrawVert *verts) const
void SetCustomPathType(const char *p)
Definition: Vector.h:808
float animationFrameFrac
Definition: DeclParticle.h:97
#define NULL
Definition: Lib.h:88
virtual int CreateParticle(particleGen_t *g, idDrawVert *verts) const
const renderView_t * renderView
Definition: DeclParticle.h:87
prtDirection_t directionType
Definition: DeclParticle.h:146
prtDistribution_t distributionType
Definition: DeclParticle.h:143
const char * GetCustomPathName()
const idMaterial * material
Definition: DeclParticle.h:128
void operator=(const idParticleStage &src)
float orientationParms[4]
Definition: DeclParticle.h:171
idList< idParticleStage * > stages
Definition: DeclParticle.h:204
idBounds bounds
Definition: DeclParticle.h:205
const char * GetCustomPathDesc()
prtCustomPth_t customPathType
Definition: DeclParticle.h:157
idRandom random
Definition: DeclParticle.h:90
int ParticleVerts(particleGen_t *g, const idVec3 origin, idDrawVert *verts) const
Definition: Matrix.h:333
idParticleParm speed
Definition: DeclParticle.h:149
void ParseParms(idLexer &src, float *parms, int maxParms)
tuple f
Definition: idal.py:89
virtual void FreeData(void)
const GLcharARB * name
Definition: glext.h:3629
const idDeclTable * table
Definition: DeclParticle.h:44
virtual const char * DefaultDefinition(void) const
idParticleParm(void)
Definition: DeclParticle.h:42
float distributionParms[4]
Definition: DeclParticle.h:144
void WriteStage(idFile *f, idParticleStage *stage)
float directionParms[4]
Definition: DeclParticle.h:147
prtOrientation_t orientation
Definition: DeclParticle.h:170
GLfloat GLfloat p
Definition: glext.h:4674
bool RebuildTextSource(void)
float customPathParms[8]
Definition: DeclParticle.h:158
void WriteParticleParm(idFile *f, idParticleParm *parm, const char *name)
virtual int NumQuadsPerParticle() const
idParticleParm size
Definition: DeclParticle.h:173