2009-01-14 04:37:51 -08:00
|
|
|
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#include "CSceneNodeAnimatorRotation.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CSceneNodeAnimatorRotation::CSceneNodeAnimatorRotation(u32 time, const core::vector3df& rotation)
|
|
|
|
: Rotation(rotation), StartTime(time)
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
|
|
|
setDebugName("CSceneNodeAnimatorRotation");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
CSceneNodeAnimatorRotation::~CSceneNodeAnimatorRotation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! animates a scene node
|
|
|
|
void CSceneNodeAnimatorRotation::animateNode(ISceneNode* node, u32 timeMs)
|
|
|
|
{
|
|
|
|
if (node) // thanks to warui for this fix
|
|
|
|
{
|
|
|
|
u32 diffTime = timeMs - StartTime;
|
|
|
|
|
|
|
|
if (diffTime != 0)
|
|
|
|
{
|
|
|
|
core::vector3df NewRotation = node->getRotation();
|
|
|
|
NewRotation += Rotation* ((diffTime)/10.0f);
|
|
|
|
node->setRotation(NewRotation);
|
|
|
|
StartTime=timeMs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! Writes attributes of the scene node animator.
|
2007-09-14 15:25:59 -07:00
|
|
|
void CSceneNodeAnimatorRotation::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
|
2007-05-20 11:03:49 -07:00
|
|
|
{
|
|
|
|
out->addVector3d("Rotation", Rotation);
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Reads attributes of the scene node animator.
|
|
|
|
void CSceneNodeAnimatorRotation::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
|
|
|
|
{
|
|
|
|
Rotation = in->getAttributeAsVector3d("Rotation");
|
|
|
|
}
|
|
|
|
|
2008-10-12 19:55:54 -07:00
|
|
|
ISceneNodeAnimator* CSceneNodeAnimatorRotation::createClone(ISceneNode* node, ISceneManager* newManager)
|
|
|
|
{
|
|
|
|
CSceneNodeAnimatorRotation * newAnimator =
|
|
|
|
new CSceneNodeAnimatorRotation(StartTime, Rotation);
|
|
|
|
|
|
|
|
return newAnimator;
|
|
|
|
}
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|