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

Surface description: blending, lighting colours, culling, and a list of texture stages. More...

#include <rndmat.h>

Inheritance diagram for RndMat:
Collaboration diagram for RndMat:

Classes

class  Stage
 One texture stage. More...

Public Types

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...

Public Member Functions

 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 RndObject * New (const char *pszName)
 Create a material.

Static Public Attributes

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.

Protected Member Functions

void ReleaseStageTex ()
 Drop the reference on every stage texture.

Protected Attributes

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

Surface description: blending, lighting colours, culling, and a list of texture stages.

The RTTI includes the class name and records RndObject as the one base. PsMat derives from it.

Member Enumeration Documentation

◆ Blend

How a surface or a texture stage combines with what is beneath it.

Enumerator
kBlendDest 

Keep the destination.

kBlendSrc 

Replace the destination.

kBlendAdd 

Add the source to the destination.

kBlendMultiply 

Multiply the destination by the source.

kBlendMultiply2 

Multiply the destination by twice the source.

kBlendSrcAlpha 

Blend by the source alpha.

kBlendSrcAlphaAdd 

Add the source scaled by its alpha.

kBlendSrcAdd 

Add the source.

kBlendInvSrcAlpha 

Blend by the inverse of the source alpha.

kBlendDestAlpha 

Blend by the destination alpha.

kBlendInvDestAlpha 

Blend by the inverse of the destination alpha.

kBlendSrcAlphaOpaque 

Blend by the source alpha and write opaque alpha.

kBlendSrcAlphaCutout 

Discard the source below an alpha threshold.

kBlendSubtract 

Subtract the source from the destination.

◆ TexGen

How a texture stage produces its texture coordinates.

Enumerator
kTexGenFixed 

Use the vertex coordinates.

kTexGenSphere 

Sphere map.

kTexGenPlanar 

Planar projection.

kTexGenOrthoCube 

Cube map in object space.

kTexGenLocalCube 

Cube map in local space.

◆ TexWrap

How texture coordinates outside the unit range wrap.

Enumerator
kTexWrapClamp 

Clamp to the edge.

kTexWrapRepeat 

Repeat.

kTexWrapMirror 

Repeat, mirroring every other copy.

Constructor & Destructor Documentation

◆ RndMat()

RndMat::RndMat ( const char * pszName)
explicit

Construct an enabled material that blends by source alpha, with a black base colour, a white light colour, and a black edge colour.

Parameters
pszNameThe registry key.
Ghidra address:
NTSC-U/C: 0x0022dd00
Ghidra address:
PAL: 0x002369b8

◆ ~RndMat()

RndMat::~RndMat ( )
override

Drop the references on the stage textures.

Ghidra address:
NTSC-U/C: 0x00384ea8
Ghidra address:
PAL: 0x003f35b0

Member Function Documentation

◆ operator new()

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

Allocate a material, billed to the class name.

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

◆ operator delete()

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

Release a material.

Parameters
pBlockThe block.

◆ DumpText()

void RndMat::DumpText ( PrnStream & stream)
overridevirtual

Write a description of the material.

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

Reimplemented from RndObject.

◆ Save()

void RndMat::Save ( BinStream & stream)
overridevirtual

Write the material.

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

Implements RndObject.

◆ Replace()

void RndMat::Replace ( RndObject * pFrom,
RndObject * pTo )
overridevirtual

Replace a stage texture with another object.

A replacement that is not a texture, or null, clears the stage texture.

Parameters
pFromThe object being replaced.
pToThe replacement, or null.
Ghidra address:
NTSC-U/C: 0x0022dc00
Ghidra address:
PAL: 0x002368b8

Implements RndObject.

◆ ClassName()

const char * RndMat::ClassName ( ) const
inlineoverridevirtual

Report the class name.

Returns
sClassName.
Ghidra address:
NTSC-U/C: 0x00384f68
Ghidra address:
PAL: 0x003f3670

Implements RndObject.

◆ Copy()

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

Copy another material.

The flat flag is not copied.

Parameters
pSourceThe material to copy from.
nFlagsThe set of fields to copy. The routine ignores it.
Ghidra address:
NTSC-U/C: 0x0022e9e0
Ghidra address:
PAL: 0x002375c8

Implements RndObject.

◆ Load()

void RndMat::Load ( BinStream & stream)
overridevirtual

Read what Save() wrote, or an earlier version of it.

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

Implements RndObject.

◆ SyncStage()

virtual void RndMat::SyncStage ( int nStage)
inlinevirtual

Bring the platform state of one stage up to date.

The base body is empty. The name is inferred.

Parameters
nStageThe stage.
Ghidra address:
NTSC-U/C: 0x00384e40
Ghidra address:
PAL: 0x003f3548

◆ SetBaseColor()

virtual void RndMat::SetBaseColor ( const Color & color)
inlinevirtual

Set the red, green, and blue of the base colour.

Parameters
colorThe colour. Its alpha is ignored.
Ghidra address:
NTSC-U/C: 0x00384e48
Ghidra address:
PAL: 0x003f3550

◆ SetLightColor()

virtual void RndMat::SetLightColor ( const Color & color)
inlinevirtual

Set the light colour.

Parameters
colorThe colour.
Ghidra address:
NTSC-U/C: 0x00384e68
Ghidra address:
PAL: 0x003f3570

◆ SetEdgeColor()

virtual void RndMat::SetEdgeColor ( const Color & color)
inlinevirtual

Set the edge colour.

Parameters
colorThe colour.
Ghidra address:
NTSC-U/C: 0x00384e78
Ghidra address:
PAL: 0x003f3580

◆ SetAlpha()

virtual void RndMat::SetAlpha ( float fAlpha)
inlinevirtual

Set the alpha of the base colour.

Parameters
fAlphaThe alpha.
Ghidra address:
NTSC-U/C: 0x00384e88
Ghidra address:
PAL: 0x003f3590

◆ SetLighting()

virtual void RndMat::SetLighting ( int bEnable,
int bVertBase,
int bVertLight,
int bVertEdge,
int bNormalize,
int bBaseAmbient )
virtual

Set the lighting switches.

Parameters
bEnableNon-zero to light the surface.
bVertBaseNon-zero to take the base colour from the vertices.
bVertLightNon-zero to take the light colour from the vertices.
bVertEdgeNon-zero to take the edge colour from the vertices.
bNormalizeNon-zero to normalise the normals.
bBaseAmbientNon-zero to light the base colour ambiently.
Ghidra address:
NTSC-U/C: 0x0022dbe0
Ghidra address:
PAL: 0x00236898

◆ Refresh()

virtual void RndMat::Refresh ( )
virtual

Take a reference on every stage texture and bring every stage up to date.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x0022e328
Ghidra address:
PAL: 0x00236f88

◆ AddStage()

void RndMat::AddStage ( )

Append a default stage.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x0022ead0
Ghidra address:
PAL: 0x002376b8

◆ New()

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

Create a material.

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

◆ GetBaseAmbient()

int RndMat::GetBaseAmbient ( ) const
inline
Returns
Non-zero to light the base colour ambiently.

◆ GetBaseColor()

const Color & RndMat::GetBaseColor ( ) const
inline
Returns
The base colour.

◆ GetBlend()

int RndMat::GetBlend ( ) const
inline
Returns
The Blend of the surface.

◆ SetBlend()

void RndMat::SetBlend ( int nBlend)
inline
Parameters
nBlendThe Blend of the surface.

◆ GetCull()

int RndMat::GetCull ( ) const
inline
Returns
The CullMode of the surface.

◆ SetCull()

void RndMat::SetCull ( int nCull)
inline
Parameters
nCullThe CullMode of the surface.

◆ GetEdgeColor()

const Color & RndMat::GetEdgeColor ( ) const
inline
Returns
The edge colour.

◆ GetLightColor()

const Color & RndMat::GetLightColor ( ) const
inline
Returns
The light colour.

◆ GetStages() [1/2]

const std::vector< Stage > & RndMat::GetStages ( ) const
inline
Returns
The texture stages.

◆ GetStages() [2/2]

std::vector< Stage > & RndMat::GetStages ( )
inline
Returns
The texture stages, for writing.

◆ GetVertBase()

int RndMat::GetVertBase ( ) const
inline
Returns
Non-zero to take the base colour from the vertices.

◆ GetVertLight()

int RndMat::GetVertLight ( ) const
inline
Returns
Non-zero to take the light colour from the vertices.

◆ ReleaseStageTex()

void RndMat::ReleaseStageTex ( )
protected

Drop the reference on every stage texture.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x0022e2c0
Ghidra address:
PAL: 0x00236f20

Member Data Documentation

◆ sClassName

const char* RndMat::sClassName
static

The class name a .rnd file writes, Mat.

Ghidra address:
NTSC-U/C: 0x003b09dc
Ghidra address:
PAL: 0x0042f874

◆ sRev

int RndMat::sRev
static

The format version Save() writes and Load() accepts.

Ghidra address:
NTSC-U/C: 0x003b09e0

◆ sLoadRev

int RndMat::sLoadRev
static

The version Load() read last, which Stage::Load() consults.

Ghidra address:
NTSC-U/C: 0x0043c688

◆ mStages

std::vector<Stage> RndMat::mStages
protected

The texture stages.

◆ mBlend

int RndMat::mBlend
protected

The Blend of the surface.

◆ mBaseColor

Color RndMat::mBaseColor
protected

The base colour.

◆ mLightColor

Color RndMat::mLightColor
protected

The light colour.

◆ mEdgeColor

Color RndMat::mEdgeColor
protected

The edge colour.

◆ mEnable

int RndMat::mEnable
protected

Non-zero to light the surface.

◆ mVertBase

int RndMat::mVertBase
protected

Non-zero to take the base colour from the vertices.

◆ mVertLight

int RndMat::mVertLight
protected

Non-zero to take the light colour from the vertices.

◆ mVertEdge

int RndMat::mVertEdge
protected

Non-zero to take the edge colour from the vertices.

◆ mNormalize

int RndMat::mNormalize
protected

Non-zero to normalise the normals.

◆ mBaseAmbient

int RndMat::mBaseAmbient
protected

Non-zero to light the base colour ambiently.

◆ mCull

int RndMat::mCull
protected

The CullMode of the surface.

◆ mFlat

int RndMat::mFlat
protected

Non-zero for flat shading.

◆ mMultiPass

int RndMat::mMultiPass
protected

The number of extra passes.


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