|
resonance 1.0.1
|
Surface description a Rnd::Mesh draws with. More...
#include <mat.h>


Classes | |
| class | Stage |
| One texture stage of a material. More... | |
Public Types | |
| enum | BlendMode { kBlendModeDest = 0 , kBlendModeSrc = 1 , kBlendModeAdd = 2 , kBlendModeMultiply = 3 , kBlendModeMultiply2 = 4 , kBlendModeSrcAlpha = 5 , kBlendModeSrcAlphaAdd = 6 , kBlendModeSrcAdd = 7 , kBlendModeInvSrcAlpha = 8 , kBlendModeDestAlpha = 9 , kBlendModeInvDestAlpha = 10 , kBlendModeSrcAlphaOpaque = 11 , kBlendModeSrcAlphaCutout = 12 } |
| Frame buffer blend, as the text dump labels the values. More... | |
| enum | Cull { kCullModeCw = 0 , kCullModeCcw = 1 , kCullModeNone = 2 } |
| Face winding the rasteriser discards, as the text dump labels the values. More... | |
| enum | TexGen { kGenModeFixed = 0 , kGenModeSphere = 1 , kGenModePlanar = 2 , kGenModeOrthoCube = 3 , kGenModeLocalCube = 4 } |
| How a texture stage produces its texture coordinates. More... | |
| enum | TexWrap { kWrapModeClamp = 0 , kWrapModeRepeat = 1 , kWrapModeMirror = 2 } |
| How a texture coordinate outside the unit square resolves. More... | |
| enum | { kSerialVersion = 7 } |
| Serial version this build writes, and the highest version it loads. More... | |
Public Member Functions | |
| Mat (const HxStr &name) | |
| Construct a material with the default surface. | |
| virtual | ~Mat () |
| void | AddStage () |
| Append one stage with the default surface, owned by this material. | |
| void | RemoveStage (int nIndex) |
| Remove one stage, dropping this material's reference on its texture. | |
| void | GetMeshReferrers (std::vector< Mesh * > &meshes) |
| Append every referrer of this material whose class is "Mesh" to meshes. | |
| virtual void | DumpText (Dbg &sink) |
| Write the material to the engine text sink. | |
| virtual void | Save (Stream &stream) |
| Serialise the material. | |
| virtual void | Replace (Object *pFrom, Object *pTo) |
| Replace one object reference with another. | |
| virtual const HxStr & | ClassName () const |
| Return the registered class name, "Mat". | |
| virtual void | Copy (const Object *pSource, unsigned nFlags) |
| Copy another material over this one. | |
| virtual void | Load (Stream &stream) |
| Load the material. | |
| virtual void | SyncMat (int nStage) |
| Virtual with an empty body in Rnd::Mat. | |
| virtual void | SetAmbient (const Color &color) |
| Set the ambient colour. | |
| virtual void | SetDiffuse (const Color &color) |
| Set the diffuse colour, retaining the current alpha. | |
| virtual void | SetEmissive (const Color &color) |
| Set the emissive colour. | |
| virtual void | SetAlpha (float flAlpha) |
| Set the diffuse alpha. | |
| virtual void | SetSpecular (const Color &color, float flAlpha) |
| Set the specular colour and its alpha. | |
| virtual void | SetLighting (int nEnable, int nVertAmbient, int nVertDiffuse, int nVertSpecular, int nVertEmissive, int nVertAlpha, int nNormalize) |
| Set the lighting enable flag, the five per-vertex source flags, and the normalise flag. | |
| virtual void | Refresh () |
| Resynchronise the material after its state or its stage vector has changed. | |
| void | SetMultiPass (int nMultiPass) |
| Set the multi-pass count. | |
| void | SetFlat (int nFlat) |
| Set whether the surface shades flat. | |
| 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(). | |
Static Public Member Functions | |
| static void * | operator new (size_t nSize) |
| Allocate a material block under the tag "Rnd::Mat". | |
| static void | operator delete (void *pBlock) |
| Release a material block under the same tag. | |
Public Attributes | |
| std::vector< Stage > | mStages |
| Color | mEmissive |
| Colour the surface emits. | |
| Color | mAmbient |
| Ambient colour. | |
| Color | mDiffuse |
| Diffuse colour. | |
| Color | mSpecular |
| int | mVertAmbient |
| Non-zero when the vertex colour supplies the ambient term in place of mAmbient. | |
| int | mVertDiffuse |
| Non-zero when the vertex colour supplies the diffuse term in place of mDiffuse. | |
| int | mVertEmissive |
| Vertex emissive flag. | |
| int | mVertAlpha |
| Vertex alpha flag. | |
| Cull | mCull |
| int | mFlat |
| Public Attributes inherited from Rnd::Object | |
| HxStr | mName |
| int | mInternal |
Static Public Attributes | |
| static HxStr | sClassName |
| Registered class name of Rnd::Mat, the string "Mat". | |
Protected Member Functions | |
| void | RemoveStageTexRefs () |
| Drop this material's reference on every stage texture. | |
| Protected Member Functions inherited from Rnd::Object | |
| void | ReleaseAllRefs () |
| Tell every referrer to drop its pointer to this object. | |
Protected Attributes | |
| BlendMode | mBlend |
| int | mEnable |
| int | mVertSpecular |
| int | mNormalize |
| int | mMultiPass |
| Protected Attributes inherited from Rnd::Object | |
| std::list< Object * > | mRefs |
Surface description a Rnd::Mesh draws with.
Its RTTI descriptor is at 0x008ef0e0. It has Rnd::Object as its one public non-virtual base at offset 0. The Object subobject is 0x1c bytes. The material's members start at +0x1c and the whole object is 0xa0 bytes.
A material combines the four lighting colours, the flags that pick per-vertex colours over the material colours, and a vector of texture stages. The stage vector is what binds textures; the material itself has no texture reference.
The PlayStation 2 subclass Rnd::PsMat adds the hardware binding path and overrides the one material virtual to invalidate the cached register state.
| enum Rnd::Mat::BlendMode |
Frame buffer blend, as the text dump labels the values.
The same enumeration types a texture stage, where the default is kBlendModeMultiply.
| enum Rnd::Mat::Cull |
| enum Rnd::Mat::TexGen |
How a texture stage produces its texture coordinates.
| Enumerator | |
|---|---|
| kGenModeFixed | Use the vertex coordinates as they are. |
| kGenModeSphere | Sphere map. |
| kGenModePlanar | Planar projection. |
| kGenModeOrthoCube | Cube map in object space. |
| kGenModeLocalCube | Cube map in local space. |
| enum Rnd::Mat::TexWrap |
| anonymous enum |
| Rnd::Mat::Mat | ( | const HxStr & | name | ) |
Construct a material with the default surface.
Ambient and diffuse start white, emissive and specular start black with full alpha, the blend starts at kBlendModeSrcAlpha, and lighting starts enabled.
| name | The object name, passed to the Rnd::Object constructor. |
|
virtual |
|
static |
Allocate a material block under the tag "Rnd::Mat".
| nSize | The object size the compiler supplies. |
|
static |
Release a material block under the same tag.
| pBlock | The block. |
| void Rnd::Mat::AddStage | ( | ) |
Append one stage with the default surface, owned by this material.
The routine has no caller in the shipped build. The name is inferred.
| void Rnd::Mat::RemoveStage | ( | int | nIndex | ) |
Remove one stage, dropping this material's reference on its texture.
The index is not checked. The routine has no caller in the shipped build. The name is inferred.
| nIndex | The position of the stage. |
| void Rnd::Mat::GetMeshReferrers | ( | std::vector< Mesh * > & | meshes | ) |
Append every referrer of this material whose class is "Mesh" to meshes.
Walks the referrer list in order and appends each match through dynamic_cast. TnlArena's constructor is the one caller. The definition sits in the TnlArena unit, and the title is inferred.
| meshes | The vector to append to. |
|
protected |
Drop this material's reference on every stage texture.
Walks mStages and calls Rnd::Object::RemoveRef() for each stage whose mTex is set. Both destructors in the hierarchy call it out of line, this class's at 0x004dbb10 and Rnd::PsMat's at 0x005915d4, which is the evidence for protected rather than private access. Copy() and Load() inline the same body instead of calling it.
|
virtual |
Write the material to the engine text sink.
| sink | The text sink. |
Reimplemented from Rnd::Object.
|
virtual |
Serialise the material.
| stream | The stream to write to. |
Implements Rnd::Object.
Replace one object reference with another.
A material references objects only through its stages, so the routine walks the stage vector and swaps every texture reference whose current value is the old object.
| pFrom | The object being replaced. |
| pTo | The object to point at, which may be null. |
Implements Rnd::Object.
|
virtual |
Return the registered class name, "Mat".
The key is the one a data file writes for the class, which the registry at Rnd::Manager::Init() maps to the creator at 0x004dbc80.
Implements Rnd::Object.
|
virtual |
Copy another material over this one.
| pSource | The source object, which has to be a material for the copy to have any effect. |
| nFlags | The copy flags. |
Implements Rnd::Object.
|
virtual |
Load the material.
Reports "Can't load new Mat" through the failure sink when the file version exceeds kSerialVersion. A file below version 3 stores a source factor and a destination factor instead of a blend mode, and the loader folds the pair into the nearest blend mode.
| stream | The stream to read from. |
Implements Rnd::Object.
|
virtual |
Virtual with an empty body in Rnd::Mat.
No subclass in the shipped build overrides it, so its purpose is undetermined. It fills the ninth vtable slot.
| nStage | The stage index. Ignored by the body. Refresh() passes the index of each stage in turn, and TnlCatcher::SetMultiplied() passes 0 (0x004552ac). |
|
virtual |
Set the ambient colour.
Rnd::PsMat overrides the setter to invalidate the cached hardware material state.
| color | The new ambient colour. |
Reimplemented in Rnd::PsMat.
|
virtual |
Set the diffuse colour, retaining the current alpha.
The body reads three floats and the fourth component of the argument is discarded, so the parameter type is not recoverable from the body alone. The one caller fixes it. Rnd::MatAnim::SetFrameSelf() blends the diffuse channel over all four components with vmulax.xyzw at 0x004d5028, stores the whole quadword into the temporary it passes, and blends the three stage channels of the same routine over three components with vmulax.xyz instead. The argument is therefore a Color and not a Vector3.
| color | The new diffuse colour, whose alpha is discarded. |
Reimplemented in Rnd::PsMat.
|
virtual |
Set the emissive colour.
| color | The new emissive colour. |
Reimplemented in Rnd::PsMat.
|
virtual |
Set the diffuse alpha.
| flAlpha | The new alpha. |
Reimplemented in Rnd::PsMat.
|
virtual |
Set the specular colour and its alpha.
The colour argument is a Color on the same evidence as SetDiffuse(), the specular blend at 0x004d54d8 being the fourth of the four quadword blends. The alpha of the colour is discarded and the separate argument is stored in its place, and the only caller passes zero for it.
| color | The new specular colour, whose alpha is discarded. |
| flAlpha | The new specular alpha. |
Reimplemented in Rnd::PsMat.
|
virtual |
Set the lighting enable flag, the five per-vertex source flags, and the normalise flag.
| nEnable | Whether lighting applies at all. |
| nVertAmbient | Whether the ambient term comes from the vertex. |
| nVertDiffuse | Whether the diffuse term comes from the vertex. |
| nVertSpecular | Whether the specular term comes from the vertex. |
| nVertEmissive | Whether the emissive term comes from the vertex. |
| nVertAlpha | Whether the alpha comes from the vertex. |
| nNormalize | Whether normals are renormalised. |
|
virtual |
Resynchronise the material after its state or its stage vector has changed.
Copy() finishes with this call. The name is inferred from the position of the call and from the stage vector the routine walks.
| void Rnd::Mat::SetMultiPass | ( | int | nMultiPass | ) |
Set the multi-pass count.
| nMultiPass | The new count. |
| void Rnd::Mat::SetFlat | ( | int | nFlat | ) |
Set whether the surface shades flat.
| nFlat | Non-zero for flat shading. |
|
static |
Registered class name of Rnd::Mat, the string "Mat".
| std::vector<Stage> Rnd::Mat::mStages |
|
protected |
| Color Rnd::Mat::mEmissive |
Colour the surface emits.
Defaults to black with full alpha. +0x30
Public because HudPoints::SetFrame() at 0x00418de8 copies it directly through a Rnd::Mat pointer from outside the hierarchy to colour a text, and the image has no accessor for it.
| Color Rnd::Mat::mAmbient |
Ambient colour.
Defaults to white. +0x40
Public because EmitFaceVu1Setup(), SelectLightForVertex(), and the PsMesh upload at 0x00583ba0 read it directly through Rnd::PsMat::sCurrent, and the image has no accessor.
| Color Rnd::Mat::mDiffuse |
Diffuse colour.
Defaults to white. +0x50
Public on the same evidence as mAmbient.
| Color Rnd::Mat::mSpecular |
|
protected |
| int Rnd::Mat::mVertAmbient |
Non-zero when the vertex colour supplies the ambient term in place of mAmbient.
Serialised as one byte. +0x74
Public because EmitFaceVu1Setup(), SelectLightForVertex(), and the PsMesh upload at 0x00583ba0 read it directly through Rnd::PsMat::sCurrent, and the image has no accessor.
| int Rnd::Mat::mVertDiffuse |
Non-zero when the vertex colour supplies the diffuse term in place of mDiffuse.
Serialised as one byte. +0x78
Public on the same evidence as mVertAmbient.
|
protected |
| int Rnd::Mat::mVertEmissive |
Vertex emissive flag.
Serialised as one byte. +0x80
Public on the same evidence as mVertAmbient.
| int Rnd::Mat::mVertAlpha |
Vertex alpha flag.
Serialised as one byte. +0x84
Public on the same evidence as mVertAmbient.
|
protected |
| Cull Rnd::Mat::mCull |
< Winding the rasteriser discards. Public because Rnd::Mesh::FindCollisions() at 0x0047f950 reads it directly to decide whether a back-facing hit counts, which is access from outside the hierarchy, and the image has no accessor for it. +0x8c
|
protected |
| int Rnd::Mat::mFlat |
< Non-zero for flat shading. Serialised as one byte. Public because Rnd::Mesh::ComputeNormals() at 0x00485ef0 and Rnd::Mesh::WeldVerts() at 0x00483e70 read it directly, which is access from outside the hierarchy, and the image has no accessor for it. +0x94