wavelength 1.0.0
Loading...
Searching...
No Matches
rndtransanim.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <vector>
5
6#include "math/key.h"
7#include "math/quaternion.h"
8#include "math/transform.h"
9#include "math/vector3.h"
10#include "rnd/rndanimatable.h"
11#include "rnd/rnddrawable.h"
13
20class RndTransAnim : public RndAnimatable, public RndDrawable {
21public:
23 static constexpr int kCopyShareKeys = 0x100;
24
30
40 explicit RndTransAnim(const char *pszName);
41
48 ~RndTransAnim() override;
49
57 float EndFrame() override;
58
66 void ListAnimObjects(std::list<RndObject *> &objects) override;
67
76 int SetFrameSelf(float fFrame) override;
77
87 virtual float StartFrame();
88
96 void DumpText(PrnStream &stream) override;
97
105 void Save(BinStream &stream) override;
106
117 void Replace(RndObject *pFrom, RndObject *pTo) override;
118
126 const char *ClassName() const override {
127 return sClassName;
128 }
129
141 void Copy(const RndObject *pSource, int nFlags) override;
142
150 void Load(BinStream &stream) override;
151
160
169
183 void MakeTransform(float fFrame, Transform &xfm, int bWhole);
184
196 float PathLength(float fStart, float fEnd);
197
206 static RndObject *New(const char *pszName) {
207 return new RndTransAnim(pszName);
208 }
209
216 static const char *sClassName;
217
223 static int sRev;
224
227 return mFramesOwner;
228 }
229
231 const std::vector<Key<Quat>> &GetRotKeys() const {
232 return mRotKeys;
233 }
234
236 std::vector<Key<Quat>> &GetRotKeys() {
237 return mRotKeys;
238 }
239
241 void SetRotKeys(const std::vector<Key<Quat>> &keys) {
242 mRotKeys = keys;
243 }
244
246 const std::vector<Key<Vector3>> &GetScaleKeys() const {
247 return mScaleKeys;
248 }
249
251 std::vector<Key<Vector3>> &GetScaleKeys() {
252 return mScaleKeys;
253 }
254
256 void SetScaleKeys(const std::vector<Key<Vector3>> &keys) {
257 mScaleKeys = keys;
258 }
259
262 return mTrans;
263 }
264
266 int GetTransInterp() const {
267 return mTransInterp;
268 }
269
271 void SetTransInterp(int nTransInterp) {
272 mTransInterp = nTransInterp;
273 }
274
276 const std::vector<Key<Vector3>> &GetTransKeys() const {
277 return mTransKeys;
278 }
279
281 std::vector<Key<Vector3>> &GetTransKeys() {
282 return mTransKeys;
283 }
284
286 void SetTransKeys(const std::vector<Key<Vector3>> &keys) {
287 mTransKeys = keys;
288 }
289
290protected:
300
310
326 float SegmentLength(int nFrom, int nTo, float fStep, float fStart, float fEnd);
327
328private:
329 RndTransformable *mTrans;
330 int mTransInterp;
331 int mScaleInterp;
332 std::vector<Key<Quat>> mRotKeys;
333 std::vector<Key<Vector3>> mTransKeys;
334 std::vector<Key<Vector3>> mScaleKeys;
335 RndTransAnim *mFramesOwner;
336 int mRepeatTrans;
337 int mFollowPath;
338};
339
353void InterpVector(const std::vector<Key<Vector3>> &keys,
354 int nInterp,
355 Vector3 &out,
356 Vector3 *pTangent,
357 float fFrame);
358
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
RndAnimatable()
Construct an animatable at frame 0 without children or filters.
Definition rndanimatable.h:600
RndDrawable()
Construct a showing drawable without a highlight or children.
Definition rnddrawable.h:23
RndObject(const char *pszName)
Construct an object and register it under a name.
RndTransAnim(const char *pszName)
Construct an animation of nothing with spline translation, linear scale, and no keys.
void Save(BinStream &stream) override
Write the animation and its bases.
static RndObject * New(const char *pszName)
Create an animation.
Definition rndtransanim.h:206
RndTransformable * GetTrans() const
Definition rndtransanim.h:261
std::vector< Key< Vector3 > > & GetTransKeys()
Definition rndtransanim.h:281
void SetFramesOwner(RndTransAnim *pOwner)
Take the keys from another animation.
void Copy(const RndObject *pSource, int nFlags) override
Copy another animation and its bases.
const std::vector< Key< Quat > > & GetRotKeys() const
Definition rndtransanim.h:231
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a referenced object with another.
Interp
How the translation and scale keys interpolate.
Definition rndtransanim.h:26
@ kInterpLinear
Definition rndtransanim.h:27
@ kInterpSpline
Definition rndtransanim.h:28
RndTransAnim * GetFramesOwner() const
Definition rndtransanim.h:226
void ListAnimObjects(std::list< RndObject * > &objects) override
Add the target to a list, then the objects of the children.
static const char * sClassName
The class name a .rnd file writes, TransAnim.
Definition rndtransanim.h:216
float SegmentLength(int nFrom, int nTo, float fStep, float fStart, float fEnd)
Measure the translation path between two keys, from one position to another.
void SetTransInterp(int nTransInterp)
Definition rndtransanim.h:271
std::vector< Key< Vector3 > > & GetScaleKeys()
Definition rndtransanim.h:251
~RndTransAnim() override
Drop the references on the target and the frames owner.
void MakeTransform(float fFrame, Transform &xfm, int bWhole)
Build the transform at a frame.
const std::vector< Key< Vector3 > > & GetScaleKeys() const
Definition rndtransanim.h:246
void Load(BinStream &stream) override
Read what Save() wrote, or an earlier version of it.
void ReleaseRefs()
Drop the references on the target and the frames owner.
void SetTrans(RndTransformable *pTrans)
Set the transformable the animation drives.
static int sRev
The format version Save() writes and Load() accepts.
Definition rndtransanim.h:223
float EndFrame() override
Report the last frame of any key.
const std::vector< Key< Vector3 > > & GetTransKeys() const
Definition rndtransanim.h:276
void SetTransKeys(const std::vector< Key< Vector3 > > &keys)
Definition rndtransanim.h:286
void SetRotKeys(const std::vector< Key< Quat > > &keys)
Definition rndtransanim.h:241
void AcquireRefs()
Take references on the target and the frames owner.
static constexpr int kCopyShareKeys
The bit of the Copy() flags that shares the source's keys rather than copying them.
Definition rndtransanim.h:23
int GetTransInterp() const
Definition rndtransanim.h:266
float PathLength(float fStart, float fEnd)
Measure the length of the translation path between two frames.
int SetFrameSelf(float fFrame) override
Apply a frame to the target's local transform.
void SetScaleKeys(const std::vector< Key< Vector3 > > &keys)
Definition rndtransanim.h:256
const char * ClassName() const override
Report the class name.
Definition rndtransanim.h:126
void DumpText(PrnStream &stream) override
Write a description of the animation and its bases.
virtual float StartFrame()
Report the first frame of any key.
std::vector< Key< Quat > > & GetRotKeys()
Definition rndtransanim.h:236
Mix-in for an object with a local transform and a world transform derived from its parent's.
Definition rndtransformable.h:17
void InterpVector(const std::vector< Key< Vector3 > > &keys, int nInterp, Vector3 &out, Vector3 *pTangent, float fFrame)
Interpolate vector keys at a frame.
PrnStream & operator<<(PrnStream &stream, RndTransAnim::Interp eInterp)
Write the name of an interpolation.
One keyframe of an animation channel, a value at a frame.
Definition key.h:21
Affine transform stored as three basis rows and a translation row.
Definition transform.h:18
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:14