OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MeshAnimation.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2010-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 
17 /* Value providers for mesh animation, cf. StdMeshInstance */
18 
19 #ifndef INC_C4MeshAnimation
20 #define INC_C4MeshAnimation
21 
22 #include "lib/StdMesh.h"
23 #include "object/C4ObjectPtr.h"
24 
26 {
44 };
45 
47 {
51 };
52 
53 // Keep a constant value
55 {
56 public:
57  C4ValueProviderConst() = default;
59  bool Execute() override;
60 };
61 
62 // Interpolate linearly in time between two values
64 {
65 public:
66  C4ValueProviderLinear(): Begin(Fix0), End(Fix0) {}
67  C4ValueProviderLinear(C4Real pos, C4Real begin, C4Real end, int32_t length, C4AnimationEnding ending);
68  bool Execute() override;
69 
70  void CompileFunc(StdCompiler* pComp) override;
71 private:
72  C4Real Begin;
73  C4Real End;
74  int32_t Length{0};
76 
77  int32_t LastTick{0};
78 };
79 
81 {
82 public:
83  C4ValueProviderX(): Object(nullptr), Begin(Fix0), End(Fix0) {}
84  C4ValueProviderX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
85  bool Execute() override;
86 
87  void CompileFunc(StdCompiler* pComp) override;
88  void DenumeratePointers() override { Object.DenumeratePointers(); }
89  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
90 private:
91  C4ObjectPtr Object;
92  C4Real Begin;
93  C4Real End;
94  int32_t Length{0};
95 };
96 
98 {
99 public:
100  C4ValueProviderY(): Object(nullptr), Begin(Fix0), End(Fix0) {}
101  C4ValueProviderY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
102  bool Execute() override;
103 
104  void CompileFunc(StdCompiler* pComp) override;
105  void DenumeratePointers() override { Object.DenumeratePointers(); }
106  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
107 private:
108  C4ObjectPtr Object;
109  C4Real Begin;
110  C4Real End;
111  int32_t Length{0};
112 };
113 
115 {
116 public:
117  C4ValueProviderR(): Object(nullptr), Begin(Fix0), End(Fix0) {}
118  C4ValueProviderR(C4Object* object, C4Real begin, C4Real end);
119  bool Execute() override;
120 
121  void CompileFunc(StdCompiler* pComp) override;
122  void DenumeratePointers() override { Object.DenumeratePointers(); }
123  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
124 private:
125  C4ObjectPtr Object;
126  C4Real Begin;
127  C4Real End;
128 };
129 
131 {
132 public:
133  C4ValueProviderAbsX(): Object(nullptr), Begin(Fix0), End(Fix0) {}
134  C4ValueProviderAbsX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
135  bool Execute() override;
136 
137  void CompileFunc(StdCompiler* pComp) override;
138  void DenumeratePointers() override { Object.DenumeratePointers(); }
139  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
140 private:
141  C4ObjectPtr Object;
142  C4Real Begin;
143  C4Real End;
144  int32_t Length{0};
145 };
146 
148 {
149 public:
150  C4ValueProviderAbsY(): Object(nullptr), Begin(Fix0), End(Fix0) {}
151  C4ValueProviderAbsY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
152  bool Execute() override;
153 
154  void CompileFunc(StdCompiler* pComp) override;
155  void DenumeratePointers() override { Object.DenumeratePointers(); }
156  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
157 private:
158  C4ObjectPtr Object;
159  C4Real Begin;
160  C4Real End;
161  int32_t Length{0};
162 };
163 
165 {
166 public:
167  C4ValueProviderDist(): Object(nullptr), Begin(Fix0), End(Fix0) {}
168  C4ValueProviderDist(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
169  bool Execute() override;
170 
171  void CompileFunc(StdCompiler* pComp) override;
172  void DenumeratePointers() override { Object.DenumeratePointers(); }
173  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
174 private:
175  C4ObjectPtr Object;
176  C4Real Begin;
177  C4Real End;
178  int32_t Length{0};
179 };
180 
182 {
183 public:
184  C4ValueProviderXDir(): Object(nullptr), Begin(Fix0), End(Fix0), MaxXDir(Fix0) {}
185  C4ValueProviderXDir(C4Object* object, C4Real begin, C4Real end, C4Real max_xdir);
186  bool Execute() override;
187 
188  void CompileFunc(StdCompiler* pComp) override;
189  void DenumeratePointers() override { Object.DenumeratePointers(); }
190  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
191 private:
192  C4ObjectPtr Object;
193  C4Real Begin;
194  C4Real End;
195  C4Real MaxXDir;
196 };
197 
199 {
200 public:
201  C4ValueProviderYDir(): Object(nullptr), Begin(Fix0), End(Fix0), MaxYDir(Fix0) {}
202  C4ValueProviderYDir(C4Object* object, C4Real begin, C4Real end, C4Real max_ydir);
203  bool Execute() override;
204 
205  void CompileFunc(StdCompiler* pComp) override;
206  void DenumeratePointers() override { Object.DenumeratePointers(); }
207  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
208 private:
209  C4ObjectPtr Object;
210  C4Real Begin;
211  C4Real End;
212  C4Real MaxYDir;
213 };
214 
216 {
217 public:
218  C4ValueProviderRDir(): Object(nullptr), Begin(Fix0), End(Fix0), MinRDir(Fix0), MaxRDir(Fix0) {}
219  C4ValueProviderRDir(C4Object* object, C4Real begin, C4Real end, C4Real min_rdir, C4Real max_rdir);
220  bool Execute() override;
221 
222  void CompileFunc(StdCompiler* pComp) override;
223  void DenumeratePointers() override { Object.DenumeratePointers(); }
224  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
225 private:
226  C4ObjectPtr Object;
227  C4Real Begin;
228  C4Real End;
229  C4Real MinRDir;
230  C4Real MaxRDir;
231 };
232 
234 {
235 public:
236  C4ValueProviderAbsRDir(): Object(nullptr), Begin(Fix0), End(Fix0), MinRDir(Fix0), MaxRDir(Fix0) {}
237  C4ValueProviderAbsRDir(C4Object* object, C4Real begin, C4Real end, C4Real min_rdir, C4Real max_rdir);
238  bool Execute() override;
239 
240  void CompileFunc(StdCompiler* pComp) override;
241  void DenumeratePointers() override { Object.DenumeratePointers(); }
242  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
243 private:
244  C4ObjectPtr Object;
245  C4Real Begin;
246  C4Real End;
247  C4Real MinRDir;
248  C4Real MaxRDir;
249 };
250 
252 {
253 public:
254  C4ValueProviderCosR(): Object(nullptr), Begin(Fix0), End(Fix0), Offset(Fix0) {}
255  C4ValueProviderCosR(C4Object* object, C4Real begin, C4Real end, C4Real offset);
256  bool Execute() override;
257 
258  void CompileFunc(StdCompiler* pComp) override;
259  void DenumeratePointers() override { Object.DenumeratePointers(); }
260  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
261 private:
262  C4ObjectPtr Object;
263  C4Real Begin;
264  C4Real End;
265  C4Real Offset;
266 };
267 
269 {
270 public:
271  C4ValueProviderSinR(): Object(nullptr), Begin(Fix0), End(Fix0), Offset(Fix0) {}
272  C4ValueProviderSinR(C4Object* object, C4Real begin, C4Real end, C4Real offset);
273  bool Execute() override;
274 
275  void CompileFunc(StdCompiler* pComp) override;
276  void DenumeratePointers() override { Object.DenumeratePointers(); }
277  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
278 private:
279  C4ObjectPtr Object;
280  C4Real Begin;
281  C4Real End;
282  C4Real Offset;
283 };
284 
286 {
287 public:
288  C4ValueProviderCosV(): Object(nullptr), Begin(Fix0), End(Fix0), Offset(Fix0) {}
289  C4ValueProviderCosV(C4Object* object, C4Real begin, C4Real end, C4Real offset);
290  bool Execute() override;
291 
292  void CompileFunc(StdCompiler* pComp) override;
293  void DenumeratePointers() override { Object.DenumeratePointers(); }
294  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
295 private:
296  C4ObjectPtr Object;
297  C4Real Begin;
298  C4Real End;
299  C4Real Offset;
300 };
301 
303 {
304 public:
305  C4ValueProviderSinV(): Object(nullptr), Begin(Fix0), End(Fix0), Offset(Fix0) {}
306  C4ValueProviderSinV(C4Object* object, C4Real begin, C4Real end, C4Real offset);
307  bool Execute() override;
308 
309  void CompileFunc(StdCompiler* pComp) override;
310  void DenumeratePointers() override { Object.DenumeratePointers(); }
311  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
312 private:
313  C4ObjectPtr Object;
314  C4Real Begin;
315  C4Real End;
316  C4Real Offset;
317 };
318 
320 {
321 public:
322  C4ValueProviderAction(): Object(nullptr) {}
324  bool Execute() override;
325 
326  void CompileFunc(StdCompiler* pComp) override;
327  void DenumeratePointers() override { Object.DenumeratePointers(); }
328  void ClearPointers(C4Object* pObj) override { if(Object == pObj) Object = nullptr; }
329 private:
330  C4ObjectPtr Object;
331 };
332 
333 // Reference another value (which is convertible to C4Real), and optionally scale it
334 template<typename SourceT>
336 {
337 public:
338  C4ValueProviderRef(const SourceT& ref, C4Real scale):
339  Ref(ref), Scale(scale) {}
340 
341  bool Execute() override
342  {
343  Value = Scale * Ref;
344  return true;
345  }
346 
347 private:
348  const SourceT& Ref;
349  C4Real Scale;
350 };
351 
352 StdMeshInstance::ValueProvider* CreateValueProviderFromArray(C4Object* pForObj, C4ValueArray& Data, const StdMeshAnimation* pos_for_animation = nullptr);
353 
354 #endif
void ClearPointers(C4Object *pObj) override
bool Execute() override
void DenumeratePointers() override
bool Execute() override
void DenumeratePointers() override
void CompileFunc(StdCompiler *pComp) override
void CompileFunc(StdCompiler *pComp) override
void CompileFunc(StdCompiler *pComp) override
void ClearPointers(C4Object *pObj) override
void CompileFunc(StdCompiler *pComp) override
bool Execute() override
void ClearPointers(C4Object *pObj) override
C4ValueProviderRef(const SourceT &ref, C4Real scale)
void CompileFunc(StdCompiler *pComp) override
void ClearPointers(C4Object *pObj) override
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:47
Definition: C4Real.h:58
void ClearPointers(C4Object *pObj) override
bool Execute() override
StdMeshInstance::ValueProvider * CreateValueProviderFromArray(C4Object *pForObj, C4ValueArray &Data, const StdMeshAnimation *pos_for_animation=nullptr)
void DenumeratePointers() override
void DenumeratePointers() override
void ClearPointers(C4Object *pObj) override
void ClearPointers(C4Object *pObj) override
bool Execute() override
void DenumeratePointers() override
void ClearPointers(C4Object *pObj) override
void ClearPointers(C4Object *pObj) override
bool Execute() override
void DenumeratePointers() override
bool Execute() override
void DenumeratePointers() override
void CompileFunc(StdCompiler *pComp) override
void ClearPointers(C4Object *pObj) override
bool Execute() override
void CompileFunc(StdCompiler *pComp) override
bool Execute() override
void CompileFunc(StdCompiler *pComp) override
void CompileFunc(StdCompiler *pComp) override
void DenumeratePointers() override
void CompileFunc(StdCompiler *pComp) override
C4AnimationValueProviderID
C4AnimationEnding
bool Execute() override
bool Execute() override
C4ValueProviderConst()=default
void ClearPointers(C4Object *pObj) override
bool Execute() override
void CompileFunc(StdCompiler *pComp) override
void DenumeratePointers() override
void CompileFunc(StdCompiler *pComp) override
void ClearPointers(C4Object *pObj) override
void DenumeratePointers() override
void DenumeratePointers() override
bool Execute() override
void CompileFunc(StdCompiler *pComp) override
bool Execute() override
void ClearPointers(C4Object *pObj) override
void DenumeratePointers() override
void CompileFunc(StdCompiler *pComp) override
bool Execute() override
void ClearPointers(C4Object *pObj) override
void DenumeratePointers() override
void ClearPointers(C4Object *pObj) override
void CompileFunc(StdCompiler *pComp) override
const C4Real Fix0
Definition: C4Real.h:312
void CompileFunc(StdCompiler *pComp) override
void DenumeratePointers() override
void DenumeratePointers() override