|
resonance 1.0.1
|
Mix-in for an object with a local and a world transform. More...
#include <transformable.h>


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. | |
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
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.
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.
| 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.
|
virtual |
Drop this object's references on its children.
| 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.
| pTrans | The transformable to position from this one. |
| 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.
| pTrans | The transformable to remove. |
| void Rnd::Transformable::RemoveAllTranses | ( | ) |
Drop this object's reference on every mTransList entry and empty the list.
|
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.
| sink | The diagnostic sink to write to. |
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.
|
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.
| stream | The stream to write to. |
Implements Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.
|
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.
| stream | The stream to read from. |
Implements Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.
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.
| pFrom | The object being replaced. |
| pTo | The replacement, or null. |
Implements Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.
|
virtual |
Copy both transforms, mBillboard, and mOrigin from pSource.
mDirty is not copied. AcquireTransRefs() sets it instead, so a copied object always recomposes once.
| pSource | The object to copy from. |
| nFlags | The set of fields to copy; see kCopyChildLists. |
Implements Rnd::Object.
Reimplemented in Rnd::Arena, Rnd::Cam, Rnd::Generator, Rnd::Light, Rnd::Mesh, Rnd::ParticleSys, Rnd::String, Rnd::Text, and Rnd::View.
| 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.
|
virtual |
Set the billboard mode and mark the transform dirty.
Vtable slot 1.
| nBillboard | The billboard mode. |
Reimplemented in Rnd::Text.
|
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.
| pParent | The transformable this one hangs off, or null for a root. |
| nForce | Non-zero to recompose even when nothing is marked dirty. |
Reimplemented in Rnd::Arena, Rnd::Cam, and Rnd::Text.
| 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.
| pOrigin | Four floats, of which the first three are x, y, and z. |
| 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.
|
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.
| owner | The transformable being detached from. |
|
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.
|
friend |
|
friend |
Append every transform descendant of a transformable.
| objects | The list to append to. |
| pTransformable | The transformable to start from, or null. |
| 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
| 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
|
protected |
| 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
|
protected |