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

Camera, PlayStation 2. More...

#include <pscam.h>

Inheritance diagram for Rnd::PsCam:
Collaboration diagram for Rnd::PsCam:

Public Member Functions

 PsCam (const HxStr &name)
 Construct a camera with the default projection.
virtual ~PsCam ()
virtual int DrawShowing ()
 Make this camera the one the frame is drawn through and submit its display registers.
virtual Vector2 ScreenToPixels (const Vector2 &ptScreen)
 Place a point of the screen rectangle in render target pixels.
virtual void UpdateTargetAspect ()
 Take the aspect ratio from the render target and rebuild the projection.
virtual void SetTargetTex (Tex *pTex)
 Set the texture this camera draws into, or none to draw into the frame buffer.
Public Member Functions inherited from Rnd::Cam
void * operator new (size_t nSize)
 Allocate a camera from the tagged heap under the tag "Rnd::Cam".
void operator delete (void *pBlock)
 Release a camera to the tagged heap.
 Cam (const HxStr &name)
 Construct a camera with the default projection.
virtual ~Cam ()
 Clear Cam::sCurrent when it addresses this camera and release the render target.
void UpdateProjection ()
 Build the local frustum and both local projection matrices.
void UpdateWorldProject ()
 Compose the world projection, its inverse, and the world frustum.
Segment ScreenToRay (const Vector2 &ptScreen, float flLength)
 Build the segment under a point of the screen rectangle.
Vector2 ProjectToUnit (const Vector3 &pt)
 Place a world point in the unit square of the projected image.
Vector3 UnprojectFar (const Vector2 &ptUnit)
 Carry a point of the unit square of the projected image onto the far side of the projection.
void SetScreenRect (const Rect &rect)
 Replace mScreenRect and rebuild the projection.
void SetFrustum (float flNear, float flFar, float flFov)
 Set the clip distances and the field of view, then rebuild the projection.
float GetNearPlane () const
 Report the near clip distance.
float GetFarPlane () const
 Report the far clip distance.
float GetFov () const
 Report the field of view, zero for an orthographic projection.
void SetTargetTex (Tex *pTex)
 Set the texture this camera draws into, or none to draw into the frame buffer.
virtual const HxStr & ClassName () const
 Report the class key a .rnd file writes for a camera.
virtual void DumpText (Dbg &sink)
 Write a description of this camera to sink.
virtual void Replace (Object *pFrom, Object *pTo)
 Repoint the render target when the object it addressed is replaced.
virtual int UpdateWorldXfm (Transformable *pParent, int nForce)
 Recompose the world transform and, when it changed, the world projection.
virtual void Save (Stream &stream)
 Write this camera's serialised form to stream.
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy the state of pSource into this camera.
virtual void Load (Stream &stream)
 Read this camera's serialised form from stream.
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().
Public Member Functions inherited from Rnd::Transformable
 Transformable ()
 Construct a dirty transformable with identity transforms and no children.
virtual ~Transformable ()
 Drop this object's references on its children.
void AddTrans (Transformable *pTrans)
 Append pTrans to mTransList and mark it dirty.
void RemoveTrans (Transformable *pTrans)
 Erase pTrans from mTransList.
void RemoveAllTranses ()
 Drop this object's reference on every mTransList entry and empty the list.
Transformable * Parent ()
 Report the transformable that positions this one.
virtual void SetBillboard (int nBillboard)
 Set the billboard mode and mark the transform dirty.
void SetOrigin (const float *pOrigin)
 Set the origin row and mark the transform dirty.
float * GetDrawXfm ()
 Build the transform this object draws with and return it.
Public Member Functions inherited from Rnd::Collideable
 Collideable ()
 Construct a collideable with no children.
virtual ~Collideable ()
 Drop this object's references on its children.
Collideable * Parent ()
 Report the collideable that hit-tests this one.
void AddCollide (Collideable *pCollide)
 Append pCollide to mCollides.
void RemoveCollide (Collideable *pCollide)
 Erase pCollide from mCollides.
virtual void FindCollisions (const Segment &ray, std::list< Collision > &collisions)
 Test a segment against this object and append what it strikes to collisions.

Static Public Member Functions

static Cam * NewCam (const HxStr &name)
 Build a camera the class registry vends.
static void Init ()
 Install the PlayStation 2 camera factory and build the default camera.
static void Terminate ()
 Undo what Init() installs.
Static Public Member Functions inherited from Rnd::Cam
static Cam * NewCam (const HxStr &name)
 Build a camera the class registry vends.
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 PsCam * sDefault
 Camera the renderer falls back on when a scene selects none.
Static Public Attributes inherited from Rnd::Cam
static Cam * sCurrent
 Camera the frame is being drawn through.
static Cam *(* sNew )(const HxStr &name)
 Creator the registered "Cam" class builds through.
static HxStr sClassName
 Registered class name of Rnd::Cam, the string "Cam".

Additional Inherited Members

Public Types inherited from Rnd::Transformable
enum  Billboard {
  kBillboardNone = 0 , kBillboardX = 1 , kBillboardY = 2 , kBillboardZ = 4 ,
  kBillboardXZ = 8 , kBillboardXYZ = 16 , kBillboardSimpleXYZ = 32 , kBillboardLocalRotate = 64 ,
  kBillboardScaleX = 129 , kBillboardScaleY = 130 , kBillboardScaleZ = 132 , kBillboardScaleXZ = 136 ,
  kBillboardScaleXYZ = 144 , kBillboardScaleSimpleXYZ = 160
}
 Mode mBillboard selects, recovered from the name dumper at 0x004f26f0. More...
Public Attributes inherited from Rnd::Cam
Vector3 mWorldToCam [kXfmRowCount]
 Inverse of the world transform, which maps world space into camera space.
Vector3 mLocalProject [kXfmRowCount]
 Projection from camera space onto the screen rectangle.
Vector3 mWorldProject [kXfmRowCount]
 mWorldToCam followed by mLocalProject.
Vector3 mInvWorldProject [kXfmRowCount]
 mInvLocalProject followed by the world transform.
Frustum mWorldFrustum
 The view volume in world space.
Rect mScreenRect
 Fraction of the render target the projected image is placed in.
Tex * mpTargetTex
 Texture this camera draws into, or null to draw into the frame buffer.
Public Attributes inherited from Rnd::Drawable
int mShowing
Public Attributes inherited from Rnd::Object
HxStr mName
int mInternal
Public Attributes inherited from Rnd::Transformable
float mLocalXfm [kXfmRowCount][kXfmRowFloatCount]
 Transform this object is positioned by, before the parent transform is applied.
float mWorldXfm [kXfmRowCount][kXfmRowFloatCount]
 Composed world transform.
int mDirty
 Set by every writer of a transform field and cleared once UpdateWorldXfm has recomposed.
Protected Member Functions inherited from Rnd::Cam
virtual void FindCollisions (const Vector2 &point, std::list< Collision > &collisions)
 Report whether a screen point lies inside the screen rectangle.
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.
Protected Member Functions inherited from Rnd::Transformable
void AdoptXfmFrom (const Transformable &owner)
 Adopt the transform of an owner this object is being detached from.
void ReleaseTransRefs ()
 Drop this object's reference on every mTransList entry without emptying the list.
Protected Member Functions inherited from Rnd::Collideable
void ReleaseCollidesRefs ()
 Drop this object's reference on every mCollides entry without emptying the list.
Protected Attributes inherited from Rnd::Cam
Frustum mLocalFrustum
float mNearPlane
float mFarPlane
float mFov
float mYRatio
Vector2 mZRange
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs
Protected Attributes inherited from Rnd::Transformable
float mOrigin [kXfmRowFloatCount]
int mBillboard

Detailed Description

Camera, PlayStation 2.

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

Four vtables belong to the class. The seven-entry table at 0x0082f2e0 is addressed by the Rnd::Drawable vptr at 0x10, the three-entry table at 0x0082f2c0 by the Rnd::Transformable vptr at 0xc8, the three-entry table at 0x0082f2a0 by the Rnd::Collideable vptr at 0xd8, and the eight-entry table at 0x0082f258 by the Rnd::Object subobject vptr. Every entry beyond the ones below stores the implementation Rnd::Cam supplies.

The seventh entry of the first table proves SetTargetTex() is a virtual declared here rather than an override. The base table has six entries and this one has seven.

Constructor & Destructor Documentation

◆ PsCam()

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

Construct a camera with the default projection.

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

◆ ~PsCam()

virtual Rnd::PsCam::~PsCam ( )
virtual
Ghidra address:
NTSC-U/C: 0x005826e0
Ghidra address:
PAL: 0x005c58d8

Member Function Documentation

◆ DrawShowing()

virtual int Rnd::PsCam::DrawShowing ( )
virtual

Make this camera the one the frame is drawn through and submit its display registers.

Vtable slot 3 of the Rnd::Drawable table. A render target is bound through Rnd::PsTex::BindAsRenderTarget(), and a camera following one that drew into a texture points the GS back at the display buffer. The routine then computes the guard band, widens the four side planes of the local frustum by it, moves all six planes into world space as Rnd::g_drawFrustum, builds the viewport and projection transforms, programs SCISSOR_1 from the screen rectangle clamped to the unit square, and stores itself in Cam::sCurrent. It does not call the base implementation.

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

Reimplemented from Rnd::Cam.

◆ ScreenToPixels()

virtual Vector2 Rnd::PsCam::ScreenToPixels ( const Vector2 & ptScreen)
virtual

Place a point of the screen rectangle in render target pixels.

Vtable slot 4 of the Rnd::Drawable table. The point is scaled by the screen rectangle extents and offset by its origin, then scaled again by the size of the render target, or by the display size of Rnd::ThePs when there is no render target.

Parameters
ptScreenThe point, in the coordinates the screen rectangle is expressed in.
Returns
The same point in render target pixels.
Ghidra address:
NTSC-U/C: 0x005885b0
Ghidra address:
PAL: 0x005cb810

Reimplemented from Rnd::Cam.

◆ UpdateTargetAspect()

virtual void Rnd::PsCam::UpdateTargetAspect ( )
virtual

Take the aspect ratio from the render target and rebuild the projection.

Vtable slot 5 of the Rnd::Drawable table. With no render target the vertical ratio becomes the 0.75 of a four by three display, which is the default the base implementation has no way to supply. The base then runs.

Ghidra address:
NTSC-U/C: 0x00588578
Ghidra address:
PAL: 0x005cb7d8

Reimplemented from Rnd::Cam.

◆ SetTargetTex()

virtual void Rnd::PsCam::SetTargetTex ( Tex * pTex)
virtual

Set the texture this camera draws into, or none to draw into the frame buffer.

Vtable slot 6 of the Rnd::Drawable table, which is a slot of its own rather than an override of the base routine of the same title. The base routine runs first, and clearing the render target then restores the vertical ratio of a four by three display.

Parameters
pTexThe render target, or null to draw into the frame buffer.
Ghidra address:
NTSC-U/C: 0x00588498
Ghidra address:
PAL: 0x005cb6f8

◆ NewCam()

Cam * Rnd::PsCam::NewCam ( const HxStr & name)
static

Build a camera the class registry vends.

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

Parameters
nameThe registry key for the new camera.
Returns
The new camera.
Ghidra address:
NTSC-U/C: 0x00588500
Ghidra address:
PAL: 0x005cb760

◆ Init()

void Rnd::PsCam::Init ( )
static

Install the PlayStation 2 camera factory and build the default camera.

Rnd::Cam::sNew becomes NewCam(), which is how a .rnd file naming the unchanged "Cam" key loads this subclass. The camera named "[default cam]" is then built, marked internal, and placed at the translation (0, -150, 0) with its dirty flag set, which puts the default viewpoint 150 units back along the axis this engine looks down.

Ghidra address:
NTSC-U/C: 0x00582430
Ghidra address:
PAL: 0x005c5608

◆ Terminate()

void Rnd::PsCam::Terminate ( )
inlinestatic

Undo what Init() installs.

Destroys PsCam::sDefault through its virtual destructor, without clearing the pointer, and then runs Rnd::RegisterCamClass(). The out-of-line copy has no caller, and GfxDevice::Terminate() expands the body at 0x0049b01c. The name is inferred from GfxDevice::Terminate().

Ghidra address:
NTSC-U/C: 0x00588428
Ghidra address:
PAL: 0x005cb688

Member Data Documentation

◆ sDefault

PsCam* Rnd::PsCam::sDefault
static

Camera the renderer falls back on when a scene selects none.

Rnd::GfxDevice::BeginFrame() reads it, and Rnd::PsEnviron::Init() makes the default environment and the default light children of it.

Ghidra address:
NTSC-U/C: 0x00768410
Ghidra address:
PAL: 0x007ac160

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