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

Keyframed animation of the three colours of one Rnd::Light. More...

#include <lightanim.h>

Inheritance diagram for Rnd::LightAnim:
Collaboration diagram for Rnd::LightAnim:

Public Types

enum  { kSerialVersion = 0 }
 Revision Save() writes, and the highest revision Load() accepts. More...
enum  { kCopyShareKeys = 0x02 }
 Bit of the copy flags that shares the source's keyframe channels rather than copying them. 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

 LightAnim (const HxStr &name)
 Construct an animation with three empty channels and no light, owning its keys.
virtual ~LightAnim ()
Light * GetLight ()
 Report the light this animation drives.
LightAnim * GetKeysOwner ()
 Report the animation whose channels this one reads.
void SetKeysOwner (LightAnim *pOwner)
 Make another animation the one whose channels drive this one.
virtual void DumpText (Dbg &sink)
 Write the animation to the engine text sink.
virtual void Save (Stream &stream)
 Serialise the animation.
virtual void Replace (Object *pFrom, Object *pTo)
 Retarget one object reference at another.
virtual const HxStr & ClassName () const
 Report the registered class name, "LightAnim".
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy another animation over this one.
virtual void Load (Stream &stream)
 Load the animation.
virtual float FilteredFrameEnd ()
 Report the last frame this animation runs to.
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().

Protected Member Functions

virtual void SetFrameSelf (float flFrame)
 Animate the light to a frame.
Protected Member Functions inherited from Rnd::Object
void ReleaseAllRefs ()
 Tell every referrer to drop its pointer to this object.

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.
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
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs

Detailed Description

Keyframed animation of the three colours of one Rnd::Light.

Its RTTI descriptor is at 0x008ef1f0. It has Rnd::Animatable as its one public base at offset

  1. The shared Rnd::Object subobject sits at +0x2c, an offset the -0x2c adjustment on every entry of the Object subobject table confirms. The members below therefore occupy +0x18 through +0x2b, and the Animatable subobject is the 0x18 bytes ahead of them. The creator at 0x005452d0 allocates exactly 0x48 bytes, the sum of that 0x2c and the 0x1c of the Object subobject with no surplus.

Two vtables belong to the class, each with the accessor at 0x00544940 in slot 0. The Object subobject table at 0x00829448 stores the seven Object overrides and the destructor, and the Animatable table at 0x00829490 stores FilteredFrameEnd() at slot 1 and SetFrameSelf() at slot

  1. Slot 2 still addresses the base StartAnim() at 0x0049a3b8. Restarting an animation therefore does nothing of its own here.

Three channels drive the light, and the text dump labels them "ambientKeys:", "diffuseKeys:", and "specularKeys:". SetFrameSelf() hands the three interpolated results to Rnd::Light::SetColors() in that order, which is independent confirmation of that parameter order. Each channel is a std::list of Rnd::ColorKey, the same arrangement Rnd::MatAnim and Rnd::ParticleSysAnim use, and the shared channel dump at 0x004d8de8 serves all three classes.

Keys are shared rather than copied, the same arrangement Rnd::MeshAnim uses with mKeysOwner. Both FilteredFrameEnd() and SetFrameSelf() read the channels of mKeysOwner rather than their own. An animation whose keys belong to another animation therefore reads that object's keys.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Revision Save() writes, and the highest revision Load() accepts.

Enumerator
kSerialVersion 

◆ anonymous enum

anonymous enum

Bit of the copy flags that shares the source's keyframe channels rather than copying them.

Recovered from the andi at 0x005416dc in Copy(). Rnd::MeshAnim reads bit 0x40 and Rnd::ParticleSysAnim bit 0x80 for the same purpose, so the bit is per class rather than shared across the hierarchy.

Enumerator
kCopyShareKeys 

Constructor & Destructor Documentation

◆ LightAnim()

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

Construct an animation with three empty channels and no light, owning its keys.

NewLightAnim() is the one construction site and allocates 0x48 untagged bytes before invoking it.

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

◆ ~LightAnim()

virtual Rnd::LightAnim::~LightAnim ( )
virtual
Ghidra address:
NTSC-U/C: 0x00544b10
Ghidra address:
PAL: 0x00584888

Member Function Documentation

◆ GetLight()

Light * Rnd::LightAnim::GetLight ( )

Report the light this animation drives.

The body is one load in a branch delay slot, and it is an accessor rather than an asserted member only because the image emits it out of line at its own address.

Returns
The light, or null while none is set.
Ghidra address:
NTSC-U/C: 0x00544dd0
Ghidra address:
PAL: 0x00584b48

◆ GetKeysOwner()

LightAnim * Rnd::LightAnim::GetKeysOwner ( )

Report the animation whose channels this one reads.

Returns
The keys owner, which is this object for an animation that owns its keys.
Ghidra address:
NTSC-U/C: 0x00544dd8
Ghidra address:
PAL: 0x00584b50

◆ SetKeysOwner()

void Rnd::LightAnim::SetKeysOwner ( LightAnim * pOwner)

Make another animation the one whose channels 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. No call site survives in the shipped program, and the name follows GetKeysOwner().

Parameters
pOwnerThe new keys owner, or null.
Ghidra address:
NTSC-U/C: 0x005455b8
Ghidra address:
PAL: 0x00585330

◆ DumpText()

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

Write the animation to the engine text sink.

Emits the Object and Animatable dumps, then the "[LightAnim]" block. The block is suppressed while the dump level of the sink is not positive.

Parameters
sinkThe text sink.
Ghidra address:
NTSC-U/C: 0x00541078
Ghidra address:
PAL: 0x00580d50

Reimplemented from Rnd::Animatable.

◆ Save()

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

Serialise the animation.

Writes kSerialVersion, the Rnd::Animatable subobject, mLight as a name, the three channels, and finally mKeysOwner as a name.

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

Reimplemented from Rnd::Animatable.

◆ Replace()

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

Retarget one object reference at another.

A null pTo means the animation that owned the shared keys is going away, and the three channels are taken over from that owner rather than emptied.

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

Reimplemented from Rnd::Animatable.

◆ ClassName()

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

Report the registered class name, "LightAnim".

Returns
The class name.
Ghidra address:
NTSC-U/C: 0x00544de0
Ghidra address:
PAL: 0x00584b58

Implements Rnd::Object.

◆ Copy()

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

Copy another animation over this one.

kCopyShareKeys shares the source's channels instead of copying them, and a source that is itself sharing is always shared from rather than copied.

Parameters
pSourceThe object to copy from.
nFlagsThe set of fields to copy.
Ghidra address:
NTSC-U/C: 0x00541638
Ghidra address:
PAL: 0x00581360

Reimplemented from Rnd::Animatable.

◆ Load()

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

Load the animation.

A revision above 0 produces the report "Can't load new LightAnim" and no further reading.

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

Reimplemented from Rnd::Animatable.

◆ FilteredFrameEnd()

virtual float Rnd::LightAnim::FilteredFrameEnd ( )
virtual

Report the last frame this animation runs to.

Rnd::Animatable vtable slot 1. Each channel of mKeysOwner contributes the frame of its last key, or zero while it is empty, and the result is the largest of the three through two nested std::max calls. The pair of selected stack addresses rather than selected values proves the two calls.

Returns
The last frame.
Ghidra address:
NTSC-U/C: 0x00541790
Ghidra address:
PAL: 0x005814b8

Reimplemented from Rnd::Animatable.

◆ SetFrameSelf()

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

Animate the light to a frame.

Rnd::Animatable vtable slot 3. Returns at once while mLight is null. Otherwise it seeds three local colours from the current ambient, diffuse, and specular of the light, then replaces each from its channel of mKeysOwner. A frame at or before the first key takes that key, a frame at or after the last key takes that key, and a frame between two keys takes the linear blend of the pair on VU0. An empty channel is skipped, which retains the light's own colour. Rnd::Light::SetColors() receives the three results.

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

Reimplemented from Rnd::Animatable.


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