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

Lighting and fog a subtree is drawn under, PlayStation 2. More...

#include <psenviron.h>

Inheritance diagram for Rnd::PsEnviron:
Collaboration diagram for Rnd::PsEnviron:

Public Member Functions

 PsEnviron (const HxStr &name)
 Construct an environment with no lights and no fog.
virtual ~PsEnviron ()
Public Member Functions inherited from Rnd::Environ
 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 a PlayStation 2 environment the class registry vends.
static void Init ()
 Install the PlayStation 2 environment factory and build the default scene fixtures.
static void Terminate ()
 Undo what Init() installs.
Static Public Member Functions inherited from Rnd::Environ
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.

Static Public Attributes

static std::vector< DirectionalLightRecord > sDirLights
 Directional lights of the current environment, rebuilt by DrawShowing().
static std::vector< PointLightRecord > sPointLights
 Point lights of the current environment, rebuilt by DrawShowing().
Static Public Attributes inherited from Rnd::Environ
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 current one, program fog, and build the light records.
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

Public Attributes inherited from Rnd::Environ
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
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs

Detailed Description

Lighting and fog a subtree is drawn under, PlayStation 2.

Its RTTI descriptor is at 0x008ef250. It has Rnd::Environ as its only public non-virtual base at offset 0. The class does not add a data member. Its allocator at 0x005b27b0 requests the same 0x80 bytes the base does, under the same "Rnd::Environ" tag, and its constructor writes only the two vtable pointers.

Two vtables belong to the class. The four-entry table at 0x00833968 is addressed by the Rnd::Drawable vptr at 0x10, and the eight-entry table at 0x00833920 by the Rnd::Object subobject vptr. DrawShowing() is the only entry that is not the base implementation.

Constructor & Destructor Documentation

◆ PsEnviron()

Rnd::PsEnviron::PsEnviron ( const HxStr & name)
inlineexplicit

Construct an environment with no lights and no fog.

NewEnviron() and Init() both open-code the body. The out-of-line copy has no caller.

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

◆ ~PsEnviron()

virtual Rnd::PsEnviron::~PsEnviron ( )
virtual
Ghidra address:
NTSC-U/C: 0x005b2200
Ghidra address:
PAL: 0x005f47d0

Member Function Documentation

◆ NewEnviron()

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

Build a PlayStation 2 environment the class registry vends.

The return type is the base class, which is what lets Init() store the routine in Rnd::g_pfnNewEnviron.

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

◆ Init()

void Rnd::PsEnviron::Init ( )
static

Install the PlayStation 2 environment factory and build the default scene fixtures.

Rnd::g_pfnNewEnviron becomes NewEnviron(), which is how a .rnd file naming the unchanged "Environ" key loads this subclass. The environment named "[default environ]" is then built with a direct allocation rather than through the factory, marked internal, and added to the draw list of Rnd::PsCam::sDefault. A light named "[default light]" follows, built through Rnd::g_pfnNewLight, marked internal, added to the environment, and made a transform child of Rnd::PsCam::sDefault.

Ghidra address:
NTSC-U/C: 0x005aea68
Ghidra address:
PAL: 0x005f0fd0

◆ Terminate()

void Rnd::PsEnviron::Terminate ( )
static

Undo what Init() installs.

Destroys g_pDefaultEnviron and then g_pDefaultLight through their virtual destructors, without clearing either pointer, and then expands the "Environ" class registration, whose out-of-line copy is at 0x00518e70. GfxDevice::Terminate() is the one caller. The name is inferred from GfxDevice::Terminate().

Ghidra address:
NTSC-U/C: 0x005b2888
Ghidra address:
PAL: 0x005f4e58

◆ DrawShowing()

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

Make this environment the current one, program fog, and build the light records.

Vtable slot 3 of the Rnd::Drawable table. Rnd::g_nFogEnabled becomes non-zero whenever the fog mode is anything other than None, and the two fog terms are then set so that a camera space depth maps onto the byte range the GS fog register takes. The scale is 255.0 divided by the fog start less the fog end, and the offset is the negated fog end scaled by it. With no fog the scale is zero and the offset 255.0, which fogs no pixel at all. The fog colour is packed into the low three bytes of GS register 0x3d.

Both record vectors are then emptied and each entry of mLights appended to one of them, a directional light contributing the negated second basis row of its world transform and a point light its translation row and its range. A spot light is skipped. The routine ends by making this environment Rnd::Environ::sCurrent.

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

Reimplemented from Rnd::Environ.

Member Data Documentation

◆ sDirLights

std::vector<DirectionalLightRecord> Rnd::PsEnviron::sDirLights
static

Directional lights of the current environment, rebuilt by DrawShowing().

Ghidra address:
NTSC-U/C: 0x00776120
Ghidra address:
PAL: 0x007b9ff8

◆ sPointLights

std::vector<PointLightRecord> Rnd::PsEnviron::sPointLights
static

Point lights of the current environment, rebuilt by DrawShowing().

Ghidra address:
NTSC-U/C: 0x00776130
Ghidra address:
PAL: 0x007ba008

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