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:
59  virtual bool Execute();
60 };
61 
62 // Interpolate linearly in time between two values
64 {
65 public:
66  C4ValueProviderLinear(): Begin(Fix0), End(Fix0), Length(0), Ending(ANIM_Loop), LastTick(0) {}
67  C4ValueProviderLinear(C4Real pos, C4Real begin, C4Real end, int32_t length, C4AnimationEnding ending);
68  virtual bool Execute();
69 
70  virtual void CompileFunc(StdCompiler* pComp);
71 private:
72  C4Real Begin;
73  C4Real End;
74  int32_t Length;
75  C4AnimationEnding Ending;
76 
77  int32_t LastTick;
78 };
79 
81 {
82 public:
83  C4ValueProviderX(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {}
84  C4ValueProviderX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
85  virtual bool Execute();
86 
87  virtual void CompileFunc(StdCompiler* pComp);
88  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
89  virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; }
90 private:
91  C4ObjectPtr Object;
92  C4Real Begin;
93  C4Real End;
94  int32_t Length;
95 };
96 
98 {
99 public:
100  C4ValueProviderY(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {}
101  C4ValueProviderY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
102  virtual bool Execute();
103 
104  virtual void CompileFunc(StdCompiler* pComp);
105  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
106  virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; }
107 private:
108  C4ObjectPtr Object;
109  C4Real Begin;
110  C4Real End;
111  int32_t Length;
112 };
113 
115 {
116 public:
117  C4ValueProviderR(): Object(nullptr), Begin(Fix0), End(Fix0) {}
118  C4ValueProviderR(C4Object* object, C4Real begin, C4Real end);
119  virtual bool Execute();
120 
121  virtual void CompileFunc(StdCompiler* pComp);
122  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
123  virtual void ClearPointers(C4Object* pObj) { 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), Length(0) {}
134  C4ValueProviderAbsX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
135  virtual bool Execute();
136 
137  virtual void CompileFunc(StdCompiler* pComp);
138  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
139  virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; }
140 private:
141  C4ObjectPtr Object;
142  C4Real Begin;
143  C4Real End;
144  int32_t Length;
145 };
146 
148 {
149 public:
150  C4ValueProviderAbsY(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {}
151  C4ValueProviderAbsY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
152  virtual bool Execute();
153 
154  virtual void CompileFunc(StdCompiler* pComp);
155  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
156  virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; }
157 private:
158  C4ObjectPtr Object;
159  C4Real Begin;
160  C4Real End;
161  int32_t Length;
162 };
163 
165 {
166 public:
167  C4ValueProviderDist(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {}
168  C4ValueProviderDist(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length);
169  virtual bool Execute();
170 
171  virtual void CompileFunc(StdCompiler* pComp);
172  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
173  virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; }
174 private:
175  C4ObjectPtr Object;
176  C4Real Begin;
177  C4Real End;
178  int32_t Length;
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  virtual bool Execute();
187 
188  virtual void CompileFunc(StdCompiler* pComp);
189  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
190  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute();
204 
205  virtual void CompileFunc(StdCompiler* pComp);
206  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
207  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute();
221 
222  virtual void CompileFunc(StdCompiler* pComp);
223  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
224  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute();
239 
240  virtual void CompileFunc(StdCompiler* pComp);
241  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
242  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute();
257 
258  virtual void CompileFunc(StdCompiler* pComp);
259  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
260  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute();
274 
275  virtual void CompileFunc(StdCompiler* pComp);
276  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
277  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute();
291 
292  virtual void CompileFunc(StdCompiler* pComp);
293  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
294  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute();
308 
309  virtual void CompileFunc(StdCompiler* pComp);
310  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
311  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute();
325 
326  virtual void CompileFunc(StdCompiler* pComp);
327  virtual void DenumeratePointers() { Object.DenumeratePointers(); }
328  virtual void ClearPointers(C4Object* pObj) { 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  virtual bool Execute()
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
virtual bool Execute()
virtual void CompileFunc(StdCompiler *pComp)
virtual void DenumeratePointers()
virtual void DenumeratePointers()
virtual bool Execute()
virtual void ClearPointers(C4Object *pObj)
virtual bool Execute()
virtual bool Execute()
virtual bool Execute()
virtual void CompileFunc(StdCompiler *pComp)
virtual void ClearPointers(C4Object *pObj)
virtual void DenumeratePointers()
virtual void CompileFunc(StdCompiler *pComp)
virtual bool Execute()
virtual void CompileFunc(StdCompiler *pComp)
virtual void DenumeratePointers()
C4ValueProviderRef(const SourceT &ref, C4Real scale)
virtual void DenumeratePointers()
virtual bool Execute()
virtual void CompileFunc(StdCompiler *pComp)
virtual bool Execute()
virtual void ClearPointers(C4Object *pObj)
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:46
virtual void CompileFunc(StdCompiler *pComp)
Definition: C4Real.h:58
virtual void DenumeratePointers()
StdMeshInstance::ValueProvider * CreateValueProviderFromArray(C4Object *pForObj, C4ValueArray &Data, const StdMeshAnimation *pos_for_animation=nullptr)
virtual void DenumeratePointers()
virtual void ClearPointers(C4Object *pObj)
virtual void CompileFunc(StdCompiler *pComp)
virtual void DenumeratePointers()
virtual void ClearPointers(C4Object *pObj)
virtual void ClearPointers(C4Object *pObj)
virtual void CompileFunc(StdCompiler *pComp)
virtual void DenumeratePointers()
virtual bool Execute()
virtual void ClearPointers(C4Object *pObj)
virtual void CompileFunc(StdCompiler *pComp)
virtual bool Execute()
virtual void ClearPointers(C4Object *pObj)
virtual void ClearPointers(C4Object *pObj)
virtual void ClearPointers(C4Object *pObj)
virtual void DenumeratePointers()
virtual void CompileFunc(StdCompiler *pComp)
virtual void DenumeratePointers()
virtual void CompileFunc(StdCompiler *pComp)
virtual bool Execute()
virtual void CompileFunc(StdCompiler *pComp)
virtual void CompileFunc(StdCompiler *pComp)
virtual void CompileFunc(StdCompiler *pComp)
virtual bool Execute()
virtual void ClearPointers(C4Object *pObj)
virtual void CompileFunc(StdCompiler *pComp)
C4AnimationValueProviderID
C4AnimationEnding
virtual bool Execute()
virtual void CompileFunc(StdCompiler *pComp)
virtual void DenumeratePointers()
virtual void ClearPointers(C4Object *pObj)
virtual void DenumeratePointers()
virtual void DenumeratePointers()
virtual bool Execute()
virtual void ClearPointers(C4Object *pObj)
virtual void ClearPointers(C4Object *pObj)
virtual void DenumeratePointers()
virtual void ClearPointers(C4Object *pObj)
const C4Real Fix0
Definition: C4Real.h:312