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