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/CSceneNodeAnimatorTexture.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 'libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorTexture.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorTexture.cpp | 280 |
1 files changed, 140 insertions, 140 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorTexture.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorTexture.cpp index 1cedf3d..67a34a3 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorTexture.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorTexture.cpp | |||
@@ -1,140 +1,140 @@ | |||
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 "CSceneNodeAnimatorTexture.h" | 5 | #include "CSceneNodeAnimatorTexture.h" |
6 | #include "ITexture.h" | 6 | #include "ITexture.h" |
7 | 7 | ||
8 | namespace irr | 8 | namespace irr |
9 | { | 9 | { |
10 | namespace scene | 10 | namespace scene |
11 | { | 11 | { |
12 | 12 | ||
13 | 13 | ||
14 | //! constructor | 14 | //! constructor |
15 | CSceneNodeAnimatorTexture::CSceneNodeAnimatorTexture(const core::array<video::ITexture*>& textures, | 15 | CSceneNodeAnimatorTexture::CSceneNodeAnimatorTexture(const core::array<video::ITexture*>& textures, |
16 | s32 timePerFrame, bool loop, u32 now) | 16 | s32 timePerFrame, bool loop, u32 now) |
17 | : ISceneNodeAnimatorFinishing(0), | 17 | : ISceneNodeAnimatorFinishing(0), |
18 | TimePerFrame(timePerFrame), StartTime(now), Loop(loop) | 18 | TimePerFrame(timePerFrame), StartTime(now), Loop(loop) |
19 | { | 19 | { |
20 | #ifdef _DEBUG | 20 | #ifdef _DEBUG |
21 | setDebugName("CSceneNodeAnimatorTexture"); | 21 | setDebugName("CSceneNodeAnimatorTexture"); |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | for (u32 i=0; i<textures.size(); ++i) | 24 | for (u32 i=0; i<textures.size(); ++i) |
25 | { | 25 | { |
26 | if (textures[i]) | 26 | if (textures[i]) |
27 | textures[i]->grab(); | 27 | textures[i]->grab(); |
28 | 28 | ||
29 | Textures.push_back(textures[i]); | 29 | Textures.push_back(textures[i]); |
30 | } | 30 | } |
31 | 31 | ||
32 | FinishTime = now + (timePerFrame * Textures.size()); | 32 | FinishTime = now + (timePerFrame * Textures.size()); |
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | //! destructor | 36 | //! destructor |
37 | CSceneNodeAnimatorTexture::~CSceneNodeAnimatorTexture() | 37 | CSceneNodeAnimatorTexture::~CSceneNodeAnimatorTexture() |
38 | { | 38 | { |
39 | clearTextures(); | 39 | clearTextures(); |
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||
43 | void CSceneNodeAnimatorTexture::clearTextures() | 43 | void CSceneNodeAnimatorTexture::clearTextures() |
44 | { | 44 | { |
45 | for (u32 i=0; i<Textures.size(); ++i) | 45 | for (u32 i=0; i<Textures.size(); ++i) |
46 | if (Textures[i]) | 46 | if (Textures[i]) |
47 | Textures[i]->drop(); | 47 | Textures[i]->drop(); |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | //! animates a scene node | 51 | //! animates a scene node |
52 | void CSceneNodeAnimatorTexture::animateNode(ISceneNode* node, u32 timeMs) | 52 | void CSceneNodeAnimatorTexture::animateNode(ISceneNode* node, u32 timeMs) |
53 | { | 53 | { |
54 | if(!node) | 54 | if(!node) |
55 | return; | 55 | return; |
56 | 56 | ||
57 | if (Textures.size()) | 57 | if (Textures.size()) |
58 | { | 58 | { |
59 | const u32 t = (timeMs-StartTime); | 59 | const u32 t = (timeMs-StartTime); |
60 | 60 | ||
61 | u32 idx = 0; | 61 | u32 idx = 0; |
62 | if (!Loop && timeMs >= FinishTime) | 62 | if (!Loop && timeMs >= FinishTime) |
63 | { | 63 | { |
64 | idx = Textures.size() - 1; | 64 | idx = Textures.size() - 1; |
65 | HasFinished = true; | 65 | HasFinished = true; |
66 | } | 66 | } |
67 | else | 67 | else |
68 | { | 68 | { |
69 | idx = (t/TimePerFrame) % Textures.size(); | 69 | idx = (t/TimePerFrame) % Textures.size(); |
70 | } | 70 | } |
71 | 71 | ||
72 | if (idx < Textures.size()) | 72 | if (idx < Textures.size()) |
73 | node->setMaterialTexture(0, Textures[idx]); | 73 | node->setMaterialTexture(0, Textures[idx]); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | //! Writes attributes of the scene node animator. | 78 | //! Writes attributes of the scene node animator. |
79 | void CSceneNodeAnimatorTexture::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const | 79 | void CSceneNodeAnimatorTexture::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const |
80 | { | 80 | { |
81 | out->addInt("TimePerFrame", TimePerFrame); | 81 | out->addInt("TimePerFrame", TimePerFrame); |
82 | out->addBool("Loop", Loop); | 82 | out->addBool("Loop", Loop); |
83 | 83 | ||
84 | // add one texture in addition when serializing for editors | 84 | // add one texture in addition when serializing for editors |
85 | // to make it easier to add textures quickly | 85 | // to make it easier to add textures quickly |
86 | 86 | ||
87 | u32 count = Textures.size(); | 87 | u32 count = Textures.size(); |
88 | if ( options && (options->Flags & io::EARWF_FOR_EDITOR)) | 88 | if ( options && (options->Flags & io::EARWF_FOR_EDITOR)) |
89 | count += 1; | 89 | count += 1; |
90 | 90 | ||
91 | for (u32 i=0; i<count; ++i) | 91 | for (u32 i=0; i<count; ++i) |
92 | { | 92 | { |
93 | core::stringc tname = "Texture"; | 93 | core::stringc tname = "Texture"; |
94 | tname += (int)(i+1); | 94 | tname += (int)(i+1); |
95 | 95 | ||
96 | out->addTexture(tname.c_str(), i<Textures.size() ? Textures[i] : 0); | 96 | out->addTexture(tname.c_str(), i<Textures.size() ? Textures[i] : 0); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | //! Reads attributes of the scene node animator. | 101 | //! Reads attributes of the scene node animator. |
102 | void CSceneNodeAnimatorTexture::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) | 102 | void CSceneNodeAnimatorTexture::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) |
103 | { | 103 | { |
104 | TimePerFrame = in->getAttributeAsInt("TimePerFrame"); | 104 | TimePerFrame = in->getAttributeAsInt("TimePerFrame"); |
105 | Loop = in->getAttributeAsBool("Loop"); | 105 | Loop = in->getAttributeAsBool("Loop"); |
106 | 106 | ||
107 | clearTextures(); | 107 | clearTextures(); |
108 | 108 | ||
109 | for(u32 i=1; true; ++i) | 109 | for(u32 i=1; true; ++i) |
110 | { | 110 | { |
111 | core::stringc tname = "Texture"; | 111 | core::stringc tname = "Texture"; |
112 | tname += (int)i; | 112 | tname += (int)i; |
113 | 113 | ||
114 | if (in->existsAttribute(tname.c_str())) | 114 | if (in->existsAttribute(tname.c_str())) |
115 | { | 115 | { |
116 | video::ITexture* tex = in->getAttributeAsTexture(tname.c_str()); | 116 | video::ITexture* tex = in->getAttributeAsTexture(tname.c_str()); |
117 | if (tex) | 117 | if (tex) |
118 | { | 118 | { |
119 | tex->grab(); | 119 | tex->grab(); |
120 | Textures.push_back(tex); | 120 | Textures.push_back(tex); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | else | 123 | else |
124 | break; | 124 | break; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | ISceneNodeAnimator* CSceneNodeAnimatorTexture::createClone(ISceneNode* node, ISceneManager* newManager) | 129 | ISceneNodeAnimator* CSceneNodeAnimatorTexture::createClone(ISceneNode* node, ISceneManager* newManager) |
130 | { | 130 | { |
131 | CSceneNodeAnimatorTexture * newAnimator = | 131 | CSceneNodeAnimatorTexture * newAnimator = |
132 | new CSceneNodeAnimatorTexture(Textures, TimePerFrame, Loop, StartTime); | 132 | new CSceneNodeAnimatorTexture(Textures, TimePerFrame, Loop, StartTime); |
133 | 133 | ||
134 | return newAnimator; | 134 | return newAnimator; |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | } // end namespace scene | 138 | } // end namespace scene |
139 | } // end namespace irr | 139 | } // end namespace irr |
140 | 140 | ||