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

Per-vertex animation of one mesh. More...

#include <meshanim.h>

Inheritance diagram for Rnd::MeshAnim:
Collaboration diagram for Rnd::MeshAnim:

Classes

struct  PointsKey
 One keyframe of the vertex position channel. More...
struct  TexsKey
 One keyframe of the first texture coordinate channel. More...
struct  ColorsKey
 One keyframe of the vertex colour channel. More...

Public Types

enum  { kSerialVersion = 0 }
 Serial version this build writes, and the highest version it loads. More...
enum  { kCopyShareKeys = 0x40 }
 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

 MeshAnim (const HxStr &name)
 Construct an animation with no keyframes that owns its own channels.
virtual ~MeshAnim ()
virtual float FilteredFrameEnd ()
 Report the frame of the last keyframe across the three channels.
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
 Return the registered class name, "MeshAnim".
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy another animation over this one.
virtual void Load (Stream &stream)
 Load the animation.
void CopyVertKeys (int nFromVert, int nToVert)
 Copy one vertex slot over another in every keyframe of all three channels.
void AppendVertKeys (int nVert)
 Append a copy of one vertex slot to every keyframe of all three channels.
void SetMesh (Mesh *pMesh)
 Change the mesh this animation deforms.
void SetKeysOwner (MeshAnim *pOwner)
 Make another animation the one whose channels 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 Attributes

std::list< PointsKey > mVertPointsKeys
 Position keyframes.
std::list< TexsKey > mVertTexsKeys
 Texture coordinate keyframes.
std::list< ColorsKey > mVertColorsKeys
 Colour keyframes.
MeshAnim * mKeysOwner
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 Member Functions

virtual void SetFrameSelf (float flFrame)
 Interpolate the three channels at a frame and write the result into the mesh.
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.
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs

Detailed Description

Per-vertex animation of one mesh.

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

  1. The Animatable subobject is 0x18 bytes and the members below start after it. The shared Rnd::Object subobject sits at +0x2c. The Object sub-vtable at 0x0081e2c0 pins the offset from outside by recording a this adjustment of -0x2c in every entry, and the creator at 0x00493a00 allocates 0x48 bytes for the whole object. The primary vtable is at 0x0081e308 and has four entries, GetTypeInfo, FilteredFrameEnd(), the inherited Rnd::Animatable::StartAnim(), and SetFrameSelf(), followed by an all-zero terminator.

Three channels animate the mesh, one for the vertex positions, one for the first texture coordinate, and one for the vertex colours. The text dump labels them "vertPointsKeys:", "vertTexsKeys:", and "vertColorsKeys:", which is where the member names come from. Each channel is a std::list of keyframes, and one keyframe stores a whole vector of per-vertex values plus the frame it applies at. A mesh anim whose keys belong to another mesh anim reads that object's channels instead of its own, the same sharing arrangement Rnd::Mesh uses for its geometry.

The dump labels the two object references "light:" and " keysOwner:". The first label is wrong in the shipped program: Replace() at 0x00486ae8 and Copy() at 0x00487288 both narrow the incoming object with the Rnd::Mesh type descriptor at 0x00492528 before storing it, and SetFrameSelf() reads mVertsOwner at +0x130 and the vertex vector at +0xe8 through it, so the field is the animated mesh. The label is a copy-paste remnant from a sibling class.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Serial version this build writes, and the highest version it loads.

Enumerator
kSerialVersion 

◆ anonymous enum

anonymous enum

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

Recovered from Copy() at 0x004872fc. The bit continues the series Rnd::Mesh reads, kCopyShareVerts through kCopyShareTransforms.

Enumerator
kCopyShareKeys 

Constructor & Destructor Documentation

◆ MeshAnim()

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

Construct an animation with no keyframes that owns its own channels.

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

◆ ~MeshAnim()

virtual Rnd::MeshAnim::~MeshAnim ( )
virtual
Ghidra address:
NTSC-U/C: 0x00493240
Ghidra address:
PAL: 0x004d10f0

Member Function Documentation

◆ FilteredFrameEnd()

virtual float Rnd::MeshAnim::FilteredFrameEnd ( )
virtual

Report the frame of the last keyframe across the three channels.

Rnd::Animatable vtable slot 1. An empty channel reports zero, and the channels read belong to mKeysOwner rather than to this object.

Returns
The largest keyframe timestamp, never below zero.
Ghidra address:
NTSC-U/C: 0x004873b0
Ghidra address:
PAL: 0x004c51d0

Reimplemented from Rnd::Animatable.

◆ DumpText()

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

Write the animation to the engine text sink.

Emits the Rnd::Object and Rnd::Animatable dumps, then the "[MeshAnim]" block. The block is suppressed while the dump level of the sink is zero or negative.

Parameters
sinkThe text sink.
Ghidra address:
NTSC-U/C: 0x00486c98
Ghidra address:
PAL: 0x004c4a68

Reimplemented from Rnd::Animatable.

◆ Save()

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

Serialise the animation.

Writes kSerialVersion, the Rnd::Animatable subobject, the mesh reference as a name, the three channels, and finally the keys owner as a name.

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

Reimplemented from Rnd::Animatable.

◆ Replace()

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

Replace one object reference with another.

Forwards to Rnd::Animatable, then swaps the mesh and the keys owner whose current value is the old object. Losing the keys owner makes this object copy the channels it was sharing and become its own owner rather than lose them.

Parameters
pFromThe object being replaced.
pToThe object to point at, which may be null.
Ghidra address:
NTSC-U/C: 0x00486ac0
Ghidra address:
PAL: 0x004c4890

Reimplemented from Rnd::Animatable.

◆ ClassName()

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

Return the registered class name, "MeshAnim".

Returns
The class name.
Ghidra address:
NTSC-U/C: 0x00493510
Ghidra address:
PAL: 0x004d13c0

Implements Rnd::Object.

◆ Copy()

virtual void Rnd::MeshAnim::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 source object, which has to be a mesh anim for the copy to have any effect.
nFlagsThe copy flags.
Ghidra address:
NTSC-U/C: 0x00487258
Ghidra address:
PAL: 0x004c5078

Reimplemented from Rnd::Animatable.

◆ Load()

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

Load the animation.

Reports "Can't load new MeshAnim" through the failure sink when the file version exceeds kSerialVersion. Object references arrive as names and resolve through Rnd::TheManager with a checked cast.

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

Reimplemented from Rnd::Animatable.

◆ CopyVertKeys()

void Rnd::MeshAnim::CopyVertKeys ( int nFromVert,
int nToVert )

Copy one vertex slot over another in every keyframe of all three channels.

The channels read and written belong to mKeysOwner. Rnd::Mesh::WeldVerts() is the only caller, which is why the method is public.

Parameters
nFromVertThe vertex slot to copy from.
nToVertThe vertex slot to copy over.
Ghidra address:
NTSC-U/C: 0x004867d8
Ghidra address:
PAL: 0x004c45a8

◆ AppendVertKeys()

void Rnd::MeshAnim::AppendVertKeys ( int nVert)

Append a copy of one vertex slot to every keyframe of all three channels.

The channels written belong to mKeysOwner. Rnd::Mesh::AssignFlatVerts() calls it on each animation of a mesh after it splits a vertex. The title is inferred.

Parameters
nVertThe vertex slot to copy.
Ghidra address:
NTSC-U/C: 0x00486900
Ghidra address:
PAL: 0x004c46d0

◆ SetMesh()

void Rnd::MeshAnim::SetMesh ( Mesh * pMesh)

Change the mesh this animation deforms.

Drops this object's reference on the previous mesh, records the new one, and takes a reference on it. HudPosition's constructor points the shared position animation at each section mesh this way. The title is inferred.

Parameters
pMeshThe new mesh, or null.
Ghidra address:
NTSC-U/C: 0x00494120
Ghidra address:
PAL: 0x004d1fd0

◆ SetKeysOwner()

void Rnd::MeshAnim::SetKeysOwner ( MeshAnim * 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. The out-of-line copy has no caller, and the title follows Rnd::LightAnim::SetKeysOwner().

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

◆ SetFrameSelf()

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

Interpolate the three channels at a frame and write the result into the mesh.

Rnd::Animatable vtable slot 3. Does nothing while mMesh is null. Each channel selects the keyframe pair bracketing the frame, clamping to the first and the last key outside the recorded range, and blends into the vertices of mMesh->mVertsOwner. Each channel then reports its own bit to Rnd::Mesh::SyncChanged().

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

Reimplemented from Rnd::Animatable.

Member Data Documentation

◆ mVertPointsKeys

std::list<PointsKey> Rnd::MeshAnim::mVertPointsKeys

Position keyframes.

The three channels are public because Rnd::Mesh::WeldVerts() resizes the vector of each key and empties a channel whose keys all match, and the image has no accessor for either.

◆ mVertTexsKeys

std::list<TexsKey> Rnd::MeshAnim::mVertTexsKeys

Texture coordinate keyframes.

◆ mVertColorsKeys

std::list<ColorsKey> Rnd::MeshAnim::mVertColorsKeys

Colour keyframes.

Animation whose channels this one reads, itself for an animation that owns its keys. Public because Rnd::Mesh::WeldVerts() reads it at 0x00483f88 to decide whether an animation may be rebuilt, and the image has no accessor for it. +0x28

◆ mKeysOwner

MeshAnim* Rnd::MeshAnim::mKeysOwner

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