~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CSceneNodeAnimatorRotation.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 
 
5
#include "CSceneNodeAnimatorRotation.h"
 
6
 
 
7
namespace irr
 
8
{
 
9
namespace scene
 
10
{
 
11
 
 
12
 
 
13
//! constructor
 
14
CSceneNodeAnimatorRotation::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
 
24
void 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.
 
49
void 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.
 
56
void CSceneNodeAnimatorRotation::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
 
57
{
 
58
        Rotation = in->getAttributeAsVector3d("Rotation");
 
59
}
 
60
 
 
61
 
 
62
ISceneNodeAnimator* 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