wavelength 1.0.0
Loading...
Searching...
No Matches
PsMesh Class Reference

Mesh, PlayStation 2. More...

#include <psmesh.h>

Inheritance diagram for PsMesh:
Collaboration diagram for PsMesh:

Classes

struct  SkinVert
 The bind pose of a skinned vertex, with the weight of each bone in the fourth word. More...

Public Member Functions

 PsMesh (const char *pszName)
 Construct a mesh without packets.
 ~PsMesh () override
 Release the packets after the frame and the bind pose.
void * operator new (size_t nSize)
 Allocate a mesh from its pool.
void operator delete (void *pBlock)
 Return a mesh to its pool.
void Copy (const RndObject *pSource, int nFlags) override
 Copy another mesh, then copy each of its packets this mesh does not have.
void Sync (int nFlags) override
 Rebuild the bind pose, the face packet, and the edge packet a set of flags covers, on the mesh that has the geometry.
int DrawShowing () override
 Draw each pass of the faces, then the edges, when the level of detail selects the mesh.
void BuildFacesPacket ()
 Build the face packet from the faces and the vertices.
void BuildEdgesPacket ()
 Build the edge packet from the edges and the vertices.
void SetZTest (int nPass)
 Set the GS depth test and depth write of a pass from the depth mode and comparison.
void DrawFaces (const Transform &xfm)
 Send the settings of the face microprogram and the face packet of the mesh with the geometry.
void DrawEdges (const Transform &xfm)
 Send the settings of the edge microprogram and the edge packet of the mesh with the geometry.
const Transform & SkinXfm ()
 Report the transform to draw the mesh with, skinning its vertices first when it has bones.
void FacesPacket (MemHandle *&pPacket, int &nSetupQwords, int &nVuEnd) const
 Report the face packet of the mesh with the geometry and how the first batch is laid out.
unsigned short GetNumFaces () const
Public Member Functions inherited from RndMesh
 RndMesh (const char *pszName)
 Construct an empty mesh that draws with a Z depth test and write, passing when nearer.
 ~RndMesh () override
 Drop the references the mesh has.
void * operator new (size_t nSize)
 Allocate a mesh, billed to the class name.
void operator delete (void *pBlock)
 Release a mesh.
void ListDrawObjects (std::list< RndObject * > &objects) override
 Add the mesh, its material, its owners, the textures of the material stages from the last, and the bones to a list.
void ListDrawables (std::list< RndDrawable * > &drawables) override
 Add the mesh and then its children to a list, unless the mesh is outside the view of the current camera.
void Collide (const Segment &segment, std::list< Collision > &collisions) override
 Add each face the segment strikes, then what the children strike, to a list.
void DumpText (PrnStream &stream) override
 Write a description of the mesh and its bases.
void Save (BinStream &stream) override
 Write the mesh and its bases.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace a referenced object with another.
const char * ClassName () const override
 Report the class name.
void Copy (const RndObject *pSource, int nFlags) override
 Copy another mesh and its bases.
void Load (BinStream &stream) override
 Read what Save() wrote, or an earlier version of it.
void SetMat (RndMat *pMat)
 Set the material.
bool CheckLod (Sphere &worldSphere)
 Report whether the mesh itself is to be drawn, drawing a lower detail mesh in its place when the current camera shows it too small.
void BoundingBox (Box &box)
 Compute the bounding box of the vertices in the mesh's own space.
void TransformVerts (const Transform &xfm)
 Move every vertex of the geometry by a transform, then rebuild the positions and normals.
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 mGeomOwner.
void AddQuadStrip (int nRowA, int nRowB, int nCount, int nStride, int nStep)
 Append the quads between two rows of vertices with AddQuad().
void FillEdges (int nEdgeA, int nEdgeB, int nCount, int nStride, const Vector3 &pointA0, const Vector3 &pointB0, const Vector3 &pointA1, const Vector3 &pointB1, const Vector2 &texA0, const Vector2 &texB0, const Vector2 &texA1, const Vector2 &texB1, const Vector2 &weightsA0, const Vector2 &weightsB0, const Vector2 &weightsA1, const Vector2 &weightsB1, const Color &colorA0, const Color &colorB0, const Color &colorA1, const Color &colorB1, const Vector3 &normA, const Vector3 &normB)
 Fill the vertices of two edges of a tunnel panel, interpolating every field along them.
const std::vector< Face > & GetFaces () const
std::vector< Face > & GetFaces ()
RndMesh * GetGeomOwner () const
RndMat * GetMat () const
float GetMinScreen () const
int GetMutable () const
void SetMutable (int nMutable)
const Sphere & GetSphere () const
Sphere & GetSphere ()
const std::vector< Vert > & GetVerts () const
std::vector< Vert > & GetVerts ()
int GetZFunc () const
void SetZFunc (int nZFunc)
int GetZMode () const
void SetZMode (int nZMode)
virtual void Collide (const Vector2 &point, std::list< Collision > &collisions)
 Test a screen point against the collideable and add what it strikes to a list.
Public Member Functions inherited from RndDrawable
 RndDrawable ()
 Construct a showing drawable without a highlight or children.
 ~RndDrawable () override
 Drop the references on the children.
virtual void SetShowing (int nShowing)
 Set whether the drawable draws at all.
virtual void SetHighlight (int nHighlight)
 Set whether the drawable draws with its highlight treatment.
RndDrawable * Parent ()
 Find the drawable whose children include this one.
void Draw ()
 Draw the drawable and then its children, when it is showing.
bool AddDraw (RndDrawable *pDraw, RndDrawable *pBefore)
 Add a child before another.
void RemoveDraw (RndDrawable *pDraw)
 Remove a child.
void ClearDraws ()
 Remove every child.
int GetShowing () const
const std::list< RndDrawable * > & GetDraws () const
Public Member Functions inherited from RndObject
 RndObject (const char *pszName)
 Construct an object and register it under a name.
virtual ~RndObject ()
 Notify every referrer, then erase the registration.
void SetName (const char *pszName)
 Register the object under a different name.
void AddRef (RndObject *pReferrer)
 Register an object as a store of a pointer to this one.
void RemoveRef (RndObject *pReferrer)
 Drop the first registration AddRef() made for a referrer.
const char * GetName () const
const std::list< RndObject * > & GetRefs () const
int GetInternal () const
void SetInternal (int nInternal)
Public Member Functions inherited from RndTransformable
 RndTransformable ()
 Construct a transformable with identity transforms, no origin offset, and no billboard.
 ~RndTransformable () override
 Drop the references on the children.
virtual void SetBillboard (int nBillboard)
 Set the billboard mode.
virtual int UpdateWorldXfm (RndTransformable *pParent, int bForce)
 Recompute the world transform when it, or the parent's, changed, and then the children's.
void DumpText (PrnStream &stream) override
 Write a description of the transformable.
void Save (BinStream &stream) override
 Write the transforms, the names of the children, the billboard mode, and the origin.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace a child with another object.
void Copy (const RndObject *pSource, int nFlags) override
 Copy the transforms, the billboard mode, the origin, and the children when the flags request them.
void Load (BinStream &stream) override
 Read what Save() wrote, or an earlier version of it.
void SetOrigin (const Vector3 &origin)
 Set the point the world transform subtracts first when there is no billboard.
RndTransformable * Parent ()
 Find the transformable whose children include this object.
bool AddTrans (RndTransformable *pTrans)
 Append a child and mark its world transform dirty.
void RemoveTrans (RndTransformable *pTrans)
 Remove a child.
void ClearTrans ()
 Remove every child.
const Transform & BillboardXfm ()
 Report the world transform turned to face the current camera.
const Transform & GetLocalXfm () const
Transform & GetLocalXfm ()
void SetLocalXfm (const Transform &xfm)
const Transform & GetWorldXfm () const
Transform & GetWorldXfm ()
int GetDirty () const
void SetDirty (int nDirty)
const std::list< RndTransformable * > & GetTransList () const
Public Member Functions inherited from RndCollideable
 RndCollideable ()
 Construct a collideable without children.
 ~RndCollideable () override
 Drop the references on the children.
RndCollideable * Parent ()
 Find the collideable whose children include this one.
bool AddCollide (RndCollideable *pCollide)
 Append a child.
void RemoveCollide (RndCollideable *pCollide)
 Remove a child.

Static Public Member Functions

static void Init ()
 Install the mesh factory for the class Mesh of a .rnd file, and set g_identityXfm.
static RndObject * New (const char *pszName)
 Create a mesh.
Static Public Member Functions inherited from RndMesh
static RndObject * New (const char *pszName)
 Create a mesh.
Static Public Member Functions inherited from RndDrawable
static void CollectChildren (std::list< RndObject * > &objects, RndDrawable *pDrawable)
 Append every draw descendant of a drawable, depth first, each before its descendants.
Static Public Member Functions inherited from RndTransformable
static void CollectChildren (std::list< RndObject * > &objects, RndTransformable *pTransformable)
 Append every transform descendant of a transformable, depth first, each before its descendants.
Static Public Member Functions inherited from RndCollideable
static void CollectChildren (std::list< RndObject * > &objects, RndCollideable *pCollideable)
 Append every collision descendant of a collideable, depth first, each before its descendants.

Public Attributes

std::unique_ptr< SkinVert[]> mSkinVerts

Static Public Attributes

static constexpr int kVertexCacheSize = 256
 The number of entries of g_vertexCache.
Static Public Attributes inherited from RndMesh
static constexpr int kCopyShareGeometry = 8
 The bit of the Copy() flags that shares the source's geometry rather than copying it.
static constexpr int kCopyBones = 0x20
 The bit of the Copy() flags that copies the bones.
static const char * sClassName
 The class name a .rnd file writes, Mesh.
static int sRev
 The format version Save() writes and Load() accepts.
static int sLoadRev
 The version Load() read last, which the vertex and face readers read by.
Static Public Attributes inherited from RndDrawable
static int sRev
 The format version Save() writes and Load() accepts.
Static Public Attributes inherited from RndObject
static constexpr int kCopyChildLists = 0x200
 The bit of the Copy() flags that copies the child lists of the mix-ins.
Static Public Attributes inherited from RndTransformable
static int sRev
 The format version Save() writes and Load() accepts.
Static Public Attributes inherited from RndCollideable
static int sRev
 The format version Save() writes and Load() accepts.

Additional Inherited Members

Public Types inherited from RndMesh
enum  ZMode {
  kZModeDisable = 0 , kZModeZReadOnly = 1 , kZModeZReadWrite = 2 , kZModeWReadOnly = 3 ,
  kZModeWReadWrite = 4
}
 How drawing reads and writes depth. More...
enum  ZFunc {
  kZFuncNever = 0 , kZFuncLess = 1 , kZFuncEqual = 2 , kZFuncLessEqual = 3 ,
  kZFuncGreater = 4 , kZFuncNotEqual = 5 , kZFuncGreaterEqual = 6 , kZFuncAlways = 7
}
 The depth comparison. More...
enum  SyncFlags {
  kSyncPositions = 1 , kSyncNormals = 4 , kSyncColors = 8 , kSyncTexCoords = 0x10 ,
  kSyncVertexData = 0x1f , kSyncFaces = 0x20 , kSyncEdges = 0x40 , kSyncAll = 0x7f
}
 The parts of the geometry Sync() rebuilds. More...
Public Types inherited from RndTransformable
enum  Billboard {
  kBillboardNone = 0 , kBillboardX = 1 , kBillboardY = 2 , kBillboardZ = 4 ,
  kBillboardXZ = 8 , kBillboardXYZ = 16 , kBillboardSimpleXYZ = 32 , kBillboardLocalRotate = 64 ,
  kBillboardScale = 128 , kBillboardScaleX = 129 , kBillboardScaleY = 130 , kBillboardScaleZ = 132 ,
  kBillboardScaleXZ = 136 , kBillboardScaleXYZ = 144 , kBillboardScaleSimpleXYZ = 160
}
 How the world transform turns to face the current camera. More...
Protected Member Functions inherited from RndMesh
void ReleaseRefs ()
 Drop the references on the next mesh, the material, the owners, and the bones, and delete the bones.
void AcquireRefs ()
 Take references on the next mesh, the material, the owners, and the bones, then rebuild everything.
Protected Member Functions inherited from RndDrawable
void ReleaseDrawRefs ()
 Drop the reference on every child without emptying the list.
void AcquireDrawRefs ()
 Take a reference on every child.
Protected Member Functions inherited from RndTransformable
void ReleaseTransRefs ()
 Drop the reference on every child without emptying the list.
void AcquireTransRefs ()
 Take a reference on every child.
Protected Member Functions inherited from RndCollideable
void ReleaseCollideRefs ()
 Drop the reference on every child without emptying the list.
void AcquireCollideRefs ()
 Take a reference on every child.
Protected Attributes inherited from RndMesh
int mZMode
int mZFunc
std::vector< Vert > mVerts
std::vector< Face > mFaces
std::vector< Edge > mEdges
RndMat * mMat
Sphere mSphere
RndMesh * mGeomOwner
RndTransformable * mTransOwner
std::unique_ptr< Bones > mBones
float mMinScreen
RndMesh * mNext
int mMutable
Protected Attributes inherited from RndDrawable
int mShowing
Protected Attributes inherited from RndObject
std::list< RndObject * > mRefs
String mName
Protected Attributes inherited from RndTransformable
std::list< RndTransformable * > mTransList
Transform mLocalXfm
Transform mWorldXfm
Vector3 mOrigin
int mDirty
int mBillboard

Detailed Description

Mesh, PlayStation 2.

The RTTI includes the class name and records RndMesh as the one base. Sync() turns the faces and the edges into VIF packets for the VU1 microprogram and then releases them. Each packet is a run of batches. A batch unpacks the vertices it uses and the indices of its faces or edges, and then starts the microprogram. A mesh that is not mutable has its vertices copied into the packets and releases them too. A mutable mesh retains them, and its packets refer to them with DMA REF tags. A mesh with bones is mutable, and SkinXfm() moves its vertices into world space every frame.

Constructor & Destructor Documentation

◆ PsMesh()

PsMesh::PsMesh ( const char * pszName)
explicit

Construct a mesh without packets.

Parameters
pszNameThe registry key.
Ghidra address:
NTSC-U/C: 0x00216050
Ghidra address:
PAL: 0x0021ee68

◆ ~PsMesh()

PsMesh::~PsMesh ( )
override

Release the packets after the frame and the bind pose.

Ghidra address:
NTSC-U/C: 0x00214e88
Ghidra address:
PAL: 0x0021dca0

Member Function Documentation

◆ operator new()

void * PsMesh::operator new ( size_t nSize)
inline

Allocate a mesh from its pool.

Parameters
nSizeThe object size the compiler supplies.
Returns
The block.

◆ operator delete()

void PsMesh::operator delete ( void * pBlock)
inline

Return a mesh to its pool.

Parameters
pBlockThe block.

◆ Copy()

void PsMesh::Copy ( const RndObject * pSource,
int nFlags )
overridevirtual

Copy another mesh, then copy each of its packets this mesh does not have.

The source has to be a PsMesh.

Parameters
pSourceThe mesh to copy from.
nFlagsThe set of fields to copy.
Ghidra address:
NTSC-U/C: 0x00213f68
Ghidra address:
PAL: 0x0021cd80

Implements RndObject.

◆ Sync()

void PsMesh::Sync ( int nFlags)
overridevirtual

Rebuild the bind pose, the face packet, and the edge packet a set of flags covers, on the mesh that has the geometry.

The faces and the edges are released once their packet is built, and the vertices are released unless the mesh is mutable. A mesh with bones becomes mutable.

Parameters
nFlagsThe RndMesh::SyncFlags.
Ghidra address:
NTSC-U/C: 0x00214af8
Ghidra address:
PAL: 0x0021d910

Reimplemented from RndMesh.

◆ DrawShowing()

int PsMesh::DrawShowing ( )
overridevirtual

Draw each pass of the faces, then the edges, when the level of detail selects the mesh.

Returns
1 when the mesh is drawn, or 0.
Ghidra address:
NTSC-U/C: 0x00215f30
Ghidra address:
PAL: 0x0021ed48

Reimplemented from RndDrawable.

◆ BuildFacesPacket()

void PsMesh::BuildFacesPacket ( )

Build the face packet from the faces and the vertices.

The previous packet is released after the frame. The name is inferred.

Ghidra address:
NTSC-U/C: 0x00214150
Ghidra address:
PAL: 0x0021cf68

◆ BuildEdgesPacket()

void PsMesh::BuildEdgesPacket ( )

Build the edge packet from the edges and the vertices.

The previous packet is released after the frame. The name is inferred.

Ghidra address:
NTSC-U/C: 0x00214710
Ghidra address:
PAL: 0x0021d528

◆ SetZTest()

void PsMesh::SetZTest ( int nPass)

Set the GS depth test and depth write of a pass from the depth mode and comparison.

Passes 0 and 1 draw faces and edges. A later pass changes nothing. Edges never write depth. The name is inferred.

Parameters
nPassThe pass.
Ghidra address:
NTSC-U/C: 0x002154e0
Ghidra address:
PAL: 0x0021e2f8

◆ DrawFaces()

void PsMesh::DrawFaces ( const Transform & xfm)

Send the settings of the face microprogram and the face packet of the mesh with the geometry.

The name is inferred.

Parameters
xfmThe transform of the mesh.
Ghidra address:
NTSC-U/C: 0x002155b0
Ghidra address:
PAL: 0x0021e3c8

◆ DrawEdges()

void PsMesh::DrawEdges ( const Transform & xfm)

Send the settings of the edge microprogram and the edge packet of the mesh with the geometry.

The edges take the edge colour of the material, or white without one. The name is inferred.

Parameters
xfmThe transform of the mesh.
Ghidra address:
NTSC-U/C: 0x002159b0
Ghidra address:
PAL: 0x0021e7c8

◆ SkinXfm()

const Transform & PsMesh::SkinXfm ( )

Report the transform to draw the mesh with, skinning its vertices first when it has bones.

A skinned mesh has its vertices moved into world space on VU0 and draws with the identity. The name is inferred.

Returns
The transform.
Ghidra address:
NTSC-U/C: 0x00215d18
Ghidra address:
PAL: 0x0021eb30

◆ FacesPacket()

void PsMesh::FacesPacket ( MemHandle *& pPacket,
int & nSetupQwords,
int & nVuEnd ) const

Report the face packet of the mesh with the geometry and how the first batch is laid out.

The name is inferred.

Parameters
pPacketReceives the face packet.
nSetupQwordsReceives the quadwords up to and including the start of the first batch.
nVuEndReceives the VU1 address after the data of the last batch.
Ghidra address:
NTSC-U/C: 0x002161b0
Ghidra address:
PAL: 0x0021efc8

◆ Init()

void PsMesh::Init ( )
static

Install the mesh factory for the class Mesh of a .rnd file, and set g_identityXfm.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x002161d0
Ghidra address:
PAL: 0x0021efe8

◆ New()

RndObject * PsMesh::New ( const char * pszName)
inlinestatic

Create a mesh.

Parameters
pszNameThe registry key.
Returns
The mesh.
Ghidra address:
NTSC-U/C: 0x0037cc78
Ghidra address:
PAL: 0x003eb3a8

◆ GetNumFaces()

unsigned short PsMesh::GetNumFaces ( ) const
inline
Returns
The number of faces before Sync() released them.

Member Data Documentation

◆ kVertexCacheSize

int PsMesh::kVertexCacheSize = 256
staticconstexpr

The number of entries of g_vertexCache.

◆ mSkinVerts

std::unique_ptr<SkinVert[]> PsMesh::mSkinVerts

The bind pose of a mesh with bones, or null.


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