aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CParticleScaleAffector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CParticleScaleAffector.cpp')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CParticleScaleAffector.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CParticleScaleAffector.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CParticleScaleAffector.cpp
new file mode 100644
index 0000000..1817bcf
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CParticleScaleAffector.cpp
@@ -0,0 +1,53 @@
1// Copyright (C) 2010-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 "CParticleScaleAffector.h"
6#include "IAttributes.h"
7
8namespace irr
9{
10 namespace scene
11 {
12 CParticleScaleAffector::CParticleScaleAffector(const core::dimension2df& scaleTo)
13 : ScaleTo(scaleTo)
14 {
15 #ifdef _DEBUG
16 setDebugName("CParticleScaleAffector");
17 #endif
18 }
19
20
21 void CParticleScaleAffector::affect (u32 now, SParticle *particlearray, u32 count)
22 {
23 for(u32 i=0;i<count;i++)
24 {
25 const u32 maxdiff = particlearray[i].endTime - particlearray[i].startTime;
26 const u32 curdiff = now - particlearray[i].startTime;
27 const f32 newscale = (f32)curdiff/maxdiff;
28 particlearray[i].size = particlearray[i].startSize+ScaleTo*newscale;
29 }
30 }
31
32
33 void CParticleScaleAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
34 {
35 out->addFloat("ScaleToWidth", ScaleTo.Width);
36 out->addFloat("ScaleToHeight", ScaleTo.Height);
37 }
38
39
40 void CParticleScaleAffector::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
41 {
42 ScaleTo.Width = in->getAttributeAsFloat("ScaleToWidth");
43 ScaleTo.Height = in->getAttributeAsFloat("ScaleToHeight");
44 }
45
46
47 E_PARTICLE_AFFECTOR_TYPE CParticleScaleAffector::getType() const
48 {
49 return scene::EPAT_SCALE;
50 }
51 }
52}
53