aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CParticleRotationAffector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CParticleRotationAffector.cpp')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CParticleRotationAffector.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CParticleRotationAffector.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CParticleRotationAffector.cpp
new file mode 100644
index 0000000..e59854a
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CParticleRotationAffector.cpp
@@ -0,0 +1,67 @@
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 "CParticleRotationAffector.h"
6#include "IAttributes.h"
7
8namespace irr
9{
10namespace scene
11{
12
13//! constructor
14CParticleRotationAffector::CParticleRotationAffector( const core::vector3df& speed, const core::vector3df& pivotPoint )
15 : PivotPoint(pivotPoint), Speed(speed), LastTime(0)
16{
17 #ifdef _DEBUG
18 setDebugName("CParticleRotationAffector");
19 #endif
20}
21
22
23//! Affects an array of particles.
24void CParticleRotationAffector::affect(u32 now, SParticle* particlearray, u32 count)
25{
26 if( LastTime == 0 )
27 {
28 LastTime = now;
29 return;
30 }
31
32 f32 timeDelta = ( now - LastTime ) / 1000.0f;
33 LastTime = now;
34
35 if( !Enabled )
36 return;
37
38 for(u32 i=0; i<count; ++i)
39 {
40 if( Speed.X != 0.0f )
41 particlearray[i].pos.rotateYZBy( timeDelta * Speed.X, PivotPoint );
42
43 if( Speed.Y != 0.0f )
44 particlearray[i].pos.rotateXZBy( timeDelta * Speed.Y, PivotPoint );
45
46 if( Speed.Z != 0.0f )
47 particlearray[i].pos.rotateXYBy( timeDelta * Speed.Z, PivotPoint );
48 }
49}
50
51//! Writes attributes of the object.
52void CParticleRotationAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
53{
54 out->addVector3d("PivotPoint", PivotPoint);
55 out->addVector3d("Speed", Speed);
56}
57
58//! Reads attributes of the object.
59void CParticleRotationAffector::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
60{
61 PivotPoint = in->getAttributeAsVector3d("PivotPoint");
62 Speed = in->getAttributeAsVector3d("Speed");
63}
64
65} // end namespace scene
66} // end namespace irr
67