resonance 1.0.1
Loading...
Searching...
No Matches
Rnd::TransAnim Class Reference

Animation that drives one transformable from three keyframe channels. More...

#include <transanim.h>

Inheritance diagram for Rnd::TransAnim:
Collaboration diagram for Rnd::TransAnim:

Classes

class  TransKey
 One keyframe of the translation or the scale channel. More...
class  RotKey
 One keyframe of the rotation channel. More...

Public Types

enum  Interp { kInterpLinear = 0 , kInterpTCB = 1 }
 Interpolation a channel applies between two keyframes. More...
enum  ShapeComponent { kShapeTension = 0 , kShapeContinuity = 1 , kShapeBias = 2 }
 Floats of a keyframe's shape triple, labelled by the dumpers at 0x004f9160. More...
Public Types inherited from Rnd::Animatable
enum  FilterType {
  kFilterScaleOffset = 0 , kFilterMinMaxLoop = 1 , kFilterZeroOrder = 2 , kFilterFirstOrder = 3 ,
  kFilterSecondOrder = 4
}
 Value a filter reports from Filter::Type() and a .rnd file stores in front of its payload. More...

Public Member Functions

 TransAnim (const HxStr &name)
 Construct an animation with no target and three empty channels that it owns.
virtual ~TransAnim ()
 Drop this object's references and every reference held on it.
virtual const HxStr & ClassName () const
 Report the registered class name, "TransAnim".
virtual float FilteredFrameEnd ()
 Report the last frame the frames owner's three channels animate to.
virtual float StartFrame ()
 Report the first frame the frames owner's three channels animate from.
virtual void DumpText (Dbg &sink)
 Write a description of this object to sink.
virtual void Save (Stream &stream)
 Write the revision, both bases, both target names, the three channels, and the flags.
virtual void Load (Stream &stream)
 Replace this object's state from stream.
virtual void Replace (Object *pFrom, Object *pTo)
 Retarget mTrans and mFramesOwner when either addresses pFrom.
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy the targets, the interpolation modes, the flags, and the channels from pSource.
void EvalFrame (float flFrame, float *pXfm, int nResetEmpty)
 Evaluate the three channels at a frame into a transform.
void Normalize ()
 Redistribute the frames owner's translation keys to an even speed.
void SetRepeatTrans (int nRepeat)
 Set whether the translation channel repeats.
void SetTrans (Transformable *pTrans)
 Make a transformable the target this animation drives.
void SetFramesOwner (TransAnim *pOwner)
 Make another animation the one whose keyframes drive this one.
TransAnim * GetFramesOwner () const
 Report the object whose keyframes drive this one.
Public Member Functions inherited from Rnd::Animatable
 Animatable ()
 Construct an animatable with no children, no filters, and a zero frame.
virtual ~Animatable ()
 Drop this object's references on its children and delete its filters.
Animatable * Parent ()
 Report the animatable that animates this one.
void AddAnim (Animatable *pAnim)
 Append pAnim to mAnims.
void RemoveAnim (Animatable *pAnim)
 Erase pAnim from mAnims.
void SetFrame (float flFrame)
 Drive this object and its whole subtree to a frame.
float UnfilterFrame (float flValue)
 Map a value back through mFilters.
void AddFilter (Filter *pFilter)
 Append an already-built filter to mFilters.
void AddScaleOffset (float flScale, float flOffset)
 Append a new ScaleOffset stage to mFilters.
void AddMinMaxLoop (float flMin, float flMax, int nLoop)
 Append a new MinMaxLoop stage to mFilters.
void AddZeroOrder (float flLevel, float flMaxDelta)
 Append a new ZeroOrder stage to mFilters.
void AddFirstOrder (float flLevel, float flRatio)
 Append a new FirstOrder stage to mFilters.
void AddSecondOrder (float flLevel, float flSpring, float flDamper)
 Append a new SecondOrder stage to mFilters.
void RemoveFilter (int nIndex)
 Delete and erase the filter at one position in mFilters.
Filter * FilterAt (int nIndex)
 Return the filter at one position in mFilters.
void SetRate (float flRate)
 Change the multiplier of the ScaleOffset stage at the front of mFilters.
void SetOffset (float flOffset)
 Change the addend of the ScaleOffset stage at the front of mFilters.
void SetLoopRange (float flMin, float flMax)
 Change both ends of the MinMaxLoop stage at the back of mFilters.
virtual void StartAnim ()
 Restart the animation of this object and its whole subtree.
void RemoveAllAnims ()
 Drop this object's reference on every mAnims entry and then empty mAnims.
Public Member Functions inherited from Rnd::Object
 Object ()
 Construct an unnamed object.
 Object (const HxStr &name)
 Construct an object and register it under name.
virtual ~Object ()
 Erase the registry entry and release the name buffer.
void SetName (const HxStr &name)
 Re-register this object under a different name.
void AddRef (Object *pReferrer)
 Register pReferrer as a store of a pointer to this object.
void RemoveRef (Object *pReferrer)
 Drop one registration made by AddRef().
Public Member Functions inherited from Rnd::Drawable
 Drawable ()
 Construct a visible drawable with no children.
virtual ~Drawable ()
 Drop this object's references on its children.
void Draw ()
 Draw this object followed by each of its children.
Drawable * Parent ()
 Report the drawable that draws this one.
void AddDraw (Drawable *pDraw, Drawable *pBefore)
 Insert pDraw into mDraws in front of pBefore.
void AddDraw (Drawable *pDraw)
 Insert pDraw at the front of mDraws.
void RemoveDraw (Drawable *pDraw)
 Erase pDraw from mDraws.
void RemoveAllDraws ()
 Empty mDraws, dropping this object's reference on every entry.
void MoveDraw (Drawable *pDraw, int nSteps)
 Move pDraw nSteps places later in mDraws, or earlier for a negative count.
virtual void SetShowing (int nShowing)
 Set whether this object draws at all.
void SetShowingRecursive (int nShowing)
 Set whether this object and every drawable beneath it in mDraws draw at all.
virtual void SetHighlight (int nHighlight)
 Set whether this object draws with its highlight treatment.
int GetHighlight () const
 Report the highlight flag.
int GetShowing () const
 Report the showing flag.
std::list< Drawable * > & GetDraws ()
 Report the child list.

Public Attributes

std::list< RotKey > mRotKeys
 The rotation keyframes, kept in frame order.
Public Attributes inherited from Rnd::Animatable
float mFilteredFrame
 The frame SetFrame() last received, after the filter chain.
Public Attributes inherited from Rnd::Object
HxStr mName
int mInternal
Public Attributes inherited from Rnd::Drawable
int mShowing

Static Public Attributes

static TransAnim *(* sNew )(const HxStr &name)
 Creator the registered "TransAnim" class builds through.

Protected Member Functions

virtual void SetFrameSelf (float flFrame)
 Write the transform this frame evaluates to into mTrans.
Protected Member Functions inherited from Rnd::Object
void ReleaseAllRefs ()
 Tell every referrer to drop its pointer to this object.
Protected Member Functions inherited from Rnd::Drawable
virtual int DrawShowing ()
 Draw this object alone.
void ReleaseDrawsRefs ()
 Drop this object's reference on every mDraws entry without emptying the list.

Additional Inherited Members

Static Public Member Functions inherited from Rnd::Animatable
static Filter * NewFilter (int nType)
 Build one default-constructed filter for a type tag.
Static Public Member Functions inherited from Rnd::Drawable
static Drawable * Find (const HxStr &name)
 Resolve a registry key to a drawable.
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs

Detailed Description

Animation that drives one transformable from three keyframe channels.

Its RTTI descriptor is at 0x008ef240. It has Rnd::Animatable as a public non-virtual base at offset 0 and Rnd::Drawable as a public non-virtual base at offset 0x18. Those two offsets pin the Animatable subobject at 0x18 bytes and place this class's members from +0x2c, Drawable occupying 0x14 bytes from +0x18. Rnd::View repeats both offsets. The Animatable size is therefore fixed from outside the class rather than from a constructor's stores.

The three channels are independent. mTransKeys and mScaleKeys store vector keyframes and mRotKeys quaternion keyframes, and each channel has its own interpolation mode. The member titles come from the text DumpText() writes, "trans:", " framesOwner:", "rotKeys:", "transKeys:", "scaleKeys:", "rotInterp:", " transInterp:", " scaleInterp:", "repeatTrans:", and " followPath:".

mFramesOwner points at the object whose keyframes this one animates from, which is normally this object itself. Replace() and Copy() both use mFramesOwner == this as the mark of an object that owns its own frames, and Replace() copies the departing owner's three lists in before taking ownership.

Member Enumeration Documentation

◆ Interp

Interpolation a channel applies between two keyframes.

Enumerator
kInterpLinear 

Straight line between the two values.

kInterpTCB 

Kochanek-Bartels spline through the stored tangents.

◆ ShapeComponent

Floats of a keyframe's shape triple, labelled by the dumpers at 0x004f9160.

Enumerator
kShapeTension 

Kochanek-Bartels tension, dumped as "t:".

kShapeContinuity 

Kochanek-Bartels continuity, dumped as "c:".

kShapeBias 

Kochanek-Bartels bias, dumped as "b:".

Constructor & Destructor Documentation

◆ TransAnim()

Rnd::TransAnim::TransAnim ( const HxStr & name)
explicit

Construct an animation with no target and three empty channels that it owns.

The translation channel starts as kInterpTCB and the other two as kInterpLinear.

Parameters
nameThe object name, passed to the Rnd::Object constructor.
Ghidra address:
NTSC-U/C: 0x004fc000
Ghidra address:
PAL: 0x0053ace8

◆ ~TransAnim()

virtual Rnd::TransAnim::~TransAnim ( )
virtual

Drop this object's references and every reference held on it.

Ghidra address:
NTSC-U/C: 0x004fbb78
Ghidra address:
PAL: 0x0053a860

Member Function Documentation

◆ ClassName()

virtual const HxStr & Rnd::TransAnim::ClassName ( ) const
virtual

Report the registered class name, "TransAnim".

Returns
The class name.
Ghidra address:
NTSC-U/C: 0x004fbf60
Ghidra address:
PAL: 0x0053ac48

Implements Rnd::Object.

◆ FilteredFrameEnd()

virtual float Rnd::TransAnim::FilteredFrameEnd ( )
virtual

Report the last frame the frames owner's three channels animate to.

Animatable vtable slot 1. Every channel is read off mFramesOwner rather than off this object, so a borrowed set of frames reports the lender's last frame. An empty channel contributes zero.

Returns
The largest last-key frame across the three channels, never below zero.
Ghidra address:
NTSC-U/C: 0x004f4020
Ghidra address:
PAL: 0x00532c58

Reimplemented from Rnd::Animatable.

◆ StartFrame()

virtual float Rnd::TransAnim::StartFrame ( )
virtual

Report the first frame the frames owner's three channels animate from.

Animatable vtable slot 4, the one virtual this class adds. Every channel is read off mFramesOwner, and an empty channel contributes zero. Rnd::Generator's path setter at 0x0045e920 calls it.

Returns
The smallest first-key frame across the three channels.
Ghidra address:
NTSC-U/C: 0x004f4188
Ghidra address:
PAL: 0x00532dc0

◆ DumpText()

virtual void Rnd::TransAnim::DumpText ( Dbg & sink)
virtual

Write a description of this object to sink.

Parameters
sinkThe diagnostic sink to write to.
Ghidra address:
NTSC-U/C: 0x004f2ab0
Ghidra address:
PAL: 0x005316a0

Reimplemented from Rnd::Animatable.

◆ Save()

virtual void Rnd::TransAnim::Save ( Stream & stream)
virtual

Write the revision, both bases, both target names, the three channels, and the flags.

The two targets are written as the names of the objects they address, so a reader has to resolve them through Rnd::TheManager. The three channels are written interleaved with the flags rather than in one block, and a reader has to expect that order.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x004f2d50
Ghidra address:
PAL: 0x00531940

Reimplemented from Rnd::Animatable.

◆ Load()

virtual void Rnd::TransAnim::Load ( Stream & stream)
virtual

Replace this object's state from stream.

A revision above the one this build writes produces the report "Can't load new TransAnim". Below revision 2 the rotation and translation keys arrive in an older form, a value and a frame each, and a channel whose interpolation reads as 0 is rebuilt from that form one key at a time, sorting the channel and rebuilding its tangents after every key. The scale channel arrives from revision 1, and the follow-path flag from revision 2. Below that the flag is derived as whether the frames owner has no rotation keys and at least two translation keys. An animation that does not own its frames then empties its own three channels.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x004f2f68
Ghidra address:
PAL: 0x00531b58

Reimplemented from Rnd::Animatable.

◆ Replace()

virtual void Rnd::TransAnim::Replace ( Object * pFrom,
Object * pTo )
virtual

Retarget mTrans and mFramesOwner when either addresses pFrom.

A null pTo against mFramesOwner is the case worth noting. Rather than dropping the pointer, this object copies the departing owner's three keyframe lists into its own and then makes itself the owner, so the animation survives the loss of the object it borrowed its timing from.

Parameters
pFromThe object being replaced.
pToThe replacement, or null.
Ghidra address:
NTSC-U/C: 0x004f28c8
Ghidra address:
PAL: 0x005314b8

Reimplemented from Rnd::Animatable.

◆ Copy()

virtual void Rnd::TransAnim::Copy ( const Object * pSource,
unsigned nFlags )
virtual

Copy the targets, the interpolation modes, the flags, and the channels from pSource.

Parameters
pSourceThe object to copy from.
nFlagsThe set of fields to copy; see kCopyShareFrames.
Ghidra address:
NTSC-U/C: 0x004f3e90
Ghidra address:
PAL: 0x00532ac8

Reimplemented from Rnd::Animatable.

◆ EvalFrame()

void Rnd::TransAnim::EvalFrame ( float flFrame,
float * pXfm,
int nResetEmpty )

Evaluate the three channels at a frame into a transform.

The keys come from mFramesOwner and the interpolation modes and flags from this object. The translation channel writes the fourth row. Outside the key range a channel clamps to its end value. With mRepeatTrans set, the frame is wrapped by the span of the translation keys and each wrap adds the chord from the first key to the last. A negative frame on a spline translation channel instead extrapolates along the first key's outgoing tangent. The wrapped frame is relative to the first key but is compared against absolute key frames. A channel whose first key is not at frame zero therefore samples a shifted segment. A repeating spline translation channel also copies the first key's outgoing tangent over the last key's incoming tangent on every call.

The basis rows come from the rotation channel, or with mFollowPath set from the direction of the translation curve against a +z reference. A follow path of fewer than two keys writes the identity basis. The scale channel then scales each basis row by one component.

Parameters
flFrameThe frame to evaluate at.
pXfmFour rows of four floats, updated in place. A channel with no keys writes nothing to its rows unless nResetEmpty is set.
nResetEmptyNon-zero to reset the rows of an empty translation or rotation channel to the identity.
Ghidra address:
NTSC-U/C: 0x004f42f0
Ghidra address:
PAL: 0x00532f28

◆ Normalize()

void Rnd::TransAnim::Normalize ( )

Redistribute the frames owner's translation keys to an even speed.

A channel of fewer than three keys is not changed. A linear channel retains its values, and each frame is set in proportion to the chord distance covered, between the first and last frames.

A spline channel is rebuilt. Its arc length is walked in parameter steps of 0.005, and a key is emitted each time another total length divided by one less than the key count has been covered. The emitted value is the straight-line blend of the two bracketing keys at the step's parameter rather than the curve position, and its shape comes from the earlier key. The emitted frames advance from one frame step rather than from the first key's frame. Each insertion sorts the new channel again and rebuilds its tangents. A walk one key short appends a copy of the last key, and a walk that arrives at the full count replaces its last key with the original last key. Any other count reports "Couldn't normalize" and does not change the channel. When an emission overshoots its target by more than 0.005 of the spacing, the routine runs again on the result.

No call site outside the routine itself survives in the shipped program. The name is inferred from the report text.

Ghidra address:
NTSC-U/C: 0x004f4c48
Ghidra address:
PAL: 0x00533880

◆ SetRepeatTrans()

void Rnd::TransAnim::SetRepeatTrans ( int nRepeat)

Set whether the translation channel repeats.

Turning repetition off sorts the frames owner's translation keys and rebuilds their tangents. The rebuild restores the incoming tangent of the last key. EvalFrame() overwrites that tangent while repetition is on. No call site survives in the shipped program, and the name is inferred from the member it sets.

Parameters
nRepeatNon-zero to repeat.
Ghidra address:
NTSC-U/C: 0x004fb7e0
Ghidra address:
PAL: 0x0053a4c8

◆ SetTrans()

void Rnd::TransAnim::SetTrans ( Transformable * pTrans)

Make a transformable the target this animation drives.

Drops this object's reference on the previous target, records the new one, and takes a reference on it. A null target clears mTrans.

Parameters
pTransThe new target, or null.
Ghidra address:
NTSC-U/C: 0x004fd000
Ghidra address:
PAL: 0x0053bce8

◆ SetFramesOwner()

void Rnd::TransAnim::SetFramesOwner ( TransAnim * pOwner)

Make another animation the one whose keyframes drive this one.

Moves this object's reference from the previous owner to the new one, and then empties this object's own channels unless it is its own owner. The routine has no caller in the shipped build. The name is inferred.

Parameters
pOwnerThe new frames owner, or null.
Ghidra address:
NTSC-U/C: 0x004fd0a0
Ghidra address:
PAL: 0x0053bd88

◆ GetFramesOwner()

TransAnim * Rnd::TransAnim::GetFramesOwner ( ) const
inline

Report the object whose keyframes drive this one.

The out-of-line copy has no callers. TnlBumpFX::Start() inlines it.

Returns
mFramesOwner, which is this object when it owns its frames.
Ghidra address:
NTSC-U/C: 0x004fbf58
Ghidra address:
PAL: 0x0053ac40

◆ SetFrameSelf()

virtual void Rnd::TransAnim::SetFrameSelf ( float flFrame)
protectedvirtual

Write the transform this frame evaluates to into mTrans.

Animatable vtable slot 3. Returns at once with no target. Reads mTrans->mLocalXfm out, evaluates over it, writes it back, and marks the target dirty, so the animation drives the local transform rather than the composed one.

Parameters
flFrameThe filtered frame to animate to.
Ghidra address:
NTSC-U/C: 0x004fd2c8
Ghidra address:
PAL: 0x0053bfb0

Reimplemented from Rnd::Animatable.

Member Data Documentation

◆ sNew

TransAnim *(* Rnd::TransAnim::sNew) (const HxStr &name)
static

Creator the registered "TransAnim" class builds through.

RegisterTransAnimClass() points it at NewTransAnim().

Ghidra address:
NTSC-U/C: 0x00706820
Ghidra address:
PAL: 0x0074a340

◆ mRotKeys

std::list<RotKey> Rnd::TransAnim::mRotKeys

The rotation keyframes, kept in frame order.

Public because TnlBumpFX::Start() at 0x0043dea8 rewrites the first key of its path's frame owner, sorts the list, and rebuilds the tangents, and the image has no accessor. +0x3c


The documentation for this class was generated from the following file: