1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __C_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__
6 #define __C_PARTICLE_CYLINDER_EMITTER_H_INCLUDED__
7 
8 #include "IParticleCylinderEmitter.h"
9 #include "irrArray.h"
10 
11 namespace irr
12 {
13 namespace scene
14 {
15 
16 //! A default box emitter
17 class CParticleCylinderEmitter : public IParticleCylinderEmitter
18 {
19 public:
20 
21 	//! constructor
22 	CParticleCylinderEmitter(
23 		const core::vector3df& center, f32 radius,
24 		const core::vector3df& normal, f32 length,
25 		bool outlineOnly = false, const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
26 		u32 minParticlesPerSecond = 20,
27 		u32 maxParticlesPerSecond = 40,
28 		const video::SColor& minStartColor = video::SColor(255,0,0,0),
29 		const video::SColor& maxStartColor = video::SColor(255,255,255,255),
30 		u32 lifeTimeMin=2000,
31 		u32 lifeTimeMax=4000,
32 		s32 maxAngleDegrees=0,
33 		const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
34 		const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f)
35 		);
36 
37 	//! Prepares an array with new particles to emitt into the system
38 	//! and returns how much new particles there are.
39 	virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
40 
41 	//! Set the center of the radius for the cylinder, at one end of the cylinder
setCenter(const core::vector3df & center)42 	virtual void setCenter( const core::vector3df& center ) { Center = center; }
43 
44 	//! Set the normal of the cylinder
setNormal(const core::vector3df & normal)45 	virtual void setNormal( const core::vector3df& normal ) { Normal = normal; }
46 
47 	//! Set the radius of the cylinder
setRadius(f32 radius)48 	virtual void setRadius( f32 radius ) { Radius = radius; }
49 
50 	//! Set the length of the cylinder
setLength(f32 length)51 	virtual void setLength( f32 length ) { Length = length; }
52 
53 	//! Set whether or not to draw points inside the cylinder
setOutlineOnly(bool outlineOnly)54 	virtual void setOutlineOnly( bool outlineOnly ) { OutlineOnly = outlineOnly; }
55 
56 	//! Set direction the emitter emits particles
setDirection(const core::vector3df & newDirection)57 	virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
58 
59 	//! Set direction the emitter emits particles
setMinParticlesPerSecond(u32 minPPS)60 	virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
61 
62 	//! Set direction the emitter emits particles
setMaxParticlesPerSecond(u32 maxPPS)63 	virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
64 
65 	//! Set direction the emitter emits particles
setMinStartColor(const video::SColor & color)66 	virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
67 
68 	//! Set direction the emitter emits particles
setMaxStartColor(const video::SColor & color)69 	virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
70 
71 	//! Set the maximum starting size for particles
setMaxStartSize(const core::dimension2df & size)72 	virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }
73 
74 	//! Set the minimum starting size for particles
setMinStartSize(const core::dimension2df & size)75 	virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }
76 
77 	//! Set the minimum particle life-time in milliseconds
setMinLifeTime(u32 lifeTimeMin)78 	virtual void setMinLifeTime( u32 lifeTimeMin ) { MinLifeTime = lifeTimeMin; }
79 
80 	//! Set the maximum particle life-time in milliseconds
setMaxLifeTime(u32 lifeTimeMax)81 	virtual void setMaxLifeTime( u32 lifeTimeMax ) { MaxLifeTime = lifeTimeMax; }
82 
83 	//!	Maximal random derivation from the direction
setMaxAngleDegrees(s32 maxAngleDegrees)84 	virtual void setMaxAngleDegrees( s32 maxAngleDegrees ) { MaxAngleDegrees = maxAngleDegrees; }
85 
86 	//! Get the center of the cylinder
getCenter()87 	virtual const core::vector3df& getCenter() const { return Center; }
88 
89 	//! Get the normal of the cylinder
getNormal()90 	virtual const core::vector3df& getNormal() const { return Normal; }
91 
92 	//! Get the radius of the cylinder
getRadius()93 	virtual f32 getRadius() const { return Radius; }
94 
95 	//! Get the center of the cylinder
getLength()96 	virtual f32 getLength() const { return Length; }
97 
98 	//! Get whether or not to draw points inside the cylinder
getOutlineOnly()99 	virtual bool getOutlineOnly() const { return OutlineOnly; }
100 
101 	//! Gets direction the emitter emits particles
getDirection()102 	virtual const core::vector3df& getDirection() const { return Direction; }
103 
104 	//! Gets direction the emitter emits particles
getMinParticlesPerSecond()105 	virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
106 
107 	//! Gets direction the emitter emits particles
getMaxParticlesPerSecond()108 	virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
109 
110 	//! Gets direction the emitter emits particles
getMinStartColor()111 	virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
112 
113 	//! Gets direction the emitter emits particles
getMaxStartColor()114 	virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
115 
116 	//! Gets the maximum starting size for particles
getMaxStartSize()117 	virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }
118 
119 	//! Gets the minimum starting size for particles
getMinStartSize()120 	virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }
121 
122 	//! Get the minimum particle life-time in milliseconds
getMinLifeTime()123 	virtual u32 getMinLifeTime() const { return MinLifeTime; }
124 
125 	//! Get the maximum particle life-time in milliseconds
getMaxLifeTime()126 	virtual u32 getMaxLifeTime() const { return MaxLifeTime; }
127 
128 	//!	Maximal random derivation from the direction
getMaxAngleDegrees()129 	virtual s32 getMaxAngleDegrees() const { return MaxAngleDegrees; }
130 
131 	//! Writes attributes of the object.
132 	virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
133 
134 	//! Reads attributes of the object.
135 	virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
136 
137 private:
138 
139 	core::array<SParticle> Particles;
140 
141 	core::vector3df	Center;
142 	core::vector3df	Normal;
143 	core::vector3df Direction;
144 	core::dimension2df MaxStartSize, MinStartSize;
145 	u32 MinParticlesPerSecond, MaxParticlesPerSecond;
146 	video::SColor MinStartColor, MaxStartColor;
147 	u32 MinLifeTime, MaxLifeTime;
148 
149 	f32 Radius;
150 	f32 Length;
151 
152 	u32 Time;
153 	u32 Emitted;
154 	s32 MaxAngleDegrees;
155 
156 	bool OutlineOnly;
157 };
158 
159 } // end namespace scene
160 } // end namespace irr
161 
162 
163 #endif
164 
165