aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorRotation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorRotation.cpp')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorRotation.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorRotation.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorRotation.cpp
new file mode 100644
index 0000000..f3c5473
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorRotation.cpp
@@ -0,0 +1,73 @@
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 "CSceneNodeAnimatorRotation.h"
6
7namespace irr
8{
9namespace scene
10{
11
12
13//! constructor
14CSceneNodeAnimatorRotation::CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation)
15: Rotation(rotation), StartTime(time)
16{
17 #ifdef _DEBUG
18 setDebugName("CSceneNodeAnimatorRotation");
19 #endif
20}
21
22
23//! animates a scene node
24void CSceneNodeAnimatorRotation::animateNode(ISceneNode* node, u32 timeMs)
25{
26 if (node) // thanks to warui for this fix
27 {
28 const u32 diffTime = timeMs - StartTime;
29
30 if (diffTime != 0)
31 {
32 // clip the rotation to small values, to avoid
33 // precision problems with huge floats.
34 core::vector3df rot = node->getRotation() + Rotation*(diffTime*0.1f);
35 if (rot.X>360.f)
36 rot.X=fmodf(rot.X, 360.f);
37 if (rot.Y>360.f)
38 rot.Y=fmodf(rot.Y, 360.f);
39 if (rot.Z>360.f)
40 rot.Z=fmodf(rot.Z, 360.f);
41 node->setRotation(rot);
42 StartTime=timeMs;
43 }
44 }
45}
46
47
48//! Writes attributes of the scene node animator.
49void CSceneNodeAnimatorRotation::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
50{
51 out->addVector3d("Rotation", Rotation);
52}
53
54
55//! Reads attributes of the scene node animator.
56void CSceneNodeAnimatorRotation::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
57{
58 Rotation = in->getAttributeAsVector3d("Rotation");
59}
60
61
62ISceneNodeAnimator* CSceneNodeAnimatorRotation::createClone(ISceneNode* node, ISceneManager* newManager)
63{
64 CSceneNodeAnimatorRotation * newAnimator =
65 new CSceneNodeAnimatorRotation(StartTime, Rotation);
66
67 return newAnimator;
68}
69
70
71} // end namespace scene
72} // end namespace irr
73