diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp | 224 |
1 files changed, 112 insertions, 112 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp index 28730b8..3e65469 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyStraight.cpp | |||
@@ -1,112 +1,112 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #include "CSceneNodeAnimatorFlyStraight.h" | 5 | #include "CSceneNodeAnimatorFlyStraight.h" |
6 | 6 | ||
7 | namespace irr | 7 | namespace irr |
8 | { | 8 | { |
9 | namespace scene | 9 | namespace scene |
10 | { | 10 | { |
11 | 11 | ||
12 | 12 | ||
13 | //! constructor | 13 | //! constructor |
14 | CSceneNodeAnimatorFlyStraight::CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, | 14 | CSceneNodeAnimatorFlyStraight::CSceneNodeAnimatorFlyStraight(const core::vector3df& startPoint, |
15 | const core::vector3df& endPoint, u32 timeForWay, | 15 | const core::vector3df& endPoint, u32 timeForWay, |
16 | bool loop, u32 now, bool pingpong) | 16 | bool loop, u32 now, bool pingpong) |
17 | : ISceneNodeAnimatorFinishing(now + timeForWay), | 17 | : ISceneNodeAnimatorFinishing(now + timeForWay), |
18 | Start(startPoint), End(endPoint), TimeFactor(0.0f), StartTime(now), | 18 | Start(startPoint), End(endPoint), TimeFactor(0.0f), StartTime(now), |
19 | TimeForWay(timeForWay), Loop(loop), PingPong(pingpong) | 19 | TimeForWay(timeForWay), Loop(loop), PingPong(pingpong) |
20 | { | 20 | { |
21 | #ifdef _DEBUG | 21 | #ifdef _DEBUG |
22 | setDebugName("CSceneNodeAnimatorFlyStraight"); | 22 | setDebugName("CSceneNodeAnimatorFlyStraight"); |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | recalculateIntermediateValues(); | 25 | recalculateIntermediateValues(); |
26 | } | 26 | } |
27 | 27 | ||
28 | 28 | ||
29 | void CSceneNodeAnimatorFlyStraight::recalculateIntermediateValues() | 29 | void CSceneNodeAnimatorFlyStraight::recalculateIntermediateValues() |
30 | { | 30 | { |
31 | Vector = End - Start; | 31 | Vector = End - Start; |
32 | TimeFactor = (f32)Vector.getLength() / TimeForWay; | 32 | TimeFactor = (f32)Vector.getLength() / TimeForWay; |
33 | Vector.normalize(); | 33 | Vector.normalize(); |
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | //! animates a scene node | 37 | //! animates a scene node |
38 | void CSceneNodeAnimatorFlyStraight::animateNode(ISceneNode* node, u32 timeMs) | 38 | void CSceneNodeAnimatorFlyStraight::animateNode(ISceneNode* node, u32 timeMs) |
39 | { | 39 | { |
40 | if (!node) | 40 | if (!node) |
41 | return; | 41 | return; |
42 | 42 | ||
43 | u32 t = (timeMs-StartTime); | 43 | u32 t = (timeMs-StartTime); |
44 | 44 | ||
45 | core::vector3df pos; | 45 | core::vector3df pos; |
46 | 46 | ||
47 | if (!Loop && !PingPong && t >= TimeForWay) | 47 | if (!Loop && !PingPong && t >= TimeForWay) |
48 | { | 48 | { |
49 | pos = End; | 49 | pos = End; |
50 | HasFinished = true; | 50 | HasFinished = true; |
51 | } | 51 | } |
52 | else if (!Loop && PingPong && t >= TimeForWay * 2.f ) | 52 | else if (!Loop && PingPong && t >= TimeForWay * 2.f ) |
53 | { | 53 | { |
54 | pos = Start; | 54 | pos = Start; |
55 | HasFinished = true; | 55 | HasFinished = true; |
56 | } | 56 | } |
57 | else | 57 | else |
58 | { | 58 | { |
59 | f32 phase = fmodf( (f32) t, (f32) TimeForWay ); | 59 | f32 phase = fmodf( (f32) t, (f32) TimeForWay ); |
60 | core::vector3df rel = Vector * phase * TimeFactor; | 60 | core::vector3df rel = Vector * phase * TimeFactor; |
61 | const bool pong = PingPong && fmodf( (f32) t, (f32) TimeForWay*2.f ) >= TimeForWay; | 61 | const bool pong = PingPong && fmodf( (f32) t, (f32) TimeForWay*2.f ) >= TimeForWay; |
62 | 62 | ||
63 | if ( !pong ) | 63 | if ( !pong ) |
64 | { | 64 | { |
65 | pos += Start + rel; | 65 | pos += Start + rel; |
66 | } | 66 | } |
67 | else | 67 | else |
68 | { | 68 | { |
69 | pos = End - rel; | 69 | pos = End - rel; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | node->setPosition(pos); | 73 | node->setPosition(pos); |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | //! Writes attributes of the scene node animator. | 77 | //! Writes attributes of the scene node animator. |
78 | void CSceneNodeAnimatorFlyStraight::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const | 78 | void CSceneNodeAnimatorFlyStraight::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const |
79 | { | 79 | { |
80 | out->addVector3d("Start", Start); | 80 | out->addVector3d("Start", Start); |
81 | out->addVector3d("End", End); | 81 | out->addVector3d("End", End); |
82 | out->addInt("TimeForWay", TimeForWay); | 82 | out->addInt("TimeForWay", TimeForWay); |
83 | out->addBool("Loop", Loop); | 83 | out->addBool("Loop", Loop); |
84 | out->addBool("PingPong", PingPong); | 84 | out->addBool("PingPong", PingPong); |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | //! Reads attributes of the scene node animator. | 88 | //! Reads attributes of the scene node animator. |
89 | void CSceneNodeAnimatorFlyStraight::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) | 89 | void CSceneNodeAnimatorFlyStraight::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) |
90 | { | 90 | { |
91 | Start = in->getAttributeAsVector3d("Start"); | 91 | Start = in->getAttributeAsVector3d("Start"); |
92 | End = in->getAttributeAsVector3d("End"); | 92 | End = in->getAttributeAsVector3d("End"); |
93 | TimeForWay = in->getAttributeAsInt("TimeForWay"); | 93 | TimeForWay = in->getAttributeAsInt("TimeForWay"); |
94 | Loop = in->getAttributeAsBool("Loop"); | 94 | Loop = in->getAttributeAsBool("Loop"); |
95 | PingPong = in->getAttributeAsBool("PingPong"); | 95 | PingPong = in->getAttributeAsBool("PingPong"); |
96 | 96 | ||
97 | recalculateIntermediateValues(); | 97 | recalculateIntermediateValues(); |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | ISceneNodeAnimator* CSceneNodeAnimatorFlyStraight::createClone(ISceneNode* node, ISceneManager* newManager) | 101 | ISceneNodeAnimator* CSceneNodeAnimatorFlyStraight::createClone(ISceneNode* node, ISceneManager* newManager) |
102 | { | 102 | { |
103 | CSceneNodeAnimatorFlyStraight * newAnimator = | 103 | CSceneNodeAnimatorFlyStraight * newAnimator = |
104 | new CSceneNodeAnimatorFlyStraight(Start, End, TimeForWay, Loop, StartTime, PingPong); | 104 | new CSceneNodeAnimatorFlyStraight(Start, End, TimeForWay, Loop, StartTime, PingPong); |
105 | 105 | ||
106 | return newAnimator; | 106 | return newAnimator; |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | } // end namespace scene | 110 | } // end namespace scene |
111 | } // end namespace irr | 111 | } // end namespace irr |
112 | 112 | ||