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

Screen-aligned ribbon drawn through a list of world-space points. More...

#include <string.h>

Inheritance diagram for Rnd::String:
Collaboration diagram for Rnd::String:

Classes

struct  Point
 One point of the ribbon. More...

Public Member Functions

 String (const HxStr &name)
 Construct an empty ribbon and its mesh.
virtual ~String ()
 Release the owned mesh and the point vector.
void SetNumPoints (int nCount)
 Resize the ribbon to nCount points and rebuild the mesh around it.
int NumPoints () const
 Report how many points the ribbon runs through.
void SetPointPos (int nIndex, const Vector3 &pos)
 Move one point.
Vector3 * GetPointPos (int nIndex)
 Report the address of the position of one point.
void SetPointColor (int nIndex, const Color &color)
 Set the colour of one point and of the mesh vertices it governs.
Color * PointColor (int nIndex)
 Report the address of the colour of one point.
void SetMat (Mat *pMat)
 Set the material the ribbon draws with.
Mat * GetMat () const
 Report the material the ribbon draws with.
float GetWidth () const
 Report the width of the ribbon in screen units.
void SetWidth (float flWidth)
 Set the width of the ribbon in screen units.
void SetFoldAngle (float flAngle)
 Set the bend the ribbon folds at and cache its cosine.
float GetFoldAngle () const
 Report the bend the ribbon folds at.
void SetHasCaps (int nHasCaps)
 Set whether the ribbon ends in a pair of tapering caps.
int GetHasCaps () const
 Report the cap flag.
void SetLinePairs (int nLinePairs)
 Set whether consecutive points form independent segments rather than one continuous ribbon.
int GetLinePairs () const
 Report the line-pair flag.
virtual void SetHighlight (int nHighlight)
 Pass the highlight treatment to the owned mesh.
virtual void FindCollisions (const Segment &ray, std::list< Collision > &collisions)
 Test a ray against the owned mesh and report the intersections as this object.
virtual void DumpText (Dbg &sink)
 Write a description of this ribbon to sink.
virtual void Save (Stream &stream)
 Write this ribbon's serialised form to stream.
virtual void Replace (Object *pFrom, Object *pTo)
 Repoint the base subobjects when an object they address is replaced.
virtual const HxStr & ClassName () const
 Report the class key a .rnd file writes for a ribbon.
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy the state of pSource into this ribbon.
virtual void Load (Stream &stream)
 Read this ribbon's serialised form from stream.
Public Member Functions inherited from Rnd::Drawable
 Drawable ()
 Construct a visible drawable with no children.
virtual ~Drawable ()
 Drop this object's references on its children.
void Draw ()
 Draw this object followed by each of its children.
Drawable * Parent ()
 Report the drawable that draws this one.
void AddDraw (Drawable *pDraw, Drawable *pBefore)
 Insert pDraw into mDraws in front of pBefore.
void AddDraw (Drawable *pDraw)
 Insert pDraw at the front of mDraws.
void RemoveDraw (Drawable *pDraw)
 Erase pDraw from mDraws.
void RemoveAllDraws ()
 Empty mDraws, dropping this object's reference on every entry.
void MoveDraw (Drawable *pDraw, int nSteps)
 Move pDraw nSteps places later in mDraws, or earlier for a negative count.
virtual void SetShowing (int nShowing)
 Set whether this object draws at all.
void SetShowingRecursive (int nShowing)
 Set whether this object and every drawable beneath it in mDraws draw at all.
int GetHighlight () const
 Report the highlight flag.
int GetShowing () const
 Report the showing flag.
std::list< Drawable * > & GetDraws ()
 Report the child list.
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 Member Functions inherited from Rnd::Transformable
 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.
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::Collideable
 Collideable ()
 Construct a collideable with no children.
virtual ~Collideable ()
 Drop this object's references on its children.
Collideable * Parent ()
 Report the collideable that hit-tests this one.
void AddCollide (Collideable *pCollide)
 Append pCollide to mCollides.
void RemoveCollide (Collideable *pCollide)
 Erase pCollide from mCollides.
virtual void FindCollisions (const Vector2 &point, std::list< Collision > &collisions)
 Test a screen point against this object and append what it strikes to collisions.

Static Public Member Functions

static String * New (const HxStr &name)
 Build a ribbon the class registry vends.
static Object * NewObject (const HxStr &name)
 Build a ribbon for the class registry.
static void Init ()
 Register the class key with Rnd::TheManager.
Static Public Member Functions inherited from Rnd::Drawable
static Drawable * Find (const HxStr &name)
 Resolve a registry key to a drawable.

Protected Member Functions

virtual int DrawShowing ()
 Project every point and redraw the owned mesh through it.
Protected Member Functions inherited from Rnd::Drawable
void ReleaseDrawsRefs ()
 Drop this object's reference on every mDraws 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 Member Functions inherited from Rnd::Transformable
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::Collideable
void ReleaseCollidesRefs ()
 Drop this object's reference on every mCollides entry without emptying the list.

Additional Inherited Members

Public Types inherited from Rnd::Transformable
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 Attributes inherited from Rnd::Drawable
int mShowing
Public Attributes inherited from Rnd::Object
HxStr mName
int mInternal
Public Attributes inherited from Rnd::Transformable
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.
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs
Protected Attributes inherited from Rnd::Transformable
float mOrigin [kXfmRowFloatCount]
int mBillboard

Detailed Description

Screen-aligned ribbon drawn through a list of world-space points.

Its RTTI descriptor is at 0x008efd50, its name string at 0x00821700, and its three base entries at 0x00821710 record Rnd::Drawable at offset 0, Rnd::Transformable at offset 32, and Rnd::Collideable at offset 208, each non-virtual and public. All three derive virtually from Rnd::Object. One shared Object subobject therefore sits at +0x110. The class is 0x130 bytes, a size the factory at 0x004bedc8 pins by allocating exactly that much. The members end at +0x108, and the 16-byte alignment the transform rows impose rounds the virtual base up to +0x110.

This class is unrelated to HxStr, the engine's text string type. The title comes from the RTTI descriptor, and the object is a length of ribbon geometry the way a guitar string is one.

Four vtables belong to the class, each ending in an all-zero terminator entry. The four-entry table at 0x00821618 is addressed by the Rnd::Drawable vptr at +0x10 and overrides SetHighlight() and DrawShowing(). The four-entry table at 0x008215f8 is addressed by the Rnd::Transformable vptr at +0xc8 and overrides nothing. The three-entry table at 0x008215d8 is addressed by the Rnd::Collideable vptr at +0xd8 and overrides FindCollisions(). The nine-entry table at 0x00821640 is addressed by the Object subobject vptr and stores the eight Rnd::Object slots with a -0x110 adjustment on each.

The geometry is not drawn directly. Every string owns one Rnd::Mesh that CreateMesh() builds under the name [<object name>_mesh], and that mesh is what the renderer submits. Each point governs two mesh vertices, or four where a cap meets it, and DrawShowing() rewrites the vertex positions every frame from the projected screen positions.

The member titles come from the text DumpText() writes, "[String]", "points:", "width:", " foldAngle:", " hasCaps:", "linePairs:", and "mesh:", and from the per-point labels "\n\tv:" and "\n\tc:". Load() rejects a version of 3 or above with "Can't load new String".

The path predicate at 0x004e7cd8 does not belong to this class; the vtables and the type-info accessor at 0x004bed30 exclude it.

Constructor & Destructor Documentation

◆ String()

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

Construct an empty ribbon and its mesh.

The width starts at 1, the fold angle at 1.5707963, the cap flag set, and the line-pair flag clear. The point vector starts empty and the material starts null. The constructor never writes the mesh pointer; the CreateMesh() call it ends with is what fills it.

Parameters
nameThe registry key for this object.
Ghidra address:
NTSC-U/C: 0x004ba898
Ghidra address:
PAL: 0x004f88c8

◆ ~String()

virtual Rnd::String::~String ( )
virtual

Release the owned mesh and the point vector.

Ghidra address:
NTSC-U/C: 0x004beee8
Ghidra address:
PAL: 0x004fcf70

Member Function Documentation

◆ SetNumPoints()

void Rnd::String::SetNumPoints ( int nCount)

Resize the ribbon to nCount points and rebuild the mesh around it.

The new points arrive default-constructed, at the origin and white. The mesh vertex vector is resized to two vertices per point, plus four more when the cap flag is set, and the index list is rewritten as two triangles for every pair of rungs. Every vertex then receives the colour of its point and the texture coordinate of its position along the ribbon, 0 across a start cap, 0.5 across the body, and 1 across an end cap.

A nCount of zero or below resizes the point vector and stops. The mesh then retains whatever geometry it already had.

Parameters
nCountThe number of points.
Ghidra address:
NTSC-U/C: 0x004b9b30
Ghidra address:
PAL: 0x004f7aa8

◆ NumPoints()

int Rnd::String::NumPoints ( ) const

Report how many points the ribbon runs through.

Returns
The point count.
Ghidra address:
NTSC-U/C: 0x004bf3c0
Ghidra address:
PAL: 0x004fd448

◆ SetPointPos()

void Rnd::String::SetPointPos ( int nIndex,
const Vector3 & pos )

Move one point.

Nothing is rebuilt. DrawShowing() transforms every position each frame, and a moved point therefore arrives in the mesh at the next draw. The copy moves one quadword. The argument is accordingly a whole padded vector rather than three floats.

Parameters
nIndexThe point to move.
posThe new position.
Ghidra address:
NTSC-U/C: 0x004bf738
Ghidra address:
PAL: 0x004fd7c0

◆ GetPointPos()

Vector3 * Rnd::String::GetPointPos ( int nIndex)

Report the address of the position of one point.

The routine returns the address of the point itself, and the position is its first member. A reading that hands back the whole point therefore fits the image equally well. No call site remains in the shipped program to separate the two.

Parameters
nIndexThe point to address.
Returns
The position.
Ghidra address:
NTSC-U/C: 0x004bf400
Ghidra address:
PAL: 0x004fd488

◆ SetPointColor()

void Rnd::String::SetPointColor ( int nIndex,
const Color & color )

Set the colour of one point and of the mesh vertices it governs.

Two vertices receive the colour, or four where the point is a cap. Ends by reporting Rnd::Mesh::kSyncColors to the mesh.

Parameters
nIndexThe point to colour.
colorThe new colour.
Ghidra address:
NTSC-U/C: 0x004bf758
Ghidra address:
PAL: 0x004fd7e0

◆ PointColor()

Color * Rnd::String::PointColor ( int nIndex)

Report the address of the colour of one point.

No call site remains in the shipped program.

Parameters
nIndexThe point to read.
Returns
The colour.
Ghidra address:
NTSC-U/C: 0x004bf418
Ghidra address:
PAL: 0x004fd4a0

◆ SetMat()

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

Set the material the ribbon draws with.

The material is handed straight to the owned mesh and the stored material is not updated. A later CreateMesh() therefore restores the material a load or a copy supplied.

Parameters
pMatThe material, or null for none.
Ghidra address:
NTSC-U/C: 0x004bf668
Ghidra address:
PAL: 0x004fd6f0

◆ GetMat()

Mat * Rnd::String::GetMat ( ) const

Report the material the ribbon draws with.

The value comes from the owned mesh rather than from the stored material.

Returns
The material, or null when none is set.
Ghidra address:
NTSC-U/C: 0x004bf500
Ghidra address:
PAL: 0x004fd588

◆ GetWidth()

float Rnd::String::GetWidth ( ) const

Report the width of the ribbon in screen units.

Returns
The width.
Ghidra address:
NTSC-U/C: 0x004bf3e0
Ghidra address:
PAL: 0x004fd468

◆ SetWidth()

void Rnd::String::SetWidth ( float flWidth)
inline

Set the width of the ribbon in screen units.

Only the stored width changes. The ribbon is not rebuilt.

Parameters
flWidthThe width.
Ghidra address:
NTSC-U/C: 0x004bee78
Ghidra address:
PAL: 0x004fcf00

◆ SetFoldAngle()

void Rnd::String::SetFoldAngle ( float flAngle)

Set the bend the ribbon folds at and cache its cosine.

Parameters
flAngleThe angle in radians.
Ghidra address:
NTSC-U/C: 0x004bf708
Ghidra address:
PAL: 0x004fd790

◆ GetFoldAngle()

float Rnd::String::GetFoldAngle ( ) const

Report the bend the ribbon folds at.

Returns
The angle in radians.
Ghidra address:
NTSC-U/C: 0x004bf3f8
Ghidra address:
PAL: 0x004fd480

◆ SetHasCaps()

void Rnd::String::SetHasCaps ( int nHasCaps)

Set whether the ribbon ends in a pair of tapering caps.

The flag changes how many vertices each point governs. The mesh is accordingly rebuilt at the current point count.

Parameters
nHasCapsNon-zero for capped ends.
Ghidra address:
NTSC-U/C: 0x004bf688
Ghidra address:
PAL: 0x004fd710

◆ GetHasCaps()

int Rnd::String::GetHasCaps ( ) const

Report the cap flag.

Returns
Non-zero when the ribbon ends in caps.
Ghidra address:
NTSC-U/C: 0x004bf3e8
Ghidra address:
PAL: 0x004fd470

◆ SetLinePairs()

void Rnd::String::SetLinePairs ( int nLinePairs)

Set whether consecutive points form independent segments rather than one continuous ribbon.

The mesh is rebuilt at the current point count, on the same grounds as SetHasCaps().

Parameters
nLinePairsNon-zero to draw each pair of points as its own segment.
Ghidra address:
NTSC-U/C: 0x004bf6c8
Ghidra address:
PAL: 0x004fd750

◆ GetLinePairs()

int Rnd::String::GetLinePairs ( ) const

Report the line-pair flag.

Returns
Non-zero when each pair of points is its own segment.
Ghidra address:
NTSC-U/C: 0x004bf3f0
Ghidra address:
PAL: 0x004fd478

◆ SetHighlight()

virtual void Rnd::String::SetHighlight ( int nHighlight)
virtual

Pass the highlight treatment to the owned mesh.

Rnd::Drawable vtable slot 2. Rnd::Drawable::mHighlight is not written. GetHighlight() on a string therefore never reports the value that was set. The behaviour matches the binary.

Parameters
nHighlightNon-zero to highlight.
Ghidra address:
NTSC-U/C: 0x004bf638
Ghidra address:
PAL: 0x004fd6c0

Reimplemented from Rnd::Drawable.

◆ FindCollisions()

virtual void Rnd::String::FindCollisions ( const Segment & ray,
std::list< Collision > & collisions )
virtual

Test a ray against the owned mesh and report the intersections as this object.

Rnd::Collideable vtable slot 1. Tests nothing while Rnd::Drawable::mShowing is clear. Every intersection the mesh appends is rewritten to address this string. A caller therefore never receives the owned mesh. Ends by chaining to Rnd::Collideable::FindCollisions() for the children.

Parameters
rayThe segment to test along.
collisionsThe list to append intersections to.
Ghidra address:
NTSC-U/C: 0x004bf570
Ghidra address:
PAL: 0x004fd5f8

Reimplemented from Rnd::Collideable.

◆ DumpText()

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

Write a description of this ribbon to sink.

The four base descriptions come first, and everything below is produced only at a positive dump level. The mesh name follows at dump level 2 or above.

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

Reimplemented from Rnd::Drawable.

◆ Save()

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

Write this ribbon's serialised form to stream.

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

Reimplemented from Rnd::Drawable.

◆ Replace()

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

Repoint the base subobjects when an object they address is replaced.

Rnd::Object vtable slot 4. The routine touches no field of this class. The mesh pointer is not repointed, because the string owns its mesh rather than referring to one.

Parameters
pFromThe object going away.
pToThe object to store instead, or null.
Ghidra address:
NTSC-U/C: 0x004bf510
Ghidra address:
PAL: 0x004fd598

Reimplemented from Rnd::Drawable.

◆ ClassName()

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

Report the class key a .rnd file writes for a ribbon.

The returned string is g_stringClassName. The static initialiser at 0x004beb40 fills it with "String".

Returns
The class key.
Ghidra address:
NTSC-U/C: 0x004bf430
Ghidra address:
PAL: 0x004fd4b8

Implements Rnd::Object.

◆ Copy()

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

Copy the state of pSource into this ribbon.

The owned mesh is discarded and rebuilt rather than copied, and the material is taken from the material of the source's mesh rather than from the source's stored material.

Parameters
pSourceThe ribbon to copy from.
nFlagsThe set of fields to copy; see kCopyChildLists.
Ghidra address:
NTSC-U/C: 0x004bf858
Ghidra address:
PAL: 0x004fd8e0

Reimplemented from Rnd::Drawable.

◆ Load()

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

Read this ribbon's serialised form from stream.

A version of 3 or above is rejected with "Can't load new String". The fold angle and the cap flag are present from version 1 and the line-pair flag from version 2. The material is resolved by name through Rnd::TheManager.

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

Reimplemented from Rnd::Drawable.

◆ New()

String * Rnd::String::New ( const HxStr & name)
static

Build a ribbon the class registry vends.

Parameters
nameThe registry key for the new ribbon.
Returns
The new ribbon.
Ghidra address:
NTSC-U/C: 0x004bedc8
Ghidra address:
PAL: 0x004fce50

◆ NewObject()

Object * Rnd::String::NewObject ( const HxStr & name)
static

Build a ribbon for the class registry.

The registry stores this creator.

New() is inlined into it, and the null test the compiler emits there is the conversion of a Rnd::String pointer to its Rnd::Object virtual base rather than a check the source requests.

Parameters
nameThe registry key for the new ribbon.
Returns
The new ribbon.
Ghidra address:
NTSC-U/C: 0x004bf440
Ghidra address:
PAL: 0x004fd4c8

◆ Init()

void Rnd::String::Init ( )
static

Register the class key with Rnd::TheManager.

Unlike Rnd::Blur, the class installs no creator hook of its own. No call site remains in the shipped program, because Rnd::Manager::Init performs the same registration inline at 0x00519eac.

Ghidra address:
NTSC-U/C: 0x004bed98
Ghidra address:
PAL: 0x004fce20

◆ DrawShowing()

virtual int Rnd::String::DrawShowing ( )
protectedvirtual

Project every point and redraw the owned mesh through it.

Rnd::Drawable vtable slot 3. Draws nothing without a current camera and nothing with fewer than two points. Each point is transformed into camera space through the inverse camera transform composed with Rnd::Transformable::mWorldXfm, and flagged when its depth is strictly less than the near plane plus 0.01. A flagged point with an unflagged neighbour is pushed onto the near plane along the segment that joins them and then unflagged. A point whose neighbours are both flagged stays flagged and retains a stale mScreen. The unflagged points are projected by dividing x and z by the absolute value of the depth component y. EmitRibbonVerts() then fills the mesh, once over every point, flagged ones included, or once per pair with mLinePairs set. A pair with a point still flagged instead collapses every vertex it governs onto the camera-space position of its first point. The mesh receives Rnd::Mesh::kSyncPoints, the camera transform as its local transform, a world transform update, and a draw.

Returns
Non-zero. The children are drawn as well.
Ghidra address:
NTSC-U/C: 0x004b95f8
Ghidra address:
PAL: 0x004f7570

Reimplemented from Rnd::Drawable.


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