1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#include "CSceneNodeAnimatorRotation.h"
14
CSceneNodeAnimatorRotation::CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation)
15
: Rotation(rotation), StartTime(time)
18
setDebugName("CSceneNodeAnimatorRotation");
23
//! animates a scene node
24
void CSceneNodeAnimatorRotation::animateNode(ISceneNode* node, u32 timeMs)
26
if (node) // thanks to warui for this fix
28
const u32 diffTime = timeMs - StartTime;
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);
36
rot.X=fmodf(rot.X, 360.f);
38
rot.Y=fmodf(rot.Y, 360.f);
40
rot.Z=fmodf(rot.Z, 360.f);
41
node->setRotation(rot);
48
//! Writes attributes of the scene node animator.
49
void CSceneNodeAnimatorRotation::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
51
out->addVector3d("Rotation", Rotation);
55
//! Reads attributes of the scene node animator.
56
void CSceneNodeAnimatorRotation::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
58
Rotation = in->getAttributeAsVector3d("Rotation");
62
ISceneNodeAnimator* CSceneNodeAnimatorRotation::createClone(ISceneNode* node, ISceneManager* newManager)
64
CSceneNodeAnimatorRotation * newAnimator =
65
new CSceneNodeAnimatorRotation(StartTime, Rotation);
71
} // end namespace scene
72
} // end namespace irr