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