ScummVM API documentation
ParticleEmitter.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_PARTICLE_EMITTER_H
29 #define HPL_PARTICLE_EMITTER_H
30 
31 #include "common/array.h"
32 #include "common/list.h"
33 #include "hpl1/engine/graphics/GraphicsTypes.h"
34 #include "hpl1/engine/graphics/Material.h"
35 #include "hpl1/engine/math/MathTypes.h"
36 #include "hpl1/engine/system/SystemTypes.h"
37 #include "common/stablemap.h"
38 
39 namespace hpl {
40 
41 enum eParticleEmitterType {
42  eParticleEmitterType_2D,
43  eParticleEmitterType_3D,
44  eParticleEmitterType_LastEnum,
45 };
46 
47 // NEW
48 
49 enum ePENoiseType {
50  ePENoiseType_LowFreq,
51  ePENoiseType_HighFreq,
52  ePENoiseType_Both,
53  ePENoiseType_None,
54  ePENoiseType_LastEnum,
55 };
56 
57 typedef struct
58 {
59  float fRelToBeamPos;
60  float fRelToBendPos;
61  int lLowFreqNoiseIdx;
62  int lHighFreqNoiseIdx;
63  ePENoiseType noiseType;
65 
66 // ---
67 
71 
72 class cParticle {
73 public:
74  cParticle() {}
75 
76  cVector3f mvPos;
77  cVector3f mvLastPos;
78  cVector3f mvLastCollidePos;
79  cVector3f mvAcc;
80  cVector3f mvVel;
81 
82  float mfSpeedMul;
83  float mfMaxSpeed;
84 
85  cColor mStartColor;
86  cColor mColor;
87 
88  cVector2f mvStartSize;
89  cVector2f mvSize;
90 
91  float mfStartLife;
92  float mfLife;
93  float mfLifeSize_MiddleStart;
94  float mfLifeSize_MiddleEnd;
95 
96  float mfLifeColor_MiddleStart;
97  float mfLifeColor_MiddleEnd;
98 
99  int mlSubDivNum;
100 
101  float mfBounceAmount;
102  int mlBounceCount;
103 
104  cVector3f mvExtra;
105 
106  // NEW
107 
108  float mfSpin;
109  float mfSpinVel;
110  float mfSpinFactor;
111 
112  cVector3f mvRevolutionVel;
113 
114  // Beam Specific
115 
116  int mlLowFreqPoints;
117  int mlHighFreqPoints;
118  Common::Array<cVector3f> mvBeamPoints;
119 
120  // ---
121 };
122 
124 typedef tParticleVec::iterator tParticleVecIt;
125 
129 
130 class cGraphics;
131 class cResources;
132 
134 public:
135  iParticleEmitter(tMaterialVec *avMaterials, unsigned int alMaxParticles,
136  cVector3f avSize, cGraphics *apGraphics, cResources *apResources);
137  virtual ~iParticleEmitter();
138 
139  void Update(float afTimeStep);
140 
141  virtual void Render() = 0;
142 
143  virtual eParticleEmitterType GetType() = 0;
144 
145  tString GetEntityType() { return "ParticleEmitter"; }
146 
147  virtual bool IsDead() { return mlNumOfParticles == 0 && mbDying; }
148  virtual void Kill() { mbDying = true; }
149 
150  void KillInstantly();
151 
152  virtual bool IsDying() { return mbDying; }
153 
154  void SetDataName(const tString &asName) { msDataName = asName; }
155  void SetDataSize(const cVector3f &avSize) { mvDataSize = avSize; }
156 
157  int GetParticleNum() { return mlNumOfParticles; }
158 
159 protected:
160  cGraphics *mpGraphics;
161  cResources *mpResources;
162 
163  tString msDataName;
164  cVector3f mvDataSize;
165 
166  tParticleVec mvParticles;
167  unsigned int mlNumOfParticles;
168  unsigned int mlMaxParticles;
169 
170  cMatrixf m_mtxTemp;
171 
172  tMaterialVec *mvMaterials;
173 
174  // Vars for easier updating.
175  float mfTime;
176  bool mbDying;
177  float mfFrame;
178 
179  bool mbUpdateGfx;
180  bool mbUpdateBV;
181 
182  virtual void UpdateMotion(float afTimeStep) = 0;
183 
184  virtual void SetParticleDefaults(cParticle *apParticle) = 0;
185 
190  void SwapRemove(unsigned int alIndex);
191  cParticle *CreateParticle();
192 };
193 
196 
200 
201 class cResources;
202 
204  friend class cParticleSystemData3D;
205 
206 public:
213  iParticleEmitterData(const tString &asName, cResources *apResources, cGraphics *apGraphics);
214  virtual ~iParticleEmitterData();
215 
216  void AddMaterial(iMaterial *apMaterial);
217 
218  const tString &GetName() { return msName; }
219 
220  virtual iParticleEmitter *Create(tString asName, cVector3f avSize) = 0;
221 
222  float GetWarmUpTime() const { return mfWarmUpTime; }
223  float GetWarmUpStepsPerSec() const { return mfWarmUpStepsPerSec; }
224 
225 protected:
226  cResources *mpResources;
227  cGraphics *mpGraphics;
228 
229  tString msName;
230  tMaterialVec mvMaterials;
231 
232  float mfWarmUpTime;
233  float mfWarmUpStepsPerSec;
234 };
235 
237 typedef tParticleEmitterDataMap::iterator tParticleEmitterDataMapIt;
238 
239 } // namespace hpl
240 
241 #endif // HPL_PARTICLE_EMITTER_H
Definition: AI.h:36
Definition: str.h:59
Definition: ParticleEmitter.h:203
Definition: list.h:44
T * iterator
Definition: array.h:54
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: stablemap.h:43
Definition: ParticleEmitter.h:57
Definition: ParticleEmitter.h:133
Definition: ParticleEmitter.h:72
Definition: Resources.h:160
Definition: Color.h:37
Definition: list_intern.h:51
Definition: Material.h:203
Definition: Graphics.h:46
Definition: ParticleSystem3D.h:45