|
resonance 1.0.1
|
Screen-aligned ribbon drawn through a list of world-space points. More...
#include <string.h>


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 |
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.
|
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.
| name | The registry key for this object. |
|
virtual |
Release the owned mesh and the point vector.
| 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.
| nCount | The number of points. |
| int Rnd::String::NumPoints | ( | ) | const |
Report how many points the ribbon runs through.
| 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.
| nIndex | The point to move. |
| pos | The new position. |
| 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.
| nIndex | The point to address. |
| 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.
| nIndex | The point to colour. |
| color | The new colour. |
| Color * Rnd::String::PointColor | ( | int | nIndex | ) |
Report the address of the colour of one point.
No call site remains in the shipped program.
| nIndex | The point to read. |
| 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.
| pMat | The material, or null for none. |
| 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.
| float Rnd::String::GetWidth | ( | ) | const |
Report the width of the ribbon in screen units.
|
inline |
Set the width of the ribbon in screen units.
Only the stored width changes. The ribbon is not rebuilt.
| flWidth | The width. |
| void Rnd::String::SetFoldAngle | ( | float | flAngle | ) |
Set the bend the ribbon folds at and cache its cosine.
| flAngle | The angle in radians. |
| float Rnd::String::GetFoldAngle | ( | ) | const |
Report the bend the ribbon folds at.
| 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.
| nHasCaps | Non-zero for capped ends. |
| int Rnd::String::GetHasCaps | ( | ) | const |
Report the cap flag.
| 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().
| nLinePairs | Non-zero to draw each pair of points as its own segment. |
| int Rnd::String::GetLinePairs | ( | ) | const |
Report the line-pair flag.
|
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.
| nHighlight | Non-zero to highlight. |
Reimplemented from Rnd::Drawable.
|
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.
| ray | The segment to test along. |
| collisions | The list to append intersections to. |
Reimplemented from Rnd::Collideable.
|
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.
| sink | The diagnostic sink to write to. |
Reimplemented from Rnd::Drawable.
|
virtual |
Write this ribbon's serialised form to stream.
| stream | The stream to write to. |
Reimplemented from Rnd::Drawable.
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.
| pFrom | The object going away. |
| pTo | The object to store instead, or null. |
Reimplemented from Rnd::Drawable.
|
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".
Implements Rnd::Object.
|
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.
| pSource | The ribbon to copy from. |
| nFlags | The set of fields to copy; see kCopyChildLists. |
Reimplemented from Rnd::Drawable.
|
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.
| stream | The stream to read from. |
Reimplemented from Rnd::Drawable.
Build a ribbon the class registry vends.
| name | The registry key for the new ribbon. |
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.
| name | The registry key for the new ribbon. |
|
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.
|
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.
Reimplemented from Rnd::Drawable.