]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CParticleSystemSceneNode.h
CIrrDeviceWin32: drop all video mode code
[irrlicht.git] / source / Irrlicht / CParticleSystemSceneNode.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__\r
6 #define __C_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 #ifdef _IRR_COMPILE_WITH_PARTICLES_\r
10 \r
11 #include "IParticleSystemSceneNode.h"\r
12 #include "irrArray.h"\r
13 #include "irrList.h"\r
14 #include "SMeshBuffer.h"\r
15 \r
16 namespace irr\r
17 {\r
18 namespace scene\r
19 {\r
20 \r
21 //! A particle system scene node.\r
22 /** A scene node controlling a particle system. The behavior of the particles\r
23 can be controlled by setting the right particle emitters and affectors.\r
24 */\r
25 class CParticleSystemSceneNode : public IParticleSystemSceneNode\r
26 {\r
27 public:\r
28 \r
29         //! constructor\r
30         CParticleSystemSceneNode(bool createDefaultEmitter,\r
31                 ISceneNode* parent, ISceneManager* mgr, s32 id,\r
32                 const core::vector3df& position,\r
33                 const core::vector3df& rotation,\r
34                 const core::vector3df& scale);\r
35 \r
36         //! destructor\r
37         virtual ~CParticleSystemSceneNode();\r
38 \r
39         //! Gets the particle emitter, which creates the particles.\r
40         virtual IParticleEmitter* getEmitter() _IRR_OVERRIDE_;\r
41 \r
42         //! Sets the particle emitter, which creates the particles.\r
43         virtual void setEmitter(IParticleEmitter* emitter) _IRR_OVERRIDE_;\r
44 \r
45         //! Adds new particle affector to the particle system.\r
46         virtual void addAffector(IParticleAffector* affector) _IRR_OVERRIDE_;\r
47 \r
48         //! Get a list of all particle affectors.\r
49         virtual const core::list<IParticleAffector*>& getAffectors() const _IRR_OVERRIDE_;\r
50 \r
51         //! Removes all particle affectors in the particle system.\r
52         virtual void removeAllAffectors() _IRR_OVERRIDE_;\r
53 \r
54         //! Returns the material based on the zero based index i.\r
55         virtual video::SMaterial& getMaterial(u32 i) _IRR_OVERRIDE_;\r
56 \r
57         //! Returns amount of materials used by this scene node.\r
58         virtual u32 getMaterialCount() const _IRR_OVERRIDE_;\r
59 \r
60         //! pre render event\r
61         virtual void OnRegisterSceneNode() _IRR_OVERRIDE_;\r
62 \r
63         //! render\r
64         virtual void render() _IRR_OVERRIDE_;\r
65 \r
66         //! returns the axis aligned bounding box of this node\r
67         virtual const core::aabbox3d<f32>& getBoundingBox() const _IRR_OVERRIDE_;\r
68 \r
69         //! Creates a particle emitter for an animated mesh scene node\r
70         virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(\r
71                 scene::IAnimatedMeshSceneNode* node, bool useNormalDirection = true,\r
72                 const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),\r
73                 f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,\r
74                 bool everyMeshVertex = false, u32 minParticlesPerSecond = 5,\r
75                 u32 maxParticlesPerSecond = 10,\r
76                 const video::SColor& minStartColor = video::SColor(255,0,0,0),\r
77                 const video::SColor& maxStartColor = video::SColor(255,255,255,255),\r
78                 u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,\r
79                 s32 maxAngleDegrees = 0,\r
80                 const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),\r
81                 const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) _IRR_OVERRIDE_;\r
82 \r
83         //! Creates a box particle emitter.\r
84         virtual IParticleBoxEmitter* createBoxEmitter(\r
85                 const core::aabbox3df& box = core::aabbox3d<f32>(-10,0,-10,5,30,10),\r
86                 const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),\r
87                 u32 minParticlesPerSecond = 5,\r
88                 u32 maxParticlesPerSecond = 10,\r
89                 const video::SColor& minStartColor = video::SColor(255,0,0,0),\r
90                 const video::SColor& maxStartColor = video::SColor(255,255,255,255),\r
91                 u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,\r
92                 s32 maxAngleDegrees=0,\r
93                 const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),\r
94                 const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) _IRR_OVERRIDE_;\r
95 \r
96         //! Creates a particle emitter for emitting from a cylinder\r
97         virtual IParticleCylinderEmitter* createCylinderEmitter(\r
98                 const core::vector3df& center, f32 radius,\r
99                 const core::vector3df& normal, f32 length,\r
100                 bool outlineOnly = false, const core::vector3df& direction = core::vector3df(0.0f,0.5f,0.0f),\r
101                 u32 minParticlesPerSecond = 5, u32 maxParticlesPersSecond = 10,\r
102                 const video::SColor& minStartColor = video::SColor(255,0,0,0),\r
103                 const video::SColor& maxStartColor = video::SColor(255,255,255,255),\r
104                 u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,\r
105                 s32 maxAngleDegrees = 0,\r
106                 const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),\r
107                 const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) _IRR_OVERRIDE_;\r
108 \r
109         //! Creates a mesh particle emitter.\r
110         virtual IParticleMeshEmitter* createMeshEmitter(\r
111                 scene::IMesh* mesh, bool useNormalDirection = true,\r
112                 const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),\r
113                 f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,\r
114                 bool everyMeshVertex = false,\r
115                 u32 minParticlesPerSecond = 5,\r
116                 u32 maxParticlesPerSecond = 10,\r
117                 const video::SColor& minStartColor = video::SColor(255,0,0,0),\r
118                 const video::SColor& maxStartColor = video::SColor(255,255,255,255),\r
119                 u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,\r
120                 s32 maxAngleDegrees = 0,\r
121                 const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),\r
122                 const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) _IRR_OVERRIDE_;\r
123 \r
124         //! Creates a point particle emitter.\r
125         virtual IParticlePointEmitter* createPointEmitter(\r
126                 const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),\r
127                 u32 minParticlesPerSecond = 5,\r
128                 u32 maxParticlesPerSecond = 10,\r
129                 const video::SColor& minStartColor = video::SColor(255,0,0,0),\r
130                 const video::SColor& maxStartColor = video::SColor(255,255,255,255),\r
131                 u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,\r
132                 s32 maxAngleDegrees=0,\r
133                 const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),\r
134                 const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) _IRR_OVERRIDE_;\r
135 \r
136         //! Creates a ring particle emitter.\r
137         virtual IParticleRingEmitter* createRingEmitter(\r
138                 const core::vector3df& center, f32 radius, f32 ringThickness,\r
139                 const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),\r
140                 u32 minParticlesPerSecond = 5,\r
141                 u32 maxParticlesPerSecond = 10,\r
142                 const video::SColor& minStartColor = video::SColor(255,0,0,0),\r
143                 const video::SColor& maxStartColor = video::SColor(255,255,255,255),\r
144                 u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,\r
145                 s32 maxAngleDegrees=0,\r
146                 const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),\r
147                 const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) _IRR_OVERRIDE_;\r
148 \r
149         //! Creates a sphere particle emitter.\r
150         virtual IParticleSphereEmitter* createSphereEmitter(\r
151                 const core::vector3df& center, f32 radius,\r
152                 const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),\r
153                 u32 minParticlesPerSecond = 5,\r
154                 u32 maxParticlesPerSecond = 10,\r
155                 const video::SColor& minStartColor = video::SColor(255,0,0,0),\r
156                 const video::SColor& maxStartColor = video::SColor(255,255,255,255),\r
157                 u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,\r
158                 s32 maxAngleDegrees=0,\r
159                 const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),\r
160                 const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) _IRR_OVERRIDE_;\r
161 \r
162         //! Creates a point attraction affector. This affector modifies the positions of the\r
163         //! particles and attracts them to a specified point at a specified speed per second.\r
164         virtual IParticleAttractionAffector* createAttractionAffector(\r
165                 const core::vector3df& point, f32 speed = 1.0f, bool attract = true,\r
166                 bool affectX = true, bool affectY = true, bool affectZ = true) _IRR_OVERRIDE_;\r
167 \r
168         //! Creates a scale particle affector.\r
169         virtual IParticleAffector* createScaleParticleAffector(\r
170                 const core::dimension2df& scaleTo = core::dimension2df(1.0f, 1.0f)) _IRR_OVERRIDE_;\r
171 \r
172         //! Creates a fade out particle affector.\r
173         virtual IParticleFadeOutAffector* createFadeOutParticleAffector(\r
174                 const video::SColor& targetColor = video::SColor(0,0,0,0),\r
175                 u32 timeNeededToFadeOut = 1000) _IRR_OVERRIDE_;\r
176 \r
177         //! Creates a gravity affector.\r
178         virtual IParticleGravityAffector* createGravityAffector(\r
179                 const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f),\r
180                 u32 timeForceLost = 1000) _IRR_OVERRIDE_;\r
181 \r
182         //! Creates a rotation affector. This affector rotates the particles\r
183         //! around a specified pivot point. The speed is in Degrees per second.\r
184         virtual IParticleRotationAffector* createRotationAffector(\r
185                 const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f),\r
186                 const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ) _IRR_OVERRIDE_;\r
187 \r
188         //! Sets the size of all particles.\r
189         virtual void setParticleSize(\r
190                 const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f)) _IRR_OVERRIDE_;\r
191 \r
192         //! Sets if the particles should be global. If they are, the particles are affected by\r
193         //! the movement of the particle system scene node too, otherwise they completely\r
194         //! ignore it. Default is true.\r
195         virtual void setParticlesAreGlobal(bool global=true) _IRR_OVERRIDE_;\r
196 \r
197         //! Remove all currently visible particles\r
198         virtual void clearParticles() _IRR_OVERRIDE_;\r
199 \r
200         //! Sets if the node should be visible or not.\r
201         virtual void setVisible(bool isVisible) _IRR_OVERRIDE_;\r
202 \r
203         //! Do manually update the particles.\r
204         //! This should only be called when you want to render the node outside the scenegraph,\r
205         //! as the node will care about this otherwise automatically.\r
206         virtual void doParticleSystem(u32 time) _IRR_OVERRIDE_;\r
207 \r
208         //! Writes attributes of the scene node.\r
209         virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const _IRR_OVERRIDE_;\r
210 \r
211         //! Reads attributes of the scene node.\r
212         virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;\r
213 \r
214         //! Returns type of the scene node\r
215         virtual ESCENE_NODE_TYPE getType() const _IRR_OVERRIDE_ { return ESNT_PARTICLE_SYSTEM; }\r
216 \r
217 private:\r
218 \r
219         void reallocateBuffers();\r
220 \r
221         core::list<IParticleAffector*> AffectorList;\r
222         IParticleEmitter* Emitter;\r
223         core::array<SParticle> Particles;\r
224         core::dimension2d<f32> ParticleSize;\r
225         u32 LastEmitTime;\r
226         core::matrix4 LastAbsoluteTransformation;\r
227 \r
228         SMeshBuffer* Buffer;\r
229 \r
230 // TODO: That was obviously planned by someone at some point and sounds like a good idea.\r
231 // But seems it was never implemented.\r
232 //      enum E_PARTICLES_PRIMITIVE\r
233 //      {\r
234 //              EPP_POINT=0,\r
235 //              EPP_BILLBOARD,\r
236 //              EPP_POINTSPRITE\r
237 //      };\r
238 //      E_PARTICLES_PRIMITIVE ParticlePrimitive;\r
239 \r
240         bool ParticlesAreGlobal;\r
241 };\r
242 \r
243 } // end namespace scene\r
244 } // end namespace irr\r
245 \r
246 #endif // _IRR_COMPILE_WITH_PARTICLES_\r
247 \r
248 #endif\r
249 \r