diff options
author | David Walter Seikel | 2014-01-13 19:47:58 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-01-13 19:47:58 +1000 |
commit | f9158592e1478b2013afc7041d9ed041cf2d2f4a (patch) | |
tree | b16e389d7988700e21b4c9741044cefa536dcbae /libraries/irrlicht-1.8/source/Irrlicht/CParticleCylinderEmitter.cpp | |
parent | Libraries readme updated with change markers and more of the Irrlicht changes. (diff) | |
download | SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.zip SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.gz SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.bz2 SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.xz |
Update Irrlicht to 1.8.1. Include actual change markers this time. lol
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CParticleCylinderEmitter.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CParticleCylinderEmitter.cpp | 187 |
1 files changed, 0 insertions, 187 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CParticleCylinderEmitter.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CParticleCylinderEmitter.cpp deleted file mode 100644 index 3e7eafc..0000000 --- a/libraries/irrlicht-1.8/source/Irrlicht/CParticleCylinderEmitter.cpp +++ /dev/null | |||
@@ -1,187 +0,0 @@ | |||
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 | #include "CParticleCylinderEmitter.h" | ||
6 | #include "os.h" | ||
7 | #include "IAttributes.h" | ||
8 | |||
9 | namespace irr | ||
10 | { | ||
11 | namespace scene | ||
12 | { | ||
13 | |||
14 | //! constructor | ||
15 | CParticleCylinderEmitter::CParticleCylinderEmitter( | ||
16 | const core::vector3df& center, f32 radius, | ||
17 | const core::vector3df& normal, f32 length, | ||
18 | bool outlineOnly, const core::vector3df& direction, | ||
19 | u32 minParticlesPerSecond, u32 maxParticlesPerSecond, | ||
20 | const video::SColor& minStartColor, const video::SColor& maxStartColor, | ||
21 | u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, | ||
22 | const core::dimension2df& minStartSize, | ||
23 | const core::dimension2df& maxStartSize ) | ||
24 | : Center(center), Normal(normal), Direction(direction), | ||
25 | MaxStartSize(maxStartSize), MinStartSize(minStartSize), | ||
26 | MinParticlesPerSecond(minParticlesPerSecond), | ||
27 | MaxParticlesPerSecond(maxParticlesPerSecond), | ||
28 | MinStartColor(minStartColor), MaxStartColor(maxStartColor), | ||
29 | MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), | ||
30 | Radius(radius), Length(length), Time(0), Emitted(0), | ||
31 | MaxAngleDegrees(maxAngleDegrees), OutlineOnly(outlineOnly) | ||
32 | { | ||
33 | #ifdef _DEBUG | ||
34 | setDebugName("CParticleCylinderEmitter"); | ||
35 | #endif | ||
36 | } | ||
37 | |||
38 | |||
39 | //! Prepares an array with new particles to emitt into the system | ||
40 | //! and returns how much new particles there are. | ||
41 | s32 CParticleCylinderEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) | ||
42 | { | ||
43 | Time += timeSinceLastCall; | ||
44 | |||
45 | const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); | ||
46 | const f32 perSecond = pps ? ((f32)MinParticlesPerSecond + os::Randomizer::frand() * pps) : MinParticlesPerSecond; | ||
47 | const f32 everyWhatMillisecond = 1000.0f / perSecond; | ||
48 | |||
49 | if(Time > everyWhatMillisecond) | ||
50 | { | ||
51 | Particles.set_used(0); | ||
52 | u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f); | ||
53 | Time = 0; | ||
54 | SParticle p; | ||
55 | |||
56 | if(amount > MaxParticlesPerSecond*2) | ||
57 | amount = MaxParticlesPerSecond * 2; | ||
58 | |||
59 | for(u32 i=0; i<amount; ++i) | ||
60 | { | ||
61 | // Random distance from center if outline only is not true | ||
62 | const f32 distance = (!OutlineOnly) ? (os::Randomizer::frand() * Radius) : Radius; | ||
63 | |||
64 | // Random direction from center | ||
65 | p.pos.set(Center.X + distance, Center.Y, Center.Z + distance); | ||
66 | p.pos.rotateXZBy(os::Randomizer::frand() * 360, Center); | ||
67 | |||
68 | // Random length | ||
69 | const f32 length = os::Randomizer::frand() * Length; | ||
70 | |||
71 | // Random point along the cylinders length | ||
72 | p.pos += Normal * length; | ||
73 | |||
74 | p.startTime = now; | ||
75 | p.vector = Direction; | ||
76 | |||
77 | if( MaxAngleDegrees ) | ||
78 | { | ||
79 | core::vector3df tgt = Direction; | ||
80 | tgt.rotateXYBy(os::Randomizer::frand() * MaxAngleDegrees); | ||
81 | tgt.rotateYZBy(os::Randomizer::frand() * MaxAngleDegrees); | ||
82 | tgt.rotateXZBy(os::Randomizer::frand() * MaxAngleDegrees); | ||
83 | p.vector = tgt; | ||
84 | } | ||
85 | |||
86 | p.endTime = now + MinLifeTime; | ||
87 | if (MaxLifeTime != MinLifeTime) | ||
88 | p.endTime += os::Randomizer::rand() % (MaxLifeTime - MinLifeTime); | ||
89 | |||
90 | if (MinStartColor==MaxStartColor) | ||
91 | p.color=MinStartColor; | ||
92 | else | ||
93 | p.color = MinStartColor.getInterpolated(MaxStartColor, os::Randomizer::frand()); | ||
94 | |||
95 | p.startColor = p.color; | ||
96 | p.startVector = p.vector; | ||
97 | |||
98 | if (MinStartSize==MaxStartSize) | ||
99 | p.startSize = MinStartSize; | ||
100 | else | ||
101 | p.startSize = MinStartSize.getInterpolated(MaxStartSize, os::Randomizer::frand()); | ||
102 | p.size = p.startSize; | ||
103 | |||
104 | Particles.push_back(p); | ||
105 | } | ||
106 | |||
107 | outArray = Particles.pointer(); | ||
108 | |||
109 | return Particles.size(); | ||
110 | } | ||
111 | |||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | //! Writes attributes of the object. | ||
116 | void CParticleCylinderEmitter::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const | ||
117 | { | ||
118 | out->addVector3d("Center", Center); | ||
119 | out->addVector3d("Normal", Normal); | ||
120 | out->addVector3d("Direction", Direction); | ||
121 | out->addFloat("MinStartSizeWidth", MinStartSize.Width); | ||
122 | out->addFloat("MinStartSizeHeight", MinStartSize.Height); | ||
123 | out->addFloat("MaxStartSizeWidth", MaxStartSize.Width); | ||
124 | out->addFloat("MaxStartSizeHeight", MaxStartSize.Height); | ||
125 | out->addInt("MinParticlesPerSecond", MinParticlesPerSecond); | ||
126 | out->addInt("MaxParticlesPerSecond", MaxParticlesPerSecond); | ||
127 | out->addColor("MinStartColor", MinStartColor); | ||
128 | out->addColor("MaxStartColor", MaxStartColor); | ||
129 | out->addInt("MinLifeTime", MinLifeTime); | ||
130 | out->addInt("MaxLifeTime", MaxLifeTime); | ||
131 | out->addFloat("Radius", Radius); | ||
132 | out->addFloat("Length", Length); | ||
133 | out->addInt("MaxAngleDegrees", MaxAngleDegrees); | ||
134 | out->addBool("OutlineOnly", OutlineOnly); | ||
135 | } | ||
136 | |||
137 | //! Reads attributes of the object. | ||
138 | void CParticleCylinderEmitter::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) | ||
139 | { | ||
140 | Center = in->getAttributeAsVector3d("Center"); | ||
141 | Normal = in->getAttributeAsVector3d("Normal"); | ||
142 | if (Normal.getLength() == 0) | ||
143 | Normal.set(0,1.f,0); | ||
144 | Direction = in->getAttributeAsVector3d("Direction"); | ||
145 | if (Direction.getLength() == 0) | ||
146 | Direction.set(0,0.01f,0); | ||
147 | |||
148 | int idx = -1; | ||
149 | idx = in->findAttribute("MinStartSizeWidth"); | ||
150 | if ( idx >= 0 ) | ||
151 | MinStartSize.Width = in->getAttributeAsFloat(idx); | ||
152 | idx = in->findAttribute("MinStartSizeHeight"); | ||
153 | if ( idx >= 0 ) | ||
154 | MinStartSize.Height = in->getAttributeAsFloat(idx); | ||
155 | idx = in->findAttribute("MaxStartSizeWidth"); | ||
156 | if ( idx >= 0 ) | ||
157 | MaxStartSize.Width = in->getAttributeAsFloat(idx); | ||
158 | idx = in->findAttribute("MaxStartSizeHeight"); | ||
159 | if ( idx >= 0 ) | ||
160 | MaxStartSize.Height = in->getAttributeAsFloat(idx); | ||
161 | |||
162 | MinParticlesPerSecond = in->getAttributeAsInt("MinParticlesPerSecond"); | ||
163 | MaxParticlesPerSecond = in->getAttributeAsInt("MaxParticlesPerSecond"); | ||
164 | |||
165 | MinParticlesPerSecond = core::max_(1u, MinParticlesPerSecond); | ||
166 | MaxParticlesPerSecond = core::max_(MaxParticlesPerSecond, 1u); | ||
167 | MaxParticlesPerSecond = core::min_(MaxParticlesPerSecond, 200u); | ||
168 | MinParticlesPerSecond = core::min_(MinParticlesPerSecond, MaxParticlesPerSecond); | ||
169 | |||
170 | MinStartColor = in->getAttributeAsColor("MinStartColor"); | ||
171 | MaxStartColor = in->getAttributeAsColor("MaxStartColor"); | ||
172 | MinLifeTime = in->getAttributeAsInt("MinLifeTime"); | ||
173 | MaxLifeTime = in->getAttributeAsInt("MaxLifeTime"); | ||
174 | MinLifeTime = core::max_(0u, MinLifeTime); | ||
175 | MaxLifeTime = core::max_(MaxLifeTime, MinLifeTime); | ||
176 | MinLifeTime = core::min_(MinLifeTime, MaxLifeTime); | ||
177 | |||
178 | Radius = in->getAttributeAsFloat("Radius"); | ||
179 | Length = in->getAttributeAsFloat("Length"); | ||
180 | MaxAngleDegrees = in->getAttributeAsInt("MaxAngleDegrees"); | ||
181 | OutlineOnly = in->getAttributeAsBool("OutlineOnly"); | ||
182 | } | ||
183 | |||
184 | |||
185 | } // end namespace scene | ||
186 | } // end namespace irr | ||
187 | |||