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

Lighting and fog a subtree is drawn under. More...

#include <environ.h>

Inheritance diagram for Rnd::Environ:
Collaboration diagram for Rnd::Environ:

Public Member Functions

 Environ (const HxStr &name)
 Construct an environment with no lights and no fog.
virtual ~Environ ()
virtual const HxStr & ClassName () const
 Report the class key a .rnd file writes for an environment.
virtual void DumpText (Dbg &sink)
 Write a description of this environment to sink.
virtual void Save (Stream &stream)
 Write this environment's serialised form to stream.
virtual void Replace (Object *pFrom, Object *pTo)
 Repoint a light entry when the object it addressed is replaced.
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy the state of pSource into this environment.
virtual void Load (Stream &stream)
 Read this environment's serialised form from stream.
void AddLight (Light *pLight)
 Append a light to mLights.
void RemoveLight (Light *pLight)
 Remove a light from mLights.
void RemoveAllLights ()
 Drop this environment's reference on every light and empty mLights.
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().

Static Public Member Functions

static Environ * NewEnviron (const HxStr &name)
 Build an environment the class registry vends.
static void * operator new (size_t nSize)
 Allocate an environment block under the tag "Rnd::Environ".
static void operator delete (void *pBlock)
 Release a block operator new() allocated.
Static Public Member Functions inherited from Rnd::Drawable
static Drawable * Find (const HxStr &name)
 Resolve a registry key to a drawable.

Public Attributes

std::list< Light * > mLights
 Lights this environment applies to the subtree below it.
Color mAmbient
 Light every vertex receives regardless of the lights above.
float mFogStart
 Distance fog starts at.
float mFogEnd
 Distance fog arrives at its full strength.
float mFogDensity
 Strength the exponential modes raise fog to.
Color mFogColor
 Colour a fully fogged pixel becomes.
FogMode mFogMode
 Which fog model applies, or None for no fog at all.
Public Attributes inherited from Rnd::Drawable
int mShowing
Public Attributes inherited from Rnd::Object
HxStr mName
int mInternal

Static Public Attributes

static HxStr sClassName
 Registered class name of Rnd::Environ, the string "Environ".
static Environ * sCurrent
 Environment the subtree being drawn is under.

Protected Member Functions

virtual int DrawShowing ()
 Make this environment the one the subtree below is drawn under.
Protected Member Functions inherited from Rnd::Drawable
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.

Additional Inherited Members

Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs

Detailed Description

Lighting and fog a subtree is drawn under.

Its RTTI descriptor is at 0x008ef500. It has Rnd::Drawable as its only public non-virtual base at offset 0. The allocator at 0x00519308 proves the class is 0x80 bytes by requesting exactly that much under the tag "Rnd::Environ". The constructor places the virtual Rnd::Object subobject at 0x60 by writing that address into the virtual-base pointer, and the four bytes after the subobject are tail padding.

Both colour members are quadword aligned in the original, which is what produces the reserved runs at 0x18 and 0x3c.

The member titles come from the text DumpText() writes: "lights:", "ambient:", " fogStart:", "fogEnd:", " fogDensity:", "fogColor:", and " fogMode:".

Two vtables belong to the class. The four-entry table at 0x00826d28 is addressed by the Rnd::Drawable vptr at 0x10 and declares no virtual of its own, and the eight-entry table at 0x00826ce0 is addressed by the Rnd::Object subobject vptr with a -0x60 adjustment on every entry.

Two routines that serve DumpText() are free functions rather than members, because each returns the sink it was handed. The one at 0x00519470 writes the name of a fog mode and the one at 0x005185b0 writes mLights, and both are declared beside the implementation rather than here because no code outside environ.cpp calls either.

The class has the tagged allocation pair every class in this tree gets from the allocation macro, under the tag "Rnd::Environ". The allocation is inlined into NewEnviron(), its one call site at 0x00519324, and no out-of-line copy of either half survives. Neither is declared here, for the same reason APalette declares neither: the macro generates them rather than a programmer writing them.

Constructor & Destructor Documentation

◆ Environ()

Rnd::Environ::Environ ( const HxStr & name)
explicit

Construct an environment with no lights and no fog.

The ambient colour starts fully transparent black, the fog colour fully opaque white, the fog start at 0.0, the fog end and the fog density at 1.0, and the fog mode at None.

Parameters
nameThe registry key for this object.
Ghidra address:
NTSC-U/C: 0x00515890
Ghidra address:
PAL: 0x00555bc0

◆ ~Environ()

virtual Rnd::Environ::~Environ ( )
virtual
Ghidra address:
NTSC-U/C: 0x00518fe0
Ghidra address:
PAL: 0x00559378

Member Function Documentation

◆ ClassName()

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

Report the class key a .rnd file writes for an environment.

The returned string is the global at 0x00718d18, which the class registration fills with "Environ".

Returns
The class key.
Ghidra address:
NTSC-U/C: 0x00519258
Ghidra address:
PAL: 0x005595f0

Implements Rnd::Object.

◆ DumpText()

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

Write a description of this environment to sink.

The base description comes first, and everything below is produced only at a positive dump level.

Parameters
sinkThe diagnostic sink to write to.
Ghidra address:
NTSC-U/C: 0x00515ce0
Ghidra address:
PAL: 0x00556010

Reimplemented from Rnd::Drawable.

◆ Save()

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

Write this environment's serialised form to stream.

The revision word is 0, which is also the highest Load() accepts, so the format never changed.

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

Reimplemented from Rnd::Drawable.

◆ Replace()

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

Repoint a light entry when the object it addressed is replaced.

An entry that already addresses pTo produces the report "%s already in %s" and is then replaced regardless. A replacement that is not a light empties the entry, and an empty entry is erased from the list rather than retained as a hole.

Parameters
pFromThe object going away.
pToThe object to store instead, or null.
Ghidra address:
NTSC-U/C: 0x005156b0
Ghidra address:
PAL: 0x005559e0

Reimplemented from Rnd::Drawable.

◆ Copy()

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

Copy the state of pSource into this environment.

The light list is copied only while bit 0 of nFlags is clear, and there is no disagreement with kCopyChildLists. The two are different bits of one word with opposite polarity. Bit 0 is an opt-out for the light list, tested here at 0x00516560 by exclusive-or against one followed by a mask. Bit 9 is an opt-in for the child draw list, tested by Rnd::Drawable::Copy() at 0x00506af0. This routine passes the same word into the base copy first, so one call tests both.

Parameters
pSourceThe environment to copy from.
nFlagsThe set of fields to copy.
Ghidra address:
NTSC-U/C: 0x00516560
Ghidra address:
PAL: 0x00556890

Reimplemented from Rnd::Drawable.

◆ Load()

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

Read this environment's serialised form from stream.

A revision above 0 is rejected with "Can't load new Environ". The fog mode arrives as a plain word and is assigned to the enumeration afterwards.

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

Reimplemented from Rnd::Drawable.

◆ NewEnviron()

Environ * Rnd::Environ::NewEnviron ( const HxStr & name)
static

Build an environment the class registry vends.

Parameters
nameThe registry key for the new environment.
Returns
The new environment.
Ghidra address:
NTSC-U/C: 0x00519308
Ghidra address:
PAL: 0x005596a0

◆ operator new()

void * Rnd::Environ::operator new ( size_t nSize)
static

Allocate an environment block under the tag "Rnd::Environ".

Parameters
nSizeThe block size.
Returns
The block.
Ghidra address:
NTSC-U/C: 0x00518df0
Ghidra address:
PAL: 0x00559188

◆ operator delete()

void Rnd::Environ::operator delete ( void * pBlock)
static

Release a block operator new() allocated.

Parameters
pBlockThe block.
Ghidra address:
NTSC-U/C: 0x00518e10
Ghidra address:
PAL: 0x005591a8

◆ AddLight()

void Rnd::Environ::AddLight ( Light * pLight)

Append a light to mLights.

A light already in the list is reported to Rnd::TheDbg as "<light> already in <environment>" and is not added again. Otherwise this environment registers as a referrer of the light, when it is not null, and the light is appended.

Parameters
pLightThe light to add.
Ghidra address:
NTSC-U/C: 0x005166d0
Ghidra address:
PAL: 0x00556a00

◆ RemoveLight()

void Rnd::Environ::RemoveLight ( Light * pLight)

Remove a light from mLights.

The first matching entry is erased, and this environment's reference on the light is dropped when the light is not null. A light not in the list is ignored. No call site survives in the shipped program, and the name is inferred from AddLight().

Parameters
pLightThe light to remove.
Ghidra address:
NTSC-U/C: 0x00516850
Ghidra address:
PAL: 0x00556b80

◆ RemoveAllLights()

void Rnd::Environ::RemoveAllLights ( )

Drop this environment's reference on every light and empty mLights.

AppTunnel's constructor calls it on "tunnel.env". The title is inferred.

Ghidra address:
NTSC-U/C: 0x00519568
Ghidra address:
PAL: 0x00559900

◆ DrawShowing()

virtual int Rnd::Environ::DrawShowing ( )
protectedvirtual

Make this environment the one the subtree below is drawn under.

Vtable slot 3 of the Rnd::Drawable table. Rnd::PsEnviron overrides it with the routine that also programs the fog registers and builds the light records.

Returns
Non-zero, which draws the children as well.
Ghidra address:
NTSC-U/C: 0x00518e60
Ghidra address:
PAL: 0x005591f8

Reimplemented from Rnd::Drawable.

Reimplemented in Rnd::PsEnviron.

Member Data Documentation

◆ sClassName

HxStr Rnd::Environ::sClassName
static

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

Ghidra address:
NTSC-U/C: 0x00718d18
Ghidra address:
PAL: 0x0075cc08

◆ sCurrent

Environ* Rnd::Environ::sCurrent
static

Environment the subtree being drawn is under.

Rnd::Environ::DrawShowing() stores itself here, and Rnd::PsEnviron::DrawShowing() stores its own environment the same way.

Ghidra address:
NTSC-U/C: 0x00718d20
Ghidra address:
PAL: 0x0075cc10

◆ mLights

std::list<Light *> Rnd::Environ::mLights

Lights this environment applies to the subtree below it.

+0x14

◆ mAmbient

Color Rnd::Environ::mAmbient

Light every vertex receives regardless of the lights above.

+0x20

◆ mFogStart

float Rnd::Environ::mFogStart

Distance fog starts at.

+0x30

◆ mFogEnd

float Rnd::Environ::mFogEnd

Distance fog arrives at its full strength.

+0x34

◆ mFogDensity

float Rnd::Environ::mFogDensity

Strength the exponential modes raise fog to.

The PlayStation 2 renderer does not read it. +0x38

◆ mFogColor

Color Rnd::Environ::mFogColor

Colour a fully fogged pixel becomes.

+0x40

◆ mFogMode

FogMode Rnd::Environ::mFogMode

Which fog model applies, or None for no fog at all.

+0x50


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