diff options
author | David Walter Seikel | 2016-03-28 22:28:34 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-03-28 22:28:34 +1000 |
commit | 7028cbe09c688437910a25623098762bf0fa592d (patch) | |
tree | 10b5af58277d9880380c2251f109325542c4e6eb /src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp | |
parent | Move lemon to the src/others directory. (diff) | |
download | SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.zip SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.gz SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.bz2 SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.xz |
Move Irrlicht to src/others.
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp')
-rw-r--r-- | src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp new file mode 100644 index 0000000..dc887fa --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp | |||
@@ -0,0 +1,100 @@ | |||
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 "CSceneNodeAnimatorFlyCircle.h" | ||
6 | |||
7 | namespace irr | ||
8 | { | ||
9 | namespace scene | ||
10 | { | ||
11 | |||
12 | |||
13 | //! constructor | ||
14 | CSceneNodeAnimatorFlyCircle::CSceneNodeAnimatorFlyCircle(u32 time, | ||
15 | const core::vector3df& center, f32 radius, f32 speed, | ||
16 | const core::vector3df& direction, f32 radiusEllipsoid) | ||
17 | : Center(center), Direction(direction), Radius(radius), | ||
18 | RadiusEllipsoid(radiusEllipsoid), Speed(speed), StartTime(time) | ||
19 | { | ||
20 | #ifdef _DEBUG | ||
21 | setDebugName("CSceneNodeAnimatorFlyCircle"); | ||
22 | #endif | ||
23 | init(); | ||
24 | } | ||
25 | |||
26 | |||
27 | void CSceneNodeAnimatorFlyCircle::init() | ||
28 | { | ||
29 | Direction.normalize(); | ||
30 | |||
31 | if (Direction.Y != 0) | ||
32 | VecV = core::vector3df(50,0,0).crossProduct(Direction).normalize(); | ||
33 | else | ||
34 | VecV = core::vector3df(0,50,0).crossProduct(Direction).normalize(); | ||
35 | VecU = VecV.crossProduct(Direction).normalize(); | ||
36 | } | ||
37 | |||
38 | |||
39 | //! animates a scene node | ||
40 | void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs) | ||
41 | { | ||
42 | if ( 0 == node ) | ||
43 | return; | ||
44 | |||
45 | f32 time; | ||
46 | |||
47 | // Check for the condition where the StartTime is in the future. | ||
48 | if(StartTime > timeMs) | ||
49 | time = ((s32)timeMs - (s32)StartTime) * Speed; | ||
50 | else | ||
51 | time = (timeMs-StartTime) * Speed; | ||
52 | |||
53 | // node->setPosition(Center + Radius * ((VecU*cosf(time)) + (VecV*sinf(time)))); | ||
54 | f32 r2 = RadiusEllipsoid == 0.f ? Radius : RadiusEllipsoid; | ||
55 | node->setPosition(Center + (Radius*cosf(time)*VecU) + (r2*sinf(time)*VecV ) ); | ||
56 | } | ||
57 | |||
58 | |||
59 | //! Writes attributes of the scene node animator. | ||
60 | void CSceneNodeAnimatorFlyCircle::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const | ||
61 | { | ||
62 | out->addVector3d("Center", Center); | ||
63 | out->addFloat("Radius", Radius); | ||
64 | out->addFloat("Speed", Speed); | ||
65 | out->addVector3d("Direction", Direction); | ||
66 | out->addFloat("RadiusEllipsoid", RadiusEllipsoid); | ||
67 | } | ||
68 | |||
69 | |||
70 | //! Reads attributes of the scene node animator. | ||
71 | void CSceneNodeAnimatorFlyCircle::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) | ||
72 | { | ||
73 | Center = in->getAttributeAsVector3d("Center"); | ||
74 | Radius = in->getAttributeAsFloat("Radius"); | ||
75 | Speed = in->getAttributeAsFloat("Speed"); | ||
76 | Direction = in->getAttributeAsVector3d("Direction"); | ||
77 | StartTime = 0; | ||
78 | |||
79 | if (Direction.equals(core::vector3df(0,0,0))) | ||
80 | Direction.set(0,1,0); // irrlicht 1.1 backwards compatibility | ||
81 | else | ||
82 | Direction.normalize(); | ||
83 | |||
84 | RadiusEllipsoid = in->getAttributeAsFloat("RadiusEllipsoid"); | ||
85 | init(); | ||
86 | } | ||
87 | |||
88 | |||
89 | ISceneNodeAnimator* CSceneNodeAnimatorFlyCircle::createClone(ISceneNode* node, ISceneManager* newManager) | ||
90 | { | ||
91 | CSceneNodeAnimatorFlyCircle * newAnimator = | ||
92 | new CSceneNodeAnimatorFlyCircle(StartTime, Center, Radius, Speed, Direction, RadiusEllipsoid); | ||
93 | |||
94 | return newAnimator; | ||
95 | } | ||
96 | |||
97 | |||
98 | } // end namespace scene | ||
99 | } // end namespace irr | ||
100 | |||