1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #include "CParticleRotationAffector.h"
\r
7 #include "IrrCompileConfig.h"
\r
8 #ifdef _IRR_COMPILE_WITH_PARTICLES_
\r
10 #include "IAttributes.h"
\r
18 CParticleRotationAffector::CParticleRotationAffector( const core::vector3df& speed, const core::vector3df& pivotPoint )
\r
19 : PivotPoint(pivotPoint), Speed(speed), LastTime(0)
\r
22 setDebugName("CParticleRotationAffector");
\r
27 //! Affects an array of particles.
\r
28 void CParticleRotationAffector::affect(u32 now, SParticle* particlearray, u32 count)
\r
36 f32 timeDelta = ( now - LastTime ) / 1000.0f;
\r
42 for(u32 i=0; i<count; ++i)
\r
44 if( Speed.X != 0.0f )
\r
45 particlearray[i].pos.rotateYZBy( timeDelta * Speed.X, PivotPoint );
\r
47 if( Speed.Y != 0.0f )
\r
48 particlearray[i].pos.rotateXZBy( timeDelta * Speed.Y, PivotPoint );
\r
50 if( Speed.Z != 0.0f )
\r
51 particlearray[i].pos.rotateXYBy( timeDelta * Speed.Z, PivotPoint );
\r
55 //! Writes attributes of the object.
\r
56 void CParticleRotationAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
\r
58 out->addVector3d("PivotPoint", PivotPoint);
\r
59 out->addVector3d("Speed", Speed);
\r
62 //! Reads attributes of the object.
\r
63 void CParticleRotationAffector::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
\r
65 PivotPoint = in->getAttributeAsVector3d("PivotPoint");
\r
66 Speed = in->getAttributeAsVector3d("Speed");
\r
69 } // end namespace scene
\r
70 } // end namespace irr
\r
72 #endif // _IRR_COMPILE_WITH_PARTICLES_
\r