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

Indexed triangle mesh with one material. More...

#include <mesh.h>

Inheritance diagram for Rnd::Mesh:
Collaboration diagram for Rnd::Mesh:

Public Types

enum  ZMode {
  kZModeDisable = 0 , kZModeZReadOnly = 1 , kZModeZReadWrite = 2 , kZModeWReadOnly = 3 ,
  kZModeWReadWrite = 4
}
 Depth buffer read and write mode, as the text dump labels the values. More...
enum  ZFunc {
  kZFuncNever = 0 , kZFuncLess = 1 , kZFuncEqual = 2 , kZFuncLessEqual = 3 ,
  kZFuncGreater = 4 , kZFuncNotEqual = 5 , kZFuncGreaterEqual = 6 , kZFuncAlways = 7
}
 Depth comparison, as the text dump labels the values. More...
enum  { kSyncAllMask = 0x7f }
 Every bit SyncAll() reports as changed. More...
enum  { kSyncPoints = 0x01 , kSyncNorms = 0x08 , kSyncColors = 0x10 , kSyncTexs = 0x20 }
 Bits of the changed-parts mask SyncChanged() receives. More...
enum  { kCopyShareVerts = 0x08 , kCopyShareFaces = 0x10 , kCopyShareTransforms = 0x20 }
 Bits of the copy flags Copy() tests. More...
enum  { kSerialVersion = 10 }
 Serial version this build writes, and the highest version it loads. More...
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 Member Functions

 Mesh (const HxStr &name)
 Construct an empty mesh that owns its own geometry.
virtual ~Mesh ()
void * operator new (size_t nSize)
 Allocate a mesh from the tagged heap under the tag "Rnd::Mesh".
void operator delete (void *pBlock)
 Release a mesh to the tagged heap under the same tag.
virtual void DumpText (Dbg &sink)
 Write the mesh to the engine text sink.
virtual void Save (Stream &stream)
 Serialise the mesh.
virtual void Replace (Object *pFrom, Object *pTo)
 Replace one object reference with another.
virtual const HxStr & ClassName () const
 Return the registered class name, "Mesh".
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy another mesh over this one.
virtual void Load (Stream &stream)
 Load the mesh.
void SetMat (Mat *pMat)
 Point the mesh at a material.
void SetTransOwner (Transformable *pOwner)
 Point the mesh at the transform it draws with.
void SetNext (Mesh *pNext, float flMinScreen)
 Set the smallest screen size to draw at, and the mesh to draw in its place below it.
void SetTrans1Owner (Transformable *pOwner)
 Point the mesh at its second transform owner.
void SetTrans2Owner (Transformable *pOwner)
 Point the mesh at its third transform owner.
Sphere WorldSphere ()
 Report the bounding sphere in world space.
void ForwardSync ()
 Dispatch Sync().
Sphere BoundingSphere ()
 Compute a bounding sphere of the vertices.
Box BoundingBox ()
 Compute the bounding box of the vertices.
void MakeCube (float flHalfSize)
 Replace the geometry with an axis-aligned cube.
void ComputeNormals (bool bPositionOnly)
 Recompute the vertex normals of mVertsOwner from the faces of mFacesOwner.
void WeldVerts (bool bAverageColors)
 Merge duplicate vertices and remove the faces and edges the merge makes redundant.
void SetVertsOwner (Mesh *pOwner)
 Point the mesh at the mesh whose vertices it draws.
void SetFacesOwner (Mesh *pOwner)
 Point the mesh at the mesh whose triangles and edges it draws.
void SetMaterialChain (Mat *pMat)
 Set the material of this mesh and of every coarser level of its mNext chain.
void SetDepthChain (ZMode zMode, ZFunc zFunc)
 Set the depth mode and comparison of this mesh and of every coarser level of its mNext chain.
void SetVertexColor (const Color &color)
 Give every vertex of mVertsOwner one colour and report the change through SyncChanged().
void MirrorX ()
 Mirror the mesh across its local x axis by negating the x row of its local transform, and mark the transform dirty.
void ScaleUniform (float flScale)
 Scale the three basis rows of the local transform by one factor, and mark the transform dirty.
void AddQuad (unsigned short nV0, unsigned short nV1, unsigned short nV2, unsigned short nV3)
 Append the two triangles of a quad to the faces of mFacesOwner.
void AddQuadStrip (int nRowA, int nRowB, int nCount, int nStep)
 Append the quads between two rows of vertices with AddQuad().
int PrepareDraw (Sphere &worldSphere)
 Decide whether this mesh draws, and yield its world bounding sphere.
virtual void FindCollisions (const Segment &ray, std::list< Collision > &collisions)
 Test a ray against this mesh and append what it strikes to sink.
virtual void Sync ()
 Rebuild whatever the platform subclass derives from the geometry.
virtual void SyncChanged (int nMask)
 Report which parts of the mesh have changed.
virtual void SyncAll ()
 Report every part of the mesh as changed.
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.
virtual void SetHighlight (int nHighlight)
 Set whether this object draws with its highlight treatment.
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.

Public Attributes

ZMode mZMode
ZFunc mZFunc
std::vector< MeshVert > mVerts
std::vector< MeshFace > mFaces
std::vector< MeshEdge > mEdges
Mat * mMat
Mesh * mVertsOwner
Mesh * mFacesOwner
float mMinScreen
Mesh * mNext
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.

Static Public Attributes

static Mesh *(* sNew )(const HxStr &name)
 Creator the registered "Mesh" class builds through.
static HxStr sClassName
 Registered class name of Rnd::Mesh, the string "Mesh".

Protected Member Functions

virtual void AddRefObjects ()
 Restore the reference bookkeeping and resynchronise after a load or a copy.
Protected Member Functions inherited from Rnd::Drawable
virtual int DrawShowing ()
 Draw this object alone.
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.

Protected Attributes

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

Friends

bool JoinFaces (Mesh *pMesh, FlatFace &primary, FlatFace &face)
 Add face to the fan that primary heads when the two share a vertex of pMesh, their normals are within two degrees, and the shared vertices retain one pivot for the whole fan.

Additional Inherited Members

Static Public Member Functions inherited from Rnd::Drawable
static Drawable * Find (const HxStr &name)
 Resolve a registry key to a drawable.

Detailed Description

Indexed triangle mesh with one material.

Its RTTI descriptor is at 0x008eed58. It has three public non-virtual bases: Rnd::Drawable at +0x00, Rnd::Transformable at +0x20, and Rnd::Collideable at +0xd0. All three derive virtually from Rnd::Object. One shared Object subobject sits at +0x150 and the whole object is 0x16c bytes; the factory rounds the allocation to 0x170.

Geometry is shared rather than copied. A mesh whose mVertsOwner is another mesh draws that mesh's vertices, and its own vertex vector is released after a load or a copy. The same applies to mFacesOwner for the face and edge vectors. A newly constructed mesh owns its own geometry, because the constructor sets both owners to this.

The drawing implementation belongs to the platform subclass. Rnd::PsMesh supplies DrawShowing() and Sync(), and GfxDevice::Init() replaces the creator hook at 0x006eed60 with the PsMesh factory, so every mesh a file loads on the PlayStation 2 is a PsMesh.

The compiler-generated GetTypeInfo() is at 0x00492528.

Member Enumeration Documentation

◆ ZMode

Depth buffer read and write mode, as the text dump labels the values.

Enumerator
kZModeDisable 

No depth test and no depth write.

kZModeZReadOnly 

Depth test against Z, no write.

kZModeZReadWrite 

Depth test against Z and write.

kZModeWReadOnly 

Depth test against W, no write.

kZModeWReadWrite 

Depth test against W and write.

◆ ZFunc

Depth comparison, as the text dump labels the values.

Enumerator
kZFuncNever 
kZFuncLess 
kZFuncEqual 
kZFuncLessEqual 
kZFuncGreater 
kZFuncNotEqual 
kZFuncGreaterEqual 
kZFuncAlways 

◆ anonymous enum

anonymous enum

Every bit SyncAll() reports as changed.

Enumerator
kSyncAllMask 

◆ anonymous enum

anonymous enum

Bits of the changed-parts mask SyncChanged() receives.

Four of the seven bits of kSyncAllMask are recovered. Three come from the channels of Rnd::MeshAnim::SetFrameSelf() that report them after writing into the vertex vector, and kSyncNorms comes from ComputeNormals(). The remaining three bits have no recovered producer.

Enumerator
kSyncPoints 

The vertex positions changed.

kSyncNorms 

The vertex normals changed.

kSyncColors 

The vertex colours changed.

kSyncTexs 

The first texture coordinate of each vertex changed.

◆ anonymous enum

anonymous enum

Bits of the copy flags Copy() tests.

The flags belong to the Rnd::Object copy interface. Only the three bits the mesh reads are recovered, and their names are inferred from the effect each one has.

Enumerator
kCopyShareVerts 

Point at the source's vertex owner rather than copying.

kCopyShareFaces 

Point at the source's face owner rather than copying.

kCopyShareTransforms 

Point at the source's transform owners.

◆ anonymous enum

anonymous enum

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

Enumerator
kSerialVersion 

Constructor & Destructor Documentation

◆ Mesh()

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

Construct an empty mesh that owns its own geometry.

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

◆ ~Mesh()

virtual Rnd::Mesh::~Mesh ( )
virtual
Ghidra address:
NTSC-U/C: 0x00492838
Ghidra address:
PAL: 0x004d06e8

Member Function Documentation

◆ operator new()

void * Rnd::Mesh::operator new ( size_t nSize)

Allocate a mesh from the tagged heap under the tag "Rnd::Mesh".

NewMesh() inlines the call, and the out-of-line copy has no caller.

Parameters
nSizeThe object size the compiler supplies.
Returns
The block.
Ghidra address:
NTSC-U/C: 0x00492590
Ghidra address:
PAL: 0x004d0440

◆ operator delete()

void Rnd::Mesh::operator delete ( void * pBlock)

Release a mesh to the tagged heap under the same tag.

The out-of-line copy has no caller.

Parameters
pBlockThe block.
Ghidra address:
NTSC-U/C: 0x004925b0
Ghidra address:
PAL: 0x004d0460

◆ DumpText()

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

Write the mesh to the engine text sink.

Emits the three base dumps, then the "[Mesh]" block. The whole block is suppressed while the dump level of the sink is zero or negative.

Parameters
sinkThe text sink.
Ghidra address:
NTSC-U/C: 0x00480d80
Ghidra address:
PAL: 0x004bea78

Reimplemented from Rnd::Drawable.

◆ Save()

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

Serialise the mesh.

Writes kSerialVersion, the three base subobjects, the two depth fields, each object reference as a name, the bounding sphere, the level of detail fields, and finally the vertex, face, and edge vectors.

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

Reimplemented from Rnd::Drawable.

◆ Replace()

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

Replace one object reference with another.

Forwards to the three bases, then swaps the material and the five mesh references whose current value is the old object. A null replacement makes the mesh adopt what it was sharing rather than lose it.

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

Reimplemented from Rnd::Drawable.

◆ ClassName()

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

Return the registered class name, "Mesh".

The key is the one a data file writes for the class, which the registry at Rnd::Manager::Init() maps to the creator below.

Returns
The class name.
Ghidra address:
NTSC-U/C: 0x00492f00
Ghidra address:
PAL: 0x004d0db0

Implements Rnd::Object.

◆ Copy()

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

Copy another mesh over this one.

Bit 3 of the flags shares the vertex vector instead of copying it, bit 4 does the same for the face and edge vectors, and bit 5 does the same for the three transform references. A shared vector is then released by ClearSharedGeometry().

Parameters
pSourceThe source object, which has to be a mesh for the copy to have any effect.
nFlagsThe copy flags.
Ghidra address:
NTSC-U/C: 0x00482568
Ghidra address:
PAL: 0x004c0338

Reimplemented from Rnd::Drawable.

◆ Load()

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

Load the mesh.

Reports "Can't load new Mesh" through the failure sink when the file version exceeds kSerialVersion. Object references arrive as names and resolve through Rnd::TheManager with a checked cast. A name that no loaded object matches produces a null reference. Versions below 10 are all still readable, and each version test is documented at its reading site.

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

Reimplemented from Rnd::Drawable.

◆ SetMat()

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

Point the mesh at a material.

Drops the reference on the previous material, stores the argument, and takes a reference on a non-null material.

Parameters
pMatThe material, or null.
Ghidra address:
NTSC-U/C: 0x00493a78
Ghidra address:
PAL: 0x004d1928

◆ SetTransOwner()

void Rnd::Mesh::SetTransOwner ( Transformable * pOwner)

Point the mesh at the transform it draws with.

Drops the reference on the previous owner, stores the argument, and takes a reference on a non-null owner.

Parameters
pOwnerThe transform, or null.
Ghidra address:
NTSC-U/C: 0x00493c40
Ghidra address:
PAL: 0x004d1af0

◆ SetNext()

void Rnd::Mesh::SetNext ( Mesh * pNext,
float flMinScreen )

Set the smallest screen size to draw at, and the mesh to draw in its place below it.

Stores flMinScreen into mMinScreen, then swaps the reference on mNext the same way as SetMat() and SetTransOwner(), storing pNext whether or not it is null. The pointer arrives in $a1 and the float in $f12, so the order of the two parameters in the source cannot be recovered. Rnd::MultiMesh::DrawShowing() and Rnd::LodMesh inline it, and the out-of-line copy has no caller. The title is inferred from the members it writes.

Parameters
pNextThe next mesh in the chain, or null.
flMinScreenThe smallest screen size to draw this mesh at, or zero to always draw it.
Ghidra address:
NTSC-U/C: 0x004925d8
Ghidra address:
PAL: 0x004d0488

◆ SetTrans1Owner()

void Rnd::Mesh::SetTrans1Owner ( Transformable * pOwner)

Point the mesh at its second transform owner.

The same shape as SetTransOwner(). Load() and Copy() inline it, and the out-of-line copy has no caller. The title is inferred.

Parameters
pOwnerThe owner, or null.
Ghidra address:
NTSC-U/C: 0x00493c98
Ghidra address:
PAL: 0x004d1b48

◆ SetTrans2Owner()

void Rnd::Mesh::SetTrans2Owner ( Transformable * pOwner)

Point the mesh at its third transform owner.

Recorded on the same evidence as SetTrans1Owner().

Parameters
pOwnerThe owner, or null.
Ghidra address:
NTSC-U/C: 0x00493cf0
Ghidra address:
PAL: 0x004d1ba0

◆ WorldSphere()

Sphere Rnd::Mesh::WorldSphere ( )

Report the bounding sphere in world space.

The centre is transformed by mTransOwner's world transform, and the radius is copied unscaled. The out-of-line copy has no caller. The title is inferred.

Returns
The sphere.
Ghidra address:
NTSC-U/C: 0x00492e98
Ghidra address:
PAL: 0x004d0d48

◆ ForwardSync()

void Rnd::Mesh::ForwardSync ( )

Dispatch Sync().

The out-of-line copy has no caller. The title is inferred.

Ghidra address:
NTSC-U/C: 0x004940a8
Ghidra address:
PAL: 0x004d1f58

◆ BoundingSphere()

Sphere Rnd::Mesh::BoundingSphere ( )

Compute a bounding sphere of the vertices.

The centre is the middle of the vertices' bounding box, and the radius reaches the farthest vertex and is then scaled by the largest axis scale of this mesh's world transform. Only the third axis scale is taken as an absolute value. A mesh with no vertices reports the origin with a zero radius. The routine has no caller, and the title is inferred.

Returns
The sphere.
Ghidra address:
NTSC-U/C: 0x00483030
Ghidra address:
PAL: 0x004c0e00

◆ BoundingBox()

Box Rnd::Mesh::BoundingBox ( )

Compute the bounding box of the vertices.

The first vertex seeds both corners, so the mesh must have one. The routine has no caller, and the title is inferred.

Returns
The box.
Ghidra address:
NTSC-U/C: 0x00493fb8
Ghidra address:
PAL: 0x004d1e68

◆ MakeCube()

void Rnd::Mesh::MakeCube ( float flHalfSize)

Replace the geometry with an axis-aligned cube.

The eight vertices sit at plus or minus flHalfSize on each axis with white colour and zero normals and texture coordinates. Twelve triangles and the twelve cube edges follow, and the mesh then runs SyncAll() and Sync(). The routine has no caller, and the title is inferred.

Parameters
flHalfSizeHalf the length of a side.
Ghidra address:
NTSC-U/C: 0x00485978
Ghidra address:
PAL: 0x004c3748

◆ ComputeNormals()

void Rnd::Mesh::ComputeNormals ( bool bPositionOnly)

Recompute the vertex normals of mVertsOwner from the faces of mFacesOwner.

With a flat material, each face writes its unit normal into its first vertex only, and the routine returns without reporting a change. Otherwise each vertex is welded to the first earlier vertex at the same position (and, unless bPositionOnly, of the same colour), and takes the normalised sum of the unit normals of every face corner welded to it, each weighted by the corner angle in radians. The smooth path then reports kSyncNorms through SyncChanged().

A world transform whose axes form a left-handed basis negates the results. The flat path negates only one normal, read through the face past the end of the face vector.

The routine has no caller, and the title is inferred.

Parameters
bPositionOnlyWeld vertices by position alone, ignoring colour.
Ghidra address:
NTSC-U/C: 0x00485ef0
Ghidra address:
PAL: 0x004c3cc0

◆ WeldVerts()

void Rnd::Mesh::WeldVerts ( bool bAverageColors)

Merge duplicate vertices and remove the faces and edges the merge makes redundant.

A vertex used by a face or an edge absorbs every later vertex still in use at the same position. With a textured material the first texture coordinates must match as well, and without a flat material a later vertex used by a face must also match in colour. Surviving vertices move down over the removed ones, and every animation that references this mesh and owns its keys moves and trims its keyframes to match. Degenerate and repeated faces and edges are then erased, and an animation channel whose keyframes all match is emptied.

With a flat material, each face first records its colour (the colour of its first vertex, or with bAverageColors the mean of its three), then AssignFlatVerts() runs, and each face's new first vertex takes the recorded colour. SyncAll() and Sync() follow. The routine has no caller, and the title is inferred.

Parameters
bAverageColorsGive each flat face the mean colour of its vertices.
Ghidra address:
NTSC-U/C: 0x00483e70
Ghidra address:
PAL: 0x004c1c40

◆ SetVertsOwner()

void Rnd::Mesh::SetVertsOwner ( Mesh * pOwner)

Point the mesh at the mesh whose vertices it draws.

Drops the reference on the previous owner, stores the argument even when it is null, takes a reference on a non-null owner, empties the vectors now shared through ClearSharedGeometry(), and calls SyncAll().

Parameters
pOwnerThe owner, or null.
Ghidra address:
NTSC-U/C: 0x00493b60
Ghidra address:
PAL: 0x004d1a10

◆ SetFacesOwner()

void Rnd::Mesh::SetFacesOwner ( Mesh * pOwner)

Point the mesh at the mesh whose triangles and edges it draws.

The same shape as SetVertsOwner(), ending with Sync() instead of SyncAll().

Parameters
pOwnerThe owner, or null.
Ghidra address:
NTSC-U/C: 0x00493bd0
Ghidra address:
PAL: 0x004d1a80

◆ SetMaterialChain()

void Rnd::Mesh::SetMaterialChain ( Mat * pMat)

Set the material of this mesh and of every coarser level of its mNext chain.

Parameters
pMatThe material, or null.
Ghidra address:
NTSC-U/C: 0x00493ac8
Ghidra address:
PAL: 0x004d1978

◆ SetDepthChain()

void Rnd::Mesh::SetDepthChain ( ZMode zMode,
ZFunc zFunc )

Set the depth mode and comparison of this mesh and of every coarser level of its mNext chain.

Parameters
zModeThe depth buffer read and write mode.
zFuncThe depth comparison.
Ghidra address:
NTSC-U/C: 0x00493b30
Ghidra address:
PAL: 0x004d19e0

◆ SetVertexColor()

void Rnd::Mesh::SetVertexColor ( const Color & color)

Give every vertex of mVertsOwner one colour and report the change through SyncChanged().

Parameters
colorThe colour.
Ghidra address:
NTSC-U/C: 0x00494048
Ghidra address:
PAL: 0x004d1ef8

◆ MirrorX()

void Rnd::Mesh::MirrorX ( )
inline

Mirror the mesh across its local x axis by negating the x row of its local transform, and mark the transform dirty.

Defined in the header. The one out-of-line copy is emitted in FreqAppearanceDetail's translation unit and has no caller, and FreqAppearanceDetail::unpack() expands the body. The title is inferred.

Ghidra address:
NTSC-U/C: 0x0024ed50
Ghidra address:
PAL: 0x00264178

◆ ScaleUniform()

void Rnd::Mesh::ScaleUniform ( float flScale)
inline

Scale the three basis rows of the local transform by one factor, and mark the transform dirty.

Defined below the class. The one out-of-line copy is emitted in MetFreqMakerInventoryScreen's translation unit and has no caller, and that screen's slot 38 expands the body. The title is inferred.

Parameters
flScaleThe factor.
Ghidra address:
NTSC-U/C: 0x002723a0
Ghidra address:
PAL: 0x0028a830

◆ AddQuad()

void Rnd::Mesh::AddQuad ( unsigned short nV0,
unsigned short nV1,
unsigned short nV2,
unsigned short nV3 )
inline

Append the two triangles of a quad to the faces of mFacesOwner.

The triangles are (nV0, nV1, nV2) and (nV2, nV1, nV3). The only out-of-line copy sits in the Rnd::Tunnel unit, and every caller is a Rnd::Tunnel routine.

Parameters
nV0The first corner.
nV1The corner after nV0 along the first row.
nV2The corner of the second row beside nV0.
nV3The corner of the second row beside nV1.
Ghidra address:
NTSC-U/C: 0x00466528
Ghidra address:
PAL: 0x004a3f58

◆ AddQuadStrip()

void Rnd::Mesh::AddQuadStrip ( int nRowA,
int nRowB,
int nCount,
int nStep )
inline

Append the quads between two rows of vertices with AddQuad().

Each row holds nCount vertices, and a quad spans nStep of them. The only out-of-line copy sits in the Rnd::Tunnel unit.

Parameters
nRowAThe first vertex of the first row.
nRowBThe first vertex of the second row.
nCountThe vertices in each row.
nStepThe vertices a quad spans.
Ghidra address:
NTSC-U/C: 0x00476598
Ghidra address:
PAL: 0x004b4210

◆ PrepareDraw()

int Rnd::Mesh::PrepareDraw ( Sphere & worldSphere)

Decide whether this mesh draws, and yield its world bounding sphere.

A mesh with neither faces nor edges is rejected. A sphere of zero radius is accepted without a test. Otherwise the local sphere is brought through the transform owner's world transform and tested against the current camera's frustum.

A non-zero mMinScreen then estimates the projected size, and a mesh too small for its own threshold is not simply rejected: the mNext chain is walked for a level of detail whose threshold admits that size, that mesh is drawn instead, and this one reports no draw. The substitution is why the name is not a question.

Parameters
worldSphereReceives the bounding sphere in world space.
Returns
Non-zero when the caller is to draw this mesh.
Ghidra address:
NTSC-U/C: 0x00480818
Ghidra address:
PAL: 0x004be510

◆ FindCollisions()

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

Test a ray against this mesh and append what it strikes to sink.

Rnd::Collideable vtable slot 1. A bounding sphere with a non-zero radius rejects the ray first, in world space. The faces are then tested in the local space of mTransOwner, so the ray is brought there through the inverse of the owner's world transform rather than every vertex being brought out. Each face of mFacesOwner is tested against the vertices of mVertsOwner, with the cull mode of the material deciding whether a back-facing hit counts, and a strike appends this mesh and the distance along the ray. The base implementation runs last, so the children are tested after this mesh's own faces.

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

Reimplemented from Rnd::Collideable.

◆ Sync()

virtual void Rnd::Mesh::Sync ( )
virtual

Rebuild whatever the platform subclass derives from the geometry.

Rnd::Drawable vtable slot 4. Empty in Rnd::Mesh. Rnd::PsMesh rebuilds its triangle strips here. The name is inferred from the slot it fills.

Public rather than protected because Rnd::Text::BuildGlyphMesh() at 0x004c9c00 dispatches the slot on the mesh it owns, and Rnd::Text derives from Rnd::Drawable rather than from this class, which protected access cannot express. A friend declaration would fit the image equally well; public asserts the weaker of the two.

Ghidra address:
NTSC-U/C: 0x00492770
Ghidra address:
PAL: 0x004d0620

Reimplemented in Rnd::PsMesh.

◆ SyncChanged()

virtual void Rnd::Mesh::SyncChanged ( int nMask)
virtual

Report which parts of the mesh have changed.

Rnd::Drawable vtable slot 5. Empty in Rnd::Mesh and in Rnd::PsMesh. The name is inferred from the slot it fills. Public because Rnd::MeshAnim::SetFrameSelf() at 0x004876b0 calls it on the mesh it animates, from outside this hierarchy and with no accessor in the image.

Parameters
nMaskThe changed parts, a set of the kSync bits above.
Ghidra address:
NTSC-U/C: 0x00492778
Ghidra address:
PAL: 0x004d0628

◆ SyncAll()

virtual void Rnd::Mesh::SyncAll ( )
virtual

Report every part of the mesh as changed.

Rnd::Drawable vtable slot 6. Public on the same evidence as Sync(), the same builder dispatching the slot at 0x004c9be8.

Ghidra address:
NTSC-U/C: 0x00492780
Ghidra address:
PAL: 0x004d0630

◆ AddRefObjects()

virtual void Rnd::Mesh::AddRefObjects ( )
protectedvirtual

Restore the reference bookkeeping and resynchronise after a load or a copy.

Adds a reference for each of the seven object references, then calls SyncAll() followed by Sync().

Ghidra address:
NTSC-U/C: 0x00493e10
Ghidra address:
PAL: 0x004d1cc0

Reimplemented in Rnd::PsMesh.

◆ JoinFaces

bool JoinFaces ( Mesh * pMesh,
FlatFace & primary,
FlatFace & face )
friend

Add face to the fan that primary heads when the two share a vertex of pMesh, their normals are within two degrees, and the shared vertices retain one pivot for the whole fan.

Records primary in face.mPrimaryFace whether or not it joins. AssignFlatVerts() is the only caller.

Ghidra address:
NTSC-U/C: 0x004832d0
Ghidra address:
PAL: 0x004c10a0

Member Data Documentation

◆ sNew

Mesh *(* Rnd::Mesh::sNew) (const HxStr &name)
static

Creator the registered "Mesh" class builds through.

GfxDevice::Init() overwrites the hook with the Rnd::PsMesh creator. A mesh loaded from a file on the PlayStation 2 is therefore a PsMesh. Rnd::Blur, HudDisplay, and Rnd::Tunnel also build their meshes through it.

Ghidra address:
NTSC-U/C: 0x006eed60
Ghidra address:
PAL: 0x00732780

◆ sClassName

HxStr Rnd::Mesh::sClassName
static

Registered class name of Rnd::Mesh, the string "Mesh".

Ghidra address:
NTSC-U/C: 0x006eed68
Ghidra address:
PAL: 0x00732788

◆ mZMode

ZMode Rnd::Mesh::mZMode

< Depth buffer read and write mode. Rnd::PsMesh::DrawShowing() reads it to build the GS register writes. Public rather than protected on two counts: Rnd::PsMesh::SelectDepthRegsForPass() reads it through a Rnd::Mesh & that is not its own object, and Rnd::Text::BuildGlyphMesh() at 0x004c9ad4 writes it on the mesh it owns from outside this hierarchy. A friend declaration would fit the image equally well; public asserts the weaker of the two. +0xe0 Depth comparison. Public on the same evidence as mZMode, the same builder writing it at 0x004c9acc. +0xe4

◆ mZFunc

ZFunc Rnd::Mesh::mZFunc

◆ mVerts

std::vector<MeshVert> Rnd::Mesh::mVerts

< Vertices, owned when mVertsOwner is this mesh. Public because Rnd::Blur::RebuildBlurMesh() at 0x004b9b30 fills the vector directly and the image has no accessor for it. +0xe8 Triangles, owned when mFacesOwner is this mesh. Public on the same evidence as mVerts, the builder at 0x004b9b30 writing all three pointers of the vector. +0xf4

◆ mFaces

std::vector<MeshFace> Rnd::Mesh::mFaces

Drawn edges. Public because Rnd::Text::BuildGlyphMesh() at 0x004c9780 writes the vector directly. +0x100

◆ mEdges

std::vector<MeshEdge> Rnd::Mesh::mEdges

◆ mMat

Mat* Rnd::Mesh::mMat

< Material this mesh draws with. Rnd::PsMesh::DrawShowing() reads it to select it, and public rather than protected because Rnd::PsMultiMesh::DrawShowing() at 0x005b2f58 reads it out of the mesh it instances, from outside this hierarchy. +0x10c

◆ mSphere

Sphere Rnd::Mesh::mSphere
protected

◆ mVertsOwner

Mesh* Rnd::Mesh::mVertsOwner

< Mesh whose vertices this one draws, itself for a mesh that owns them. Public because the blur builder at 0x004b9b30 reads it to decide whether it may refill mVerts. +0x130 Mesh whose triangles and edges this one draws, itself for a mesh that owns them. Public on the same evidence as mVertsOwner. +0x134

◆ mFacesOwner

Mesh* Rnd::Mesh::mFacesOwner

◆ mTransOwner

Transformable* Rnd::Mesh::mTransOwner
protected

◆ mMaxVerts

int Rnd::Mesh::mMaxVerts
protected

◆ mMinScreen

float Rnd::Mesh::mMinScreen

< Projected size below which this mesh yields to a coarser link of the mNext chain. Zero disables the substitution. SetNext() writes it. Public because Rnd::MultiMesh::DrawShowing() at 0x004e83f4 and Rnd::LodMesh read it directly, and the image has no accessor for it. +0x148 Next coarser level of detail, or null at the end of the chain. Public on the same evidence: the same routine reads it at 0x004e8444 to hand it back to SetNext(). +0x14c

◆ mNext

Mesh* Rnd::Mesh::mNext

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