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

Mix-in for an object with a local and a world transform. More...

#include <transformable.h>

Inheritance diagram for Rnd::Transformable:
Collaboration diagram for Rnd::Transformable:

Public Types

enum  Billboard {
  kBillboardNone = 0 , kBillboardX = 1 , kBillboardY = 2 , kBillboardZ = 4 ,
  kBillboardXZ = 8 , kBillboardXYZ = 16 , kBillboardSimpleXYZ = 32 , kBillboardLocalRotate = 64 ,
  kBillboardScaleX = 129 , kBillboardScaleY = 130 , kBillboardScaleZ = 132 , kBillboardScaleXZ = 136 ,
  kBillboardScaleXYZ = 144 , kBillboardScaleSimpleXYZ = 160
}
 Mode mBillboard selects, recovered from the name dumper at 0x004f26f0. More...

Public Member Functions

 Transformable ()
 Construct a dirty transformable with identity transforms and no children.
virtual ~Transformable ()
 Drop this object's references on its children.
void AddTrans (Transformable *pTrans)
 Append pTrans to mTransList and mark it dirty.
void RemoveTrans (Transformable *pTrans)
 Erase pTrans from mTransList.
void RemoveAllTranses ()
 Drop this object's reference on every mTransList entry and empty the list.
virtual void DumpText (Dbg &sink)
 Write a description of this object to sink.
virtual void Save (Stream &stream)
 Write the revision, both transforms, mTransList, mBillboard, and mOrigin to stream.
virtual void Load (Stream &stream)
 Replace both transforms, mTransList, mBillboard, and mOrigin from stream.
virtual void Replace (Object *pFrom, Object *pTo)
 Retarget every mTransList entry equal to pFrom at pTo.
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy both transforms, mBillboard, and mOrigin from pSource.
Transformable * Parent ()
 Report the transformable that positions this one.
virtual void SetBillboard (int nBillboard)
 Set the billboard mode and mark the transform dirty.
virtual int UpdateWorldXfm (Transformable *pParent, int nForce)
 Compose mWorldXfm from mLocalXfm and the parent's world transform.
void SetOrigin (const float *pOrigin)
 Set the origin row and mark the transform dirty.
float * GetDrawXfm ()
 Build the transform this object draws with and return it.
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().
virtual const HxStr & ClassName () const =0
 Report the name of this object's most derived class.

Public Attributes

float mLocalXfm [kXfmRowCount][kXfmRowFloatCount]
 Transform this object is positioned by, before the parent transform is applied.
float mWorldXfm [kXfmRowCount][kXfmRowFloatCount]
 Composed world transform.
int mDirty
 Set by every writer of a transform field and cleared once UpdateWorldXfm has recomposed.
Public Attributes inherited from Rnd::Object
HxStr mName
int mInternal

Protected Member Functions

void AdoptXfmFrom (const Transformable &owner)
 Adopt the transform of an owner this object is being detached from.
void ReleaseTransRefs ()
 Drop this object's reference on every mTransList entry without emptying the list.
Protected Member Functions inherited from Rnd::Object
void ReleaseAllRefs ()
 Tell every referrer to drop its pointer to this object.

Protected Attributes

float mOrigin [kXfmRowFloatCount]
int mBillboard
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs

Friends

class ::MetRenderer
void CollectChildren (std::list< Object * > &objects, Transformable *pTransformable)
 Append every transform descendant of a transformable.

Detailed Description

Mix-in for an object with a local and a world transform.

Its RTTI descriptor is at 0x008ef770. It has Rnd::Object as a public virtual base at offset

  1. The subobject is 0xac bytes: the virtual-base pointer at +0x00, mTransList at +0x04, two unrecovered fields at +0x08 and +0x0c, the two transforms, the origin, mDirty at +0xa0, mBillboard at +0xa4, and the vptr at +0xa8. Rnd::View confirms the vptr offset by placing its Transformable subobject at +0x30 and writing that vptr to View + 0xd8.

Each transform is four consecutive 16-byte rows of an x, a y, and a z float followed by four bytes of padding, which is the layout the VU units read. The member titles come from the text DumpText() writes, "localXfm:", "worldXfm:", "transList:", "billboard:", and " origin:".

The class declares two virtuals of its own beyond the compiler-generated slot 0, SetBillboard at slot 1 and UpdateWorldXfm at slot 2.

Rnd::Cam, Rnd::Mesh, Rnd::View, and Rnd::Arena each place their next base immediately after this subobject, at a distance of 0xb0 bytes from its start, which pins the size from outside the class rather than from the highest store of a constructor. The 0xac the members occupy rounds up to 0xb0 under the 16-byte alignment the transform rows impose.

Member Enumeration Documentation

◆ Billboard

Mode mBillboard selects, recovered from the name dumper at 0x004f26f0.

The low bits select an axis set and bit 0x80 adds the scaling variant of the same set, so the fourteen values below are the whole set the dumper recognises. A value outside it produces no text at all rather than a fallback.

Enumerator
kBillboardNone 

No billboarding.

kBillboardX 

Face the camera about x.

kBillboardY 

Face the camera about y.

kBillboardZ 

Face the camera about z.

kBillboardXZ 

Face the camera about x and z.

kBillboardXYZ 

Face the camera about all three axes.

kBillboardSimpleXYZ 

Face the camera with the cheaper orientation.

kBillboardLocalRotate 

Rotate about the local axes instead.

kBillboardScaleX 

kBillboardX with the scale preserved.

kBillboardScaleY 

kBillboardY with the scale preserved.

kBillboardScaleZ 

kBillboardZ with the scale preserved.

kBillboardScaleXZ 

kBillboardXZ with the scale preserved.

kBillboardScaleXYZ 

kBillboardXYZ with the scale preserved.

kBillboardScaleSimpleXYZ 

kBillboardSimpleXYZ with the scale preserved.

Constructor & Destructor Documentation

◆ Transformable()

Rnd::Transformable::Transformable ( )

Construct a dirty transformable with identity transforms and no children.

Both transforms become the identity, mOrigin becomes (0, 0, 0, 1), and mBillboard becomes kBillboardNone. Every row is first built with a padding float of 1.0.

Ghidra address:
NTSC-U/C: 0x004fb3f8
Ghidra address:
PAL: 0x0053a0d8

◆ ~Transformable()

virtual Rnd::Transformable::~Transformable ( )
virtual

Drop this object's references on its children.

Ghidra address:
NTSC-U/C: 0x004fb2a8
Ghidra address:
PAL: 0x00539f88

Member Function Documentation

◆ AddTrans()

void Rnd::Transformable::AddTrans ( Transformable * pTrans)

Append pTrans to mTransList and mark it dirty.

Registers this object as a referrer of pTrans. A pTrans already in mTransList produces the report "%s already in %s" and no insertion.

Parameters
pTransThe transformable to position from this one.
Ghidra address:
NTSC-U/C: 0x004f0838
Ghidra address:
PAL: 0x0052f428

◆ RemoveTrans()

void Rnd::Transformable::RemoveTrans ( Transformable * pTrans)

Erase pTrans from mTransList.

Drops this object's reference on pTrans first. A pTrans absent from mTransList does nothing.

Parameters
pTransThe transformable to remove.
Ghidra address:
NTSC-U/C: 0x004f09c0
Ghidra address:
PAL: 0x0052f5b0

◆ RemoveAllTranses()

void Rnd::Transformable::RemoveAllTranses ( )

Drop this object's reference on every mTransList entry and empty the list.

Ghidra address:
NTSC-U/C: 0x004f0a80
Ghidra address:
PAL: 0x0052f670

◆ DumpText()

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

Write a description of this object to sink.

Writes both transforms a row at a time, then mTransList, mBillboard, and mOrigin. Produces nothing at all when the dump level of sink is not positive. Dbg::Print() discards its text in the shipped build, so the routine produces no output on this target.

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

Reimplemented from Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.

◆ Save()

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

Write the revision, both transforms, mTransList, mBillboard, and mOrigin to stream.

Each transform row writes only its first three floats, so the padding word is not stored.

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

Implements Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.

◆ Load()

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

Replace both transforms, mTransList, mBillboard, and mOrigin from stream.

A revision above the one this build writes produces the report "Can't load new Transformable". Revisions below 3 store a legacy billboard index the reader maps through a table, and revisions below 1 store neither the billboard nor the origin.

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

Implements Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.

◆ Replace()

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

Retarget every mTransList entry equal to pFrom at pTo.

An entry that already equals pTo produces the report "%s already in %s" without stopping the walk. An entry that ends up null is erased.

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

Implements Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.

◆ Copy()

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

Copy both transforms, mBillboard, and mOrigin from pSource.

mDirty is not copied. AcquireTransRefs() sets it instead, so a copied object always recomposes once.

Parameters
pSourceThe object to copy from.
nFlagsThe set of fields to copy; see kCopyChildLists.
Ghidra address:
NTSC-U/C: 0x004fce30
Ghidra address:
PAL: 0x0053bb18

Implements Rnd::Object.

Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.

◆ Parent()

Transformable * Rnd::Transformable::Parent ( )

Report the transformable that positions this one.

Walks the referrer list of the Rnd::Object subobject, casts each referrer to Transformable and returns the first whose own mTransList includes this object, which makes the result the parent in the transform hierarchy rather than a plain cast.

Returns
The parent transformable, or null when no referrer positions this one.
Ghidra address:
NTSC-U/C: 0x004f0770
Ghidra address:
PAL: 0x0052f360

◆ SetBillboard()

virtual void Rnd::Transformable::SetBillboard ( int nBillboard)
virtual

Set the billboard mode and mark the transform dirty.

Vtable slot 1.

Parameters
nBillboardThe billboard mode.
Ghidra address:
NTSC-U/C: 0x004fce08
Ghidra address:
PAL: 0x0053baf0

Reimplemented in Rnd::Text.

◆ UpdateWorldXfm()

virtual int Rnd::Transformable::UpdateWorldXfm ( Transformable * pParent,
int nForce )
virtual

Compose mWorldXfm from mLocalXfm and the parent's world transform.

Vtable slot 2. Returns at once when nForce is clear, mDirty is clear, and the parent is either absent or clean. Recurses over mTransList with the same call once it has recomposed.

Two independent arguments fix the return. The final exit at 0x004f0ca4 loads mDirty into the return register and only then clears it, so the value handed back is the flag as it stood on entry. Rnd::Cam's override at 0x004b1fa0 then calls this implementation, branches on the result with beq v0,zero, runs its own projection rebuild only on the non-zero path, and normalises its own answer to 1 or 0.

Parameters
pParentThe transformable this one hangs off, or null for a root.
nForceNon-zero to recompose even when nothing is marked dirty.
Returns
Non-zero when the world transform was recomposed.
Ghidra address:
NTSC-U/C: 0x004f0b18
Ghidra address:
PAL: 0x0052f708

Reimplemented in Rnd::Arena, Rnd::Cam, and Rnd::Text.

◆ SetOrigin()

void Rnd::Transformable::SetOrigin ( const float * pOrigin)

Set the origin row and mark the transform dirty.

The row is copied as one 128-bit quadword, so pOrigin has to be 16-byte aligned.

Parameters
pOriginFour floats, of which the first three are x, y, and z.
Ghidra address:
NTSC-U/C: 0x004fce18
Ghidra address:
PAL: 0x0053bb00

◆ GetDrawXfm()

float * Rnd::Transformable::GetDrawXfm ( )

Build the transform this object draws with and return it.

With mBillboard clear, or with no current camera, the four mWorldXfm rows are copied out unchanged. Otherwise the basis rows are rebuilt to face Cam::sCurrent about the axes the mode selects, and kBillboardSimpleXYZ takes the camera's basis outright. A scaling mode divides the world scale out first and multiplies it back afterwards. The translation then moves by mOrigin, negated and transformed by the new basis. Modes outside the six named axis sets, kBillboardLocalRotate among them, retain the world basis and take only the origin.

The result is the one shared scratch buffer g_drawXfm. It is valid only until the next call.

Returns
The shared draw transform, four rows of four floats.
Ghidra address:
NTSC-U/C: 0x004f0cc0
Ghidra address:
PAL: 0x0052f8b0

◆ AdoptXfmFrom()

void Rnd::Transformable::AdoptXfmFrom ( const Transformable & owner)
protected

Adopt the transform of an owner this object is being detached from.

Takes the owner's composed world transform as this object's local transform and recomposes, which preserves the world position the owner was placing this object at, then takes the owner's own local transform, billboard mode, and origin and recomposes again.

The compiler inlined this at 0x00482c20 through 0x00482cd4 inside Rnd::Mesh::Replace, its only call site, so no out-of-line body exists and the title is inferred. The alternative reading is that the five transform fields were public and Mesh performed the sequence itself; the image cannot separate the two, and this one preserves the narrower access.

Parameters
ownerThe transformable being detached from.

◆ ReleaseTransRefs()

void Rnd::Transformable::ReleaseTransRefs ( )
protected

Drop this object's reference on every mTransList entry without emptying the list.

Protected rather than private because every destructor of a derived class invokes it directly, twenty call sites among them Rnd::Mesh, Rnd::Cam, Rnd::View, Rnd::Light, and Rnd::ParticleSys.

Ghidra address:
NTSC-U/C: 0x004fcf18
Ghidra address:
PAL: 0x0053bc00

◆ ::MetRenderer

friend class ::MetRenderer
friend

◆ CollectChildren

void CollectChildren ( std::list< Object * > & objects,
Transformable * pTransformable )
friend

Append every transform descendant of a transformable.

Parameters
objectsThe list to append to.
pTransformableThe transformable to start from, or null.
Ghidra address:
NTSC-U/C: 0x0051a310
Ghidra address:
PAL: 0x0055a708

Member Data Documentation

◆ mLocalXfm

float Rnd::Transformable::mLocalXfm[kXfmRowCount][kXfmRowFloatCount]

Transform this object is positioned by, before the parent transform is applied.

Public rather than protected because Rnd::TransAnim::SetFrameSelf at 0x004fd2c8 reads all four rows out of its target and writes the interpolated rows back, and TransAnim derives from Animatable and Drawable rather than from this class. A friend declaration would fit the image equally well; public asserts the weaker of the two.

+0x10

◆ mWorldXfm

float Rnd::Transformable::mWorldXfm[kXfmRowCount][kXfmRowFloatCount]

Composed world transform.

Public rather than protected because Rnd::Mesh::FindCollisions reads it through a Transformable * that need not be a mesh, and protected access cannot reach a member through a pointer to the base type. The image exposes no accessor for it.

+0x50

◆ mOrigin

float Rnd::Transformable::mOrigin[kXfmRowFloatCount]
protected

◆ mDirty

int Rnd::Transformable::mDirty

Set by every writer of a transform field and cleared once UpdateWorldXfm has recomposed.

Public for the same reason as mLocalXfm. Rnd::TransAnim::SetFrameSelf sets it on its target after writing the interpolated transform, and Rnd::Transformable::AddTrans sets it on the transformable being added.

+0xa0

◆ mBillboard

int Rnd::Transformable::mBillboard
protected

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