]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CParticleRotationAffector.cpp
Set includes and libs on object targets
[irrlicht.git] / source / Irrlicht / CParticleRotationAffector.cpp
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
4 \r
5 #include "CParticleRotationAffector.h"\r
6 \r
7 #include "IrrCompileConfig.h"\r
8 #ifdef _IRR_COMPILE_WITH_PARTICLES_\r
9 \r
10 #include "IAttributes.h"\r
11 \r
12 namespace irr\r
13 {\r
14 namespace scene\r
15 {\r
16 \r
17 //! constructor\r
18 CParticleRotationAffector::CParticleRotationAffector( const core::vector3df& speed, const core::vector3df& pivotPoint )\r
19                 : PivotPoint(pivotPoint), Speed(speed), LastTime(0)\r
20 {\r
21         #ifdef _DEBUG\r
22         setDebugName("CParticleRotationAffector");\r
23         #endif\r
24 }\r
25 \r
26 \r
27 //! Affects an array of particles.\r
28 void CParticleRotationAffector::affect(u32 now, SParticle* particlearray, u32 count)\r
29 {\r
30         if( LastTime == 0 )\r
31         {\r
32                 LastTime = now;\r
33                 return;\r
34         }\r
35 \r
36         f32 timeDelta = ( now - LastTime ) / 1000.0f;\r
37         LastTime = now;\r
38 \r
39         if( !Enabled )\r
40                 return;\r
41 \r
42         for(u32 i=0; i<count; ++i)\r
43         {\r
44                 if( Speed.X != 0.0f )\r
45                         particlearray[i].pos.rotateYZBy( timeDelta * Speed.X, PivotPoint );\r
46 \r
47                 if( Speed.Y != 0.0f )\r
48                         particlearray[i].pos.rotateXZBy( timeDelta * Speed.Y, PivotPoint );\r
49 \r
50                 if( Speed.Z != 0.0f )\r
51                         particlearray[i].pos.rotateXYBy( timeDelta * Speed.Z, PivotPoint );\r
52         }\r
53 }\r
54 \r
55 //! Writes attributes of the object.\r
56 void CParticleRotationAffector::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const\r
57 {\r
58         out->addVector3d("PivotPoint", PivotPoint);\r
59         out->addVector3d("Speed", Speed);\r
60 }\r
61 \r
62 //! Reads attributes of the object.\r
63 void CParticleRotationAffector::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)\r
64 {\r
65         PivotPoint = in->getAttributeAsVector3d("PivotPoint");\r
66         Speed = in->getAttributeAsVector3d("Speed");\r
67 }\r
68 \r
69 } // end namespace scene\r
70 } // end namespace irr\r
71 \r
72 #endif // _IRR_COMPILE_WITH_PARTICLES_\r