40 virtual float Apply(
float fValue) = 0;
97 float Apply(
float fValue)
override {
98 return (fValue * mScale) + mOffset;
110 return (fValue - mOffset) / mScale;
165 *
this = *
static_cast<const ScaleOffset *
>(pSource);
235 const char bLoop =
static_cast<char>(mLoop);
236 stream.
Write(&bLoop,
sizeof(bLoop));
250 stream.
Read(&bLoop,
sizeof(bLoop));
273 *
this = *
static_cast<const MinMaxLoop *
>(pSource);
350 stream.
ReadEndian(&mMaxDelta,
sizeof(mMaxDelta));
372 *
this = *
static_cast<const ZeroOrder *
>(pSource);
391 float Apply(
float fValue)
override {
392 mLevel += (fValue - mLevel) * mRatio;
405 return (mLevel - (fValue * mRatio)) / (1.0f - mRatio);
460 *
this = *
static_cast<const FirstOrder *
>(pSource);
555 *
this = *
static_cast<const SecondOrder *
>(pSource);
804 if (pAnimatable ==
nullptr) {
808 objects.push_back(pChild);
837 const std::list<RndAnimatable *> &
GetAnims()
const {
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
void ReadEndian(void *pData, int nBytes)
Read a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
virtual void Read(void *pData, int nBytes)=0
Read bytes.
virtual void Write(const void *pData, int nBytes)=0
Write bytes.
void WriteEndian(const void *pData, int nBytes)
Write a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
Text output stream.
Definition prnstream.h:16
One stage of the frame filter chain.
Definition rndanimatable.h:32
virtual float Apply(float fValue)=0
Filter a frame.
virtual float Unapply(float fValue)=0
Undo Apply() as far as the stage allows.
virtual int Type()=0
Report the type tag.
virtual void Print(PrnStream &stream) const =0
Write the parameters.
virtual void Load(BinStream &stream)=0
Read what Save() wrote.
virtual void Save(BinStream &stream)=0
Write the parameters.
virtual void Copy(const Filter *pSource)=0
Copy the parameters of a stage of the same type.
Stage that moves the level toward the frame by a fixed ratio of the gap.
Definition rndanimatable.h:381
float Unapply(float fValue) override
Report the frame that leads from the level to a filtered frame.
Definition rndanimatable.h:404
int Type() override
Report the type tag.
Definition rndanimatable.h:448
void Print(PrnStream &stream) const override
Write the level and the ratio.
void Save(BinStream &stream) override
Write the level and the ratio.
Definition rndanimatable.h:424
void Copy(const Filter *pSource) override
Copy another stage.
Definition rndanimatable.h:459
float Apply(float fValue) override
Move the level toward a frame.
Definition rndanimatable.h:391
void Load(BinStream &stream) override
Read the level and the ratio.
Definition rndanimatable.h:436
Stage that clamps the frame to a range, or wraps it around the range.
Definition rndanimatable.h:194
void Save(BinStream &stream) override
Write the range and the loop flag.
Definition rndanimatable.h:232
void Load(BinStream &stream) override
Read the range and the loop flag.
Definition rndanimatable.h:246
void SetLoop(int nLoop)
Definition rndanimatable.h:287
void SetMin(float fMin)
Definition rndanimatable.h:277
void SetMax(float fMax)
Definition rndanimatable.h:282
float Apply(float fValue) override
Clamp or wrap a frame.
void Print(PrnStream &stream) const override
Write the range and the loop flag.
void Copy(const Filter *pSource) override
Copy another stage.
Definition rndanimatable.h:272
int Type() override
Report the type tag.
Definition rndanimatable.h:261
float Unapply(float fValue) override
Report the frame unchanged.
Stage that scales the frame and adds an offset.
Definition rndanimatable.h:87
void SetOffset(float fOffset)
Definition rndanimatable.h:169
void Load(BinStream &stream) override
Read the scale and the offset.
Definition rndanimatable.h:141
void SetScale(float fScale)
Definition rndanimatable.h:184
int Type() override
Report the type tag.
Definition rndanimatable.h:153
float Apply(float fValue) override
Scale and offset a frame.
Definition rndanimatable.h:97
float Unapply(float fValue) override
Remove the offset and the scale.
Definition rndanimatable.h:109
float GetScale() const
Definition rndanimatable.h:179
float GetOffset() const
Definition rndanimatable.h:174
void Print(PrnStream &stream) const override
Write the scale and the offset.
void Copy(const Filter *pSource) override
Copy another stage.
Definition rndanimatable.h:164
void Save(BinStream &stream) override
Write the scale and the offset.
Definition rndanimatable.h:129
SecondOrder()
Construct a stage at rest.
Definition rndanimatable.h:476
int Type() override
Report the type tag.
Definition rndanimatable.h:543
void Load(BinStream &stream) override
Read the level, the spring, and the damper.
Definition rndanimatable.h:530
float GetVel() const
Definition rndanimatable.h:569
void Copy(const Filter *pSource) override
Copy another stage.
Definition rndanimatable.h:554
void Print(PrnStream &stream) const override
Write the level, the spring, the damper, and the velocity.
void SetSpring(float fSpring)
Definition rndanimatable.h:579
void SetLevel(float fLevel)
Definition rndanimatable.h:564
float Unapply(float fValue) override
Report the level one step back.
void SetDamper(float fDamper)
Definition rndanimatable.h:584
void Save(BinStream &stream) override
Write the level, the spring, and the damper.
Definition rndanimatable.h:517
void SetVel(float fVel)
Definition rndanimatable.h:574
float Apply(float fValue) override
Advance the spring toward a frame.
float GetLevel() const
Definition rndanimatable.h:559
Stage that follows the frame by at most a fixed step a call.
Definition rndanimatable.h:298
int Type() override
Report the type tag.
Definition rndanimatable.h:360
float Unapply(float fValue) override
Report the level one step back from a frame.
void Load(BinStream &stream) override
Read the level and the step.
Definition rndanimatable.h:348
float Apply(float fValue) override
Step the level toward a frame.
void Save(BinStream &stream) override
Write the level and the step.
Definition rndanimatable.h:336
void Copy(const Filter *pSource) override
Copy another stage.
Definition rndanimatable.h:371
void Print(PrnStream &stream) const override
Write the level and the step.
RndAnimatable()
Construct an animatable at frame 0 without children or filters.
Definition rndanimatable.h:600
virtual float EndFrame()
Report the frame at which the animation ends.
float mFrame
Definition rndanimatable.h:871
float mFilteredFrame
Definition rndanimatable.h:873
float GetFrame() const
Definition rndanimatable.h:827
RndAnimatable * Parent()
Find the animatable whose children include this one.
void Load(BinStream &stream) override
Read what Save() wrote.
~RndAnimatable() override
Drop the references on the children and delete the filters.
void AcquireAnimRefs()
Take a reference on every child.
const std::list< Filter * > & GetFilters() const
Definition rndanimatable.h:822
std::list< Filter * > & GetFilters()
Definition rndanimatable.h:842
static void CollectChildren(std::list< RndObject * > &objects, RndAnimatable *pAnimatable)
Append every animation descendant of an animatable, depth first, each before its descendants.
Definition rndanimatable.h:803
float GetFilteredFrame() const
Definition rndanimatable.h:832
void RemoveAllAnims()
Remove every child.
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a child with another object.
static int sRev
The format version Save() writes and Load() accepts.
Definition rndanimatable.h:819
void RemoveAnim(RndAnimatable *pAnim)
Remove a child.
void ReleaseObjects()
Drop the references on the children without emptying the list, and delete the filters.
std::list< RndAnimatable * > mAnims
Definition rndanimatable.h:867
void DumpText(PrnStream &stream) override
Write a description of the animatable.
void Copy(const RndObject *pSource, int nFlags) override
Copy the filters, and the children when the flags request them.
float ChildrenEndFrame()
Report the latest end frame of the children, unfiltered through this animatable.
float UnfilterFrame(float fValue)
Run a filtered frame back through the filters, last first.
float FilterFrame(float fValue)
Run a frame through the filters.
void SetFrame(float fFrame)
Filter a frame, apply it, and pass the result on to the children.
virtual int SetFrameSelf(float fFrame)
Apply a filtered frame to this object alone.
Definition rndanimatable.h:643
void Save(BinStream &stream) override
Write the filters and the names of the children.
bool AddAnim(RndAnimatable *pAnim)
Append a child.
std::list< Filter * > mFilters
Definition rndanimatable.h:869
virtual void ListAnimObjects(std::list< RndObject * > &objects)
Add the objects the animation uses to a list.
FilterType
The type tags of the filters, as Save() writes them.
Definition rndanimatable.h:19
@ kFilterFirstOrder
Definition rndanimatable.h:23
@ kFilterZeroOrder
Definition rndanimatable.h:22
@ kFilterSecondOrder
Definition rndanimatable.h:24
@ kFilterScaleOffset
Definition rndanimatable.h:20
@ kFilterMinMaxLoop
Definition rndanimatable.h:21
const std::list< RndAnimatable * > & GetAnims() const
Definition rndanimatable.h:837
static Filter * NewFilter(int nType)
Create a filter stage of a type, with its parameters unset.
RndObject(const char *pszName)
Construct an object and register it under a name.
PrnStream & operator<<(PrnStream &stream, RndAnimatable::Filter *pFilter)
Write a filter stage as its type tag and its parameters.
BinStream & operator>>(BinStream &stream, RndAnimatable::Filter *&pFilter)
Read a filter stage as its type tag and its parameters.