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 /libraries/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyStraight.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 'libraries/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp')
-rw-r--r-- | libraries/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/libraries/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp b/libraries/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp deleted file mode 100644 index 28730b8..0000000 --- a/libraries/irrlicht-1.8.1/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp +++ /dev/null | |||
@@ -1,112 +0,0 @@ | |||
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 "CSceneNodeAnimatorFlyStraight.h" | ||
6 | |||
7 | namespace irr | ||
8 | { | ||
9 | namespace scene | ||
10 | { | ||
11 | |||
12 | |||
13 | //! constructor | ||
14 | CSceneNodeAnimatorFlyStraight::CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, | ||
15 | const core::vector3df& endPoint, u32 timeForWay, | ||
16 | bool loop, u32 now, bool pingpong) | ||
17 | : ISceneNodeAnimatorFinishing(now + timeForWay), | ||
18 | Start(startPoint), End(endPoint), TimeFactor(0.0f), StartTime(now), | ||
19 | TimeForWay(timeForWay), Loop(loop), PingPong(pingpong) | ||
20 | { | ||
21 | #ifdef _DEBUG | ||
22 | setDebugName("CSceneNodeAnimatorFlyStraight"); | ||
23 | #endif | ||
24 | |||
25 | recalculateIntermediateValues(); | ||
26 | } | ||
27 | |||
28 | |||
29 | void CSceneNodeAnimatorFlyStraight::recalculateIntermediateValues() | ||
30 | { | ||
31 | Vector = End - Start; | ||
32 | TimeFactor = (f32)Vector.getLength() / TimeForWay; | ||
33 | Vector.normalize(); | ||
34 | } | ||
35 | |||
36 | |||
37 | //! animates a scene node | ||
38 | void CSceneNodeAnimatorFlyStraight::animateNode(ISceneNode* node, u32 timeMs) | ||
39 | { | ||
40 | if (!node) | ||
41 | return; | ||
42 | |||
43 | u32 t = (timeMs-StartTime); | ||
44 | |||
45 | core::vector3df pos; | ||
46 | |||
47 | if (!Loop && !PingPong && t >= TimeForWay) | ||
48 | { | ||
49 | pos = End; | ||
50 | HasFinished = true; | ||
51 | } | ||
52 | else if (!Loop && PingPong && t >= TimeForWay * 2.f ) | ||
53 | { | ||
54 | pos = Start; | ||
55 | HasFinished = true; | ||
56 | } | ||
57 | else | ||
58 | { | ||
59 | f32 phase = fmodf( (f32) t, (f32) TimeForWay ); | ||
60 | core::vector3df rel = Vector * phase * TimeFactor; | ||
61 | const bool pong = PingPong && fmodf( (f32) t, (f32) TimeForWay*2.f ) >= TimeForWay; | ||
62 | |||
63 | if ( !pong ) | ||
64 | { | ||
65 | pos += Start + rel; | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | pos = End - rel; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | node->setPosition(pos); | ||
74 | } | ||
75 | |||
76 | |||
77 | //! Writes attributes of the scene node animator. | ||
78 | void CSceneNodeAnimatorFlyStraight::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const | ||
79 | { | ||
80 | out->addVector3d("Start", Start); | ||
81 | out->addVector3d("End", End); | ||
82 | out->addInt("TimeForWay", TimeForWay); | ||
83 | out->addBool("Loop", Loop); | ||
84 | out->addBool("PingPong", PingPong); | ||
85 | } | ||
86 | |||
87 | |||
88 | //! Reads attributes of the scene node animator. | ||
89 | void CSceneNodeAnimatorFlyStraight::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) | ||
90 | { | ||
91 | Start = in->getAttributeAsVector3d("Start"); | ||
92 | End = in->getAttributeAsVector3d("End"); | ||
93 | TimeForWay = in->getAttributeAsInt("TimeForWay"); | ||
94 | Loop = in->getAttributeAsBool("Loop"); | ||
95 | PingPong = in->getAttributeAsBool("PingPong"); | ||
96 | |||
97 | recalculateIntermediateValues(); | ||
98 | } | ||
99 | |||
100 | |||
101 | ISceneNodeAnimator* CSceneNodeAnimatorFlyStraight::createClone(ISceneNode* node, ISceneManager* newManager) | ||
102 | { | ||
103 | CSceneNodeAnimatorFlyStraight * newAnimator = | ||
104 | new CSceneNodeAnimatorFlyStraight(Start, End, TimeForWay, Loop, StartTime, PingPong); | ||
105 | |||
106 | return newAnimator; | ||
107 | } | ||
108 | |||
109 | |||
110 | } // end namespace scene | ||
111 | } // end namespace irr | ||
112 | |||