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

Animation of the colours and the texture stages of one material. More...

#include <matanim.h>

Inheritance diagram for Rnd::MatAnim:
Collaboration diagram for Rnd::MatAnim:

Classes

class  Stage
 Animation of one texture stage of the material. More...

Public Types

enum  { kSerialVersion = 2 }
 Revision Save() writes, and the highest revision Load() accepts. More...
enum  { kCopyShareKeys = 0x04 }
 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

 MatAnim (const HxStr &name)
 Construct an animation with five empty channels, no stages, and no material.
virtual ~MatAnim ()
 Drop every reference this animation holds and every reference held on it.
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)
 Replace one object reference with another.
virtual const HxStr & ClassName () const
 Report the registered class name, "MatAnim".
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.
void SetMat (Mat *pMat)
 Change the material this animation drives.
void SetKeysOwner (MatAnim *pOwner)
 Change the animation whose channels this one reads.
void SetNumStages (int nCount)
 Resize the stage vector of the keys owner.
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().

Static Public Attributes

static HxStr sClassName
 Registered class name of Rnd::MatAnim, the string "MatAnim".

Protected Member Functions

virtual void SetFrameSelf (float flFrame)
 Apply the animation at 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

Animation of the colours and the texture stages of one material.

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

  1. The constructor pins the Animatable subobject at 0x18 bytes from inside by storing the primary vtable pointer at +0x14 and the two Animatable lists at +0x04 and +0x08. The members below therefore start at +0x18, the MatAnim subobject is 0x40 bytes, and the shared Rnd::Object subobject sits at +0x40. The creator at 0x004dcb00 allocates exactly 0x5c bytes, the 0x40 plus the 0x1c of the Object subobject with no surplus. The -0x40 adjustment on every entry of the Object subobject table confirms the offset from outside.

Two vtables belong to the class, each with the type function at 0x004dbf10 in slot 0. The Object subobject table at 0x00822d68 stores the destructor and the seven Object overrides, and the primary table at 0x00822db0 stores FilteredFrameEnd() at slot 1 and SetFrameSelf(float) at slot 3, followed by an all-zero terminator. Slot 2 still addresses the base Rnd::Animatable::StartAnim() at 0x0049a3b8, so restarting an animation does nothing of its own here.

Five channels animate the four material colours and the alpha, and the stage vector animates the texture stages one for one against the material's own stages. Two independent readings agree on which colour each channel drives. The text dump labels them " diffuseKeys:", "ambientKeys", "emissiveKeys: ", "specularKeys:", and "alphaKeys:" in offset order. And SetFrameSelf() hands each interpolated result to the material through vtable slot 10, slot 9, slot 11, slot 13, and slot 12 respectively, which are Rnd::Mat::SetDiffuse(), SetAmbient(), SetEmissive(), SetSpecular(), and SetAlpha() in the declaration order of src/rnd/mat.h.

Keys are shared rather than copied, the same arrangement Rnd::MeshAnim uses with mKeysOwner. FilteredFrameEnd() and SetFrameSelf() read the channels of mKeysOwner rather than their own.

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 0x004dd404 in Copy(). Rnd::MeshAnim reads bit 0x40, Rnd::LightAnim bit 0x02, 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

◆ MatAnim()

Rnd::MatAnim::MatAnim ( const HxStr & name)

Construct an animation with five empty channels, no stages, and no material.

The animation owns its keys from the start, so mKeysOwner is this object.

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

◆ ~MatAnim()

virtual Rnd::MatAnim::~MatAnim ( )
virtual

Drop every reference this animation holds and every reference held on it.

Ghidra address:
NTSC-U/C: 0x004dc0c8
Ghidra address:
PAL: 0x0051a668

Member Function Documentation

◆ DumpText()

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

Write the animation to the engine text sink.

Emits the Rnd::Object and Rnd::Animatable dumps, then the "[MatAnim]" block with the material, the stage vector, the keys owner, and the five channels. The block is suppressed while the dump level of the sink is not positive.

Parameters
sinkThe text sink.
Ghidra address:
NTSC-U/C: 0x004d33b8
Ghidra address:
PAL: 0x00511858

Reimplemented from Rnd::Animatable.

◆ Save()

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

Serialise the animation.

Writes kSerialVersion, the Rnd::Animatable subobject, mMat as a name, the stage vector, mKeysOwner as a name, and finally the five channels.

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

Reimplemented from Rnd::Animatable.

◆ Replace()

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

Replace one object reference with another.

The material, the keys owner, and every stage texture that is pFrom move to pTo. A null pTo for the keys owner copies the owner's stage vector and makes this animation its own owner, but the five colour and alpha channels are not copied. A stage texture key left null is erased.

Parameters
pFromThe object being replaced.
pToThe replacement, which may be null.
Ghidra address:
NTSC-U/C: 0x004d30c8
Ghidra address:
PAL: 0x00511568

Reimplemented from Rnd::Animatable.

◆ ClassName()

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

Report the registered class name, "MatAnim".

Returns
The class name.
Ghidra address:
NTSC-U/C: 0x004dc4e0
Ghidra address:
PAL: 0x0051aa80

Implements Rnd::Object.

◆ Copy()

virtual void Rnd::MatAnim::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. Unlike its three sibling classes this one has no mKeysOwner != this test around the clear, because ClearKeys() performs that test itself.

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

Reimplemented from Rnd::Animatable.

◆ Load()

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

Load the animation.

The revision is read into Rnd::g_nRndMatLoadVersion, the material's global, and the stage records consult it there. A revision above kSerialVersion is reported to the failure sink and nothing more is read. The five channels are present from revision 2.

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

Reimplemented from Rnd::Animatable.

◆ FilteredFrameEnd()

virtual float Rnd::MatAnim::FilteredFrameEnd ( )
virtual

Report the last frame this animation runs to.

Rnd::Animatable vtable slot 1. Every channel of every stage of mKeysOwner and then each of the five colour and alpha channels contributes the frame of its last key, or zero while it is empty, and the result is the largest across all of them. The walk threads one running maximum through nested std::max calls, and the selected stack addresses rather than selected values prove that each pair is a call.

Returns
The last frame.
Ghidra address:
NTSC-U/C: 0x004d42f0
Ghidra address:
PAL: 0x005127e0

Reimplemented from Rnd::Animatable.

◆ SetMat()

void Rnd::MatAnim::SetMat ( Mat * pMat)

Change the material this animation drives.

Drops this object's reference on the previous material, records the new one, and takes a reference on it. The head-up display's FreQ icon points one shared pulse animation at its own material this way before every frame. The title is inferred.

Parameters
pMatThe new material, or null.
Ghidra address:
NTSC-U/C: 0x004dd2d8
Ghidra address:
PAL: 0x0051b878

◆ SetKeysOwner()

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

Change the animation whose channels this one reads.

Moves this object's reference from the previous owner to the new one and then empties this animation'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 keys owner, or null.
Ghidra address:
NTSC-U/C: 0x004dd328
Ghidra address:
PAL: 0x0051b8c8

◆ SetNumStages()

void Rnd::MatAnim::SetNumStages ( int nCount)

Resize the stage vector of the keys owner.

Every texture of a stage past the new count drops this animation's reference first. After the resize every stage records this animation as its owner. The routine has no caller in the shipped build. The name is inferred.

Parameters
nCountThe new stage count.
Ghidra address:
NTSC-U/C: 0x004d3b58
Ghidra address:
PAL: 0x00512048

◆ SetFrameSelf()

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

Apply the animation at a frame.

Rnd::Animatable vtable slot 3. Nothing happens without a material. The stage half walks the stages of mKeysOwner against mMat->mStages, bounded by both counts. Per stage, the translation writes the last transform row, the rotation rebuilds the basis through Rnd::MakeRotMatrix(), the scale folds into it through Rnd::Scale(), and the texture channel replaces the stage texture. The vector blends write three components and take the fourth word from the later key.

The colour half hands each blended colour to the material through its setters. The specular call passes an alpha of zero, which clear f12 at 0x004d54ec proves, and the alpha channel interpolates linearly rather than on VU0. Any empty channel leaves its target as it was.

Parameters
flFrameThe frame to apply.
Ghidra address:
NTSC-U/C: 0x004d4820
Ghidra address:
PAL: 0x00512d10

Reimplemented from Rnd::Animatable.

Member Data Documentation

◆ sClassName

HxStr Rnd::MatAnim::sClassName
static

Registered class name of Rnd::MatAnim, the string "MatAnim".

A static constructor fills the string from the literal at 0x00822e68.

Ghidra address:
NTSC-U/C: 0x00700428
Ghidra address:
PAL: 0x00743e50

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