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

Material, PlayStation 2. More...

#include <psmat.h>

Inheritance diagram for PsMat:
Collaboration diagram for PsMat:

Public Member Functions

 PsMat (const char *pszName)
 Construct a material.
 ~PsMat () override
void * operator new (size_t nSize)
 Allocate a material from its pool.
void operator delete (void *pBlock)
 Return a material to its pool.
int Select (int nPass)
 Select one pass of the material for drawing.
void SelectBlendMode (int nPass)
 Program the GS blend, dither, alpha test, and alpha correction for a pass.
void SelectStageClamp (const Stage &stage)
 Clamp the texture coordinates of a stage, or let them repeat.
int TexFunction (int nBlend)
 Report the GS texture function a blend draws its texture with.
void BindStageTexture (int nPass)
 Bind the texture of a pass's stage and set the colour scale for its texture function.
void SetupUvXfm (int nPass)
 Build the texture coordinate transform of a pass's stage into g_uvXfm and g_stageXfm.
Public Member Functions inherited from RndMat
 RndMat (const char *pszName)
 Construct an enabled material that blends by source alpha, with a black base colour, a white light colour, and a black edge colour.
 ~RndMat () override
 Drop the references on the stage textures.
void * operator new (size_t nSize)
 Allocate a material, billed to the class name.
void operator delete (void *pBlock)
 Release a material.
void DumpText (PrnStream &stream) override
 Write a description of the material.
void Save (BinStream &stream) override
 Write the material.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace a stage texture with another object.
const char * ClassName () const override
 Report the class name.
void Copy (const RndObject *pSource, int nFlags) override
 Copy another material.
void Load (BinStream &stream) override
 Read what Save() wrote, or an earlier version of it.
virtual void SyncStage (int nStage)
 Bring the platform state of one stage up to date.
virtual void SetBaseColor (const Color &color)
 Set the red, green, and blue of the base colour.
virtual void SetLightColor (const Color &color)
 Set the light colour.
virtual void SetEdgeColor (const Color &color)
 Set the edge colour.
virtual void SetAlpha (float fAlpha)
 Set the alpha of the base colour.
virtual void SetLighting (int bEnable, int bVertBase, int bVertLight, int bVertEdge, int bNormalize, int bBaseAmbient)
 Set the lighting switches.
virtual void Refresh ()
 Take a reference on every stage texture and bring every stage up to date.
void AddStage ()
 Append a default stage.
int GetBaseAmbient () const
const Color & GetBaseColor () const
int GetBlend () const
void SetBlend (int nBlend)
int GetCull () const
void SetCull (int nCull)
const Color & GetEdgeColor () const
const Color & GetLightColor () const
const std::vector< Stage > & GetStages () const
std::vector< Stage > & GetStages ()
int GetVertBase () const
int GetVertLight () 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)

Static Public Member Functions

static void SelectDefault ()
 Forget the selected material and return the GS to opaque drawing with the default dither.
static void SelectAlphaBlend ()
 Blend by the source alpha, and make the next Select() of the selected material select its blend again.
static void Init ()
 Install the material factory for the class Mat of a .rnd file.
static RndObject * New (const char *pszName)
 Create a material.
Static Public Member Functions inherited from RndMat
static RndObject * New (const char *pszName)
 Create a material.

Static Public Attributes

static PsMat * sCurrent
 The material Select() last selected, or null.
Static Public Attributes inherited from RndMat
static const char * sClassName
 The class name a .rnd file writes, Mat.
static int sRev
 The format version Save() writes and Load() accepts.
static int sLoadRev
 The version Load() read last, which Stage::Load() consults.
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.

Additional Inherited Members

Public Types inherited from RndMat
enum  Blend {
  kBlendDest = 0 , kBlendSrc = 1 , kBlendAdd = 2 , kBlendMultiply = 3 ,
  kBlendMultiply2 = 4 , kBlendSrcAlpha = 5 , kBlendSrcAlphaAdd = 6 , kBlendSrcAdd = 7 ,
  kBlendInvSrcAlpha = 8 , kBlendDestAlpha = 9 , kBlendInvDestAlpha = 10 , kBlendSrcAlphaOpaque = 11 ,
  kBlendSrcAlphaCutout = 12 , kBlendSubtract = 13
}
 How a surface or a texture stage combines with what is beneath it. More...
enum  TexGen {
  kTexGenFixed = 0 , kTexGenSphere = 1 , kTexGenPlanar = 2 , kTexGenOrthoCube = 3 ,
  kTexGenLocalCube = 4
}
 How a texture stage produces its texture coordinates. More...
enum  TexWrap { kTexWrapClamp = 0 , kTexWrapRepeat = 1 , kTexWrapMirror = 2 }
 How texture coordinates outside the unit range wrap. More...
Protected Member Functions inherited from RndMat
void ReleaseStageTex ()
 Drop the reference on every stage texture.
Protected Attributes inherited from RndMat
std::vector< Stage > mStages
int mBlend
Color mBaseColor
Color mLightColor
Color mEdgeColor
int mEnable
int mVertBase
int mVertLight
int mVertEdge
int mNormalize
int mBaseAmbient
int mCull
int mFlat
int mMultiPass
Protected Attributes inherited from RndObject
std::list< RndObject * > mRefs
String mName

Detailed Description

Material, PlayStation 2.

The RTTI includes the class name and records RndMat as the one base. The class adds no data member and overrides only the destructor. It selects a material for drawing: the GS blend, alpha test, and clamp registers, the stage texture, and the globals the mesh and particle paths read. The material last selected is cached in sCurrent.

Constructor & Destructor Documentation

◆ PsMat()

PsMat::PsMat ( const char * pszName)
inlineexplicit

Construct a material.

The binary expands the constructor inline in New().

Parameters
pszNameThe registry key.

◆ ~PsMat()

PsMat::~PsMat ( )
inlineoverride
Ghidra address:
NTSC-U/C: 0x0037cb18
Ghidra address:
PAL: 0x003eb248

Member Function Documentation

◆ operator new()

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

Allocate a material from its pool.

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

◆ operator delete()

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

Return a material to its pool.

Parameters
pBlockThe block.

◆ Select()

int PsMat::Select ( int nPass)

Select one pass of the material for drawing.

A material that is already selected and has fewer than two stages changes nothing, beyond selecting its blend again after SelectAlphaBlend(). Otherwise the blend, the stage texture, and the texture coordinate transform of the pass are selected.

Parameters
nPassThe pass. The pass is also the stage.
Returns
The next pass, or 0 after the last.
Ghidra address:
NTSC-U/C: 0x00213698
Ghidra address:
PAL: 0x0021c4b0

◆ SelectBlendMode()

void PsMat::SelectBlendMode ( int nPass)

Program the GS blend, dither, alpha test, and alpha correction for a pass.

The first pass takes the surface blend and the later passes the blend of their stage. The name is inferred.

Parameters
nPassThe pass.
Ghidra address:
NTSC-U/C: 0x00213788
Ghidra address:
PAL: 0x0021c5a0

◆ SelectStageClamp()

void PsMat::SelectStageClamp ( const Stage & stage)

Clamp the texture coordinates of a stage, or let them repeat.

The name is inferred.

Parameters
stageThe stage.
Ghidra address:
NTSC-U/C: 0x00213a88
Ghidra address:
PAL: 0x0021c8a0

◆ TexFunction()

int PsMat::TexFunction ( int nBlend)

Report the GS texture function a blend draws its texture with.

The name is inferred.

Parameters
nBlendThe Blend.
Returns
The TFX field of TEX0.
Ghidra address:
NTSC-U/C: 0x00213ad8
Ghidra address:
PAL: 0x0021c8f0

◆ BindStageTexture()

void PsMat::BindStageTexture ( int nPass)

Bind the texture of a pass's stage and set the colour scale for its texture function.

A stage without a texture, or with RndMat::kBlendDest, binds nothing. The name is inferred.

Parameters
nPassThe pass.
Ghidra address:
NTSC-U/C: 0x00213af0
Ghidra address:
PAL: 0x0021c908

◆ SetupUvXfm()

void PsMat::SetupUvXfm ( int nPass)

Build the texture coordinate transform of a pass's stage into g_uvXfm and g_stageXfm.

The name is inferred.

Parameters
nPassThe pass.
Ghidra address:
NTSC-U/C: 0x00213c70
Ghidra address:
PAL: 0x0021ca88

◆ SelectDefault()

void PsMat::SelectDefault ( )
static

Forget the selected material and return the GS to opaque drawing with the default dither.

Ghidra address:
NTSC-U/C: 0x00213570
Ghidra address:
PAL: 0x0021c388

◆ SelectAlphaBlend()

void PsMat::SelectAlphaBlend ( )
static

Blend by the source alpha, and make the next Select() of the selected material select its blend again.

Ghidra address:
NTSC-U/C: 0x00213660
Ghidra address:
PAL: 0x0021c478

◆ Init()

void PsMat::Init ( )
static

Install the material factory for the class Mat of a .rnd file.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00213e38
Ghidra address:
PAL: 0x0021cc50

◆ New()

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

Create a material.

Parameters
pszNameThe registry key.
Returns
The material.
Ghidra address:
NTSC-U/C: 0x0037ca68
Ghidra address:
PAL: 0x003eb198

Member Data Documentation

◆ sCurrent

PsMat* PsMat::sCurrent
static

The material Select() last selected, or null.

Ghidra address:
NTSC-U/C: 0x003b0768
Ghidra address:
PAL: 0x0042f600

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