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

Camera. More...

#include <rndcam.h>

Inheritance diagram for RndCam:
Collaboration diagram for RndCam:

Public Member Functions

 RndCam (const char *pszName)
 Construct a camera looking along y with a quarter-turn field of view, from 1 to 1000 units.
 ~RndCam () override
 Release the camera and stop drawing through it.
void * operator new (size_t nSize)
 Allocate a camera, billed to the class name.
void operator delete (void *pBlock)
 Release a camera.
void ListDrawObjects (std::list< RndObject * > &objects) override
 Add the camera itself to a list.
void ListDrawables (std::list< RndDrawable * > &drawables) override
 Make the camera current and add the drawables of the children to a list.
int DrawShowing () override
 Make the camera current.
int UpdateWorldXfm (RndTransformable *pParent, int bForce) override
 Recompute the world transform, and the world projection when it changed.
void Collide (const Vector2 &point, std::list< Collision > &collisions) override
 Record the camera as struck when a screen point falls inside mScreenRect, then test the children.
void DumpText (PrnStream &stream) override
 Write a description of the camera and its bases.
void Save (BinStream &stream) override
 Write the camera and its bases.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace a referenced object with another.
const char * ClassName () const override
 Report the class name.
void Copy (const RndObject *pSource, int nFlags) override
 Copy another camera and its bases.
void Load (BinStream &stream) override
 Read what Save() wrote, or an earlier version of it.
void WorldToScreen (const Vector3 &world, Vector2 &screen) const
 Project a world point to a screen point through mWorldProject and mScreenRect.
void SetTargetTex (RndTex *pTex)
 Render into a texture rather than the display, or stop.
void SetFrustum (float fNear, float fFar, float fFov)
 Set the view volume.
void UpdateProjection ()
 Rebuild the local projection and the local view volume, then the world projection.
void UpdateWorldProject ()
 Rebuild the world projection and the world view volume from the world transform.
float GetFarPlane () const
float GetFov () const
const Transform & GetInvWorldXfm () const
const Transform & GetLocalProject () const
float GetNearPlane () const
const Transform & GetOrthoWorldXfm () const
const Rect & GetScreenRect () const
void SetScreenRect (const Rect &rect)
RndTex * GetTargetTex () const
const Frustum & GetWorldFrustum () const
const Vector2 & GetZRange () const
void SetZRange (const Vector2 &range)
virtual void Collide (const Segment &segment, std::list< Collision > &collisions)
 Test a segment against the collideable and add what it strikes to a list.
Public Member Functions inherited from RndDrawable
 RndDrawable ()
 Construct a showing drawable without a highlight or children.
 ~RndDrawable () override
 Drop the references on the children.
virtual void SetShowing (int nShowing)
 Set whether the drawable draws at all.
virtual void SetHighlight (int nHighlight)
 Set whether the drawable draws with its highlight treatment.
void DumpText (PrnStream &stream) override
 Write a description of the drawable.
void Save (BinStream &stream) override
 Write the showing flag and the names of the children.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace a child with another object.
void Copy (const RndObject *pSource, int nFlags) override
 Copy the showing flag, and the children when the flags request them.
void Load (BinStream &stream) override
 Read what Save() wrote.
RndDrawable * Parent ()
 Find the drawable whose children include this one.
void Draw ()
 Draw the drawable and then its children, when it is showing.
bool AddDraw (RndDrawable *pDraw, RndDrawable *pBefore)
 Add a child before another.
void RemoveDraw (RndDrawable *pDraw)
 Remove a child.
void ClearDraws ()
 Remove every child.
int GetShowing () const
const std::list< RndDrawable * > & GetDraws () 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)
Public Member Functions inherited from RndTransformable
 RndTransformable ()
 Construct a transformable with identity transforms, no origin offset, and no billboard.
 ~RndTransformable () override
 Drop the references on the children.
virtual void SetBillboard (int nBillboard)
 Set the billboard mode.
void DumpText (PrnStream &stream) override
 Write a description of the transformable.
void Save (BinStream &stream) override
 Write the transforms, the names of the children, the billboard mode, and the origin.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace a child with another object.
void Copy (const RndObject *pSource, int nFlags) override
 Copy the transforms, the billboard mode, the origin, and the children when the flags request them.
void Load (BinStream &stream) override
 Read what Save() wrote, or an earlier version of it.
void SetOrigin (const Vector3 &origin)
 Set the point the world transform subtracts first when there is no billboard.
RndTransformable * Parent ()
 Find the transformable whose children include this object.
bool AddTrans (RndTransformable *pTrans)
 Append a child and mark its world transform dirty.
void RemoveTrans (RndTransformable *pTrans)
 Remove a child.
void ClearTrans ()
 Remove every child.
const Transform & BillboardXfm ()
 Report the world transform turned to face the current camera.
const Transform & GetLocalXfm () const
Transform & GetLocalXfm ()
void SetLocalXfm (const Transform &xfm)
const Transform & GetWorldXfm () const
Transform & GetWorldXfm ()
int GetDirty () const
void SetDirty (int nDirty)
const std::list< RndTransformable * > & GetTransList () const
Public Member Functions inherited from RndCollideable
 RndCollideable ()
 Construct a collideable without children.
 ~RndCollideable () override
 Drop the references on the children.
void DumpText (PrnStream &stream) override
 Write a description of the collideable.
void Save (BinStream &stream) override
 Write the names of the children.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace a child with another object.
void Copy (const RndObject *pSource, int nFlags) override
 Copy the children when the flags request them.
void Load (BinStream &stream) override
 Read what Save() wrote.
RndCollideable * Parent ()
 Find the collideable whose children include this one.
bool AddCollide (RndCollideable *pCollide)
 Append a child.
void RemoveCollide (RndCollideable *pCollide)
 Remove a child.

Static Public Member Functions

static RndObject * New (const char *pszName)
 Create a camera.
static void CreateDefault ()
 Create the internal camera [default cam], 150 units back along y.
static float ConvertFov (float fFrom, float fTo, float fFov)
 Report the field of view that covers the same extent at another aspect.
Static Public Member Functions inherited from RndDrawable
static void CollectChildren (std::list< RndObject * > &objects, RndDrawable *pDrawable)
 Append every draw descendant of a drawable, depth first, each before its descendants.
Static Public Member Functions inherited from RndTransformable
static void CollectChildren (std::list< RndObject * > &objects, RndTransformable *pTransformable)
 Append every transform descendant of a transformable, depth first, each before its descendants.
Static Public Member Functions inherited from RndCollideable
static void CollectChildren (std::list< RndObject * > &objects, RndCollideable *pCollideable)
 Append every collision descendant of a collideable, depth first, each before its descendants.

Static Public Attributes

static RndCam * sCurrent
 The camera drawing is set up for.
static RndCam * sDefault
 The internal camera CreateDefault() made.
static const char * sClassName
 The class name a .rnd file writes, Cam.
static int sRev
 The format version Save() writes and Load() accepts.
Static Public Attributes inherited from RndDrawable
static int sRev
 The format version Save() writes and Load() accepts.
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.
Static Public Attributes inherited from RndTransformable
static int sRev
 The format version Save() writes and Load() accepts.
Static Public Attributes inherited from RndCollideable
static int sRev
 The format version Save() writes and Load() accepts.

Protected Member Functions

void ReleaseTargetTex ()
 Drop the reference on mTargetTex.
void AcquireTargetTex ()
 Take a reference on mTargetTex and rebuild the projection.
Protected Member Functions inherited from RndDrawable
void ReleaseDrawRefs ()
 Drop the reference on every child without emptying the list.
void AcquireDrawRefs ()
 Take a reference on every child.
Protected Member Functions inherited from RndTransformable
void ReleaseTransRefs ()
 Drop the reference on every child without emptying the list.
void AcquireTransRefs ()
 Take a reference on every child.
Protected Member Functions inherited from RndCollideable
void ReleaseCollideRefs ()
 Drop the reference on every child without emptying the list.
void AcquireCollideRefs ()
 Take a reference on every child.

Protected Attributes

Transform mOrthoWorldXfm
Transform mInvWorldXfm
Transform mLocalProject
Transform mInvLocalProject
Transform mWorldProject
Transform mInvWorldProject
Frustum mLocalFrustum
Frustum mWorldFrustum
float mNearPlane
float mFarPlane
float mFov
Vector2 mZRange
Rect mScreenRect
RndTex * mTargetTex
Protected Attributes inherited from RndDrawable
int mShowing
Protected Attributes inherited from RndObject
std::list< RndObject * > mRefs
String mName
Protected Attributes inherited from RndTransformable
std::list< RndTransformable * > mTransList
Transform mLocalXfm
Transform mWorldXfm
Vector3 mOrigin
int mDirty
int mBillboard

Additional Inherited Members

Public Types inherited from RndTransformable
enum  Billboard {
  kBillboardNone = 0 , kBillboardX = 1 , kBillboardY = 2 , kBillboardZ = 4 ,
  kBillboardXZ = 8 , kBillboardXYZ = 16 , kBillboardSimpleXYZ = 32 , kBillboardLocalRotate = 64 ,
  kBillboardScale = 128 , kBillboardScaleX = 129 , kBillboardScaleY = 130 , kBillboardScaleZ = 132 ,
  kBillboardScaleXZ = 136 , kBillboardScaleXYZ = 144 , kBillboardScaleSimpleXYZ = 160
}
 How the world transform turns to face the current camera. More...

Detailed Description

Camera.

The RTTI includes the class name and records RndDrawable, RndTransformable, and RndCollideable as bases. The camera projects onto mScreenRect, a rectangle in fractions of the display or of mTargetTex. A field of view of 0 selects an orthographic projection.

Constructor & Destructor Documentation

◆ RndCam()

RndCam::RndCam ( const char * pszName)
explicit

Construct a camera looking along y with a quarter-turn field of view, from 1 to 1000 units.

Parameters
pszNameThe registry key.
Ghidra address:
NTSC-U/C: 0x00220f20
Ghidra address:
PAL: 0x00229cf0

◆ ~RndCam()

RndCam::~RndCam ( )
override

Release the camera and stop drawing through it.

Ghidra address:
NTSC-U/C: 0x00221498
Ghidra address:
PAL: 0x0022a268

Member Function Documentation

◆ operator new()

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

Allocate a camera, billed to the class name.

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

◆ operator delete()

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

Release a camera.

Parameters
pBlockThe block.

◆ New()

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

Create a camera.

Parameters
pszNameThe registry key.
Returns
The camera.
Ghidra address:
NTSC-U/C: 0x0037f278
Ghidra address:
PAL: 0x003ed990

◆ ListDrawObjects()

void RndCam::ListDrawObjects ( std::list< RndObject * > & objects)
overridevirtual

Add the camera itself to a list.

Parameters
objectsThe list to add to.
Ghidra address:
NTSC-U/C: 0x00221e60
Ghidra address:
PAL: 0x0022ac30

Reimplemented from RndDrawable.

◆ ListDrawables()

void RndCam::ListDrawables ( std::list< RndDrawable * > & drawables)
overridevirtual

Make the camera current and add the drawables of the children to a list.

Parameters
drawablesThe list to add to.
Ghidra address:
NTSC-U/C: 0x00221ee8
Ghidra address:
PAL: 0x0022acb8

Reimplemented from RndDrawable.

◆ DrawShowing()

int RndCam::DrawShowing ( )
overridevirtual

Make the camera current.

Returns
1, to draw the children.
Ghidra address:
NTSC-U/C: 0x0037f230
Ghidra address:
PAL: 0x003ed948

Reimplemented from RndDrawable.

◆ UpdateWorldXfm()

int RndCam::UpdateWorldXfm ( RndTransformable * pParent,
int bForce )
overridevirtual

Recompute the world transform, and the world projection when it changed.

Parameters
pParentThe parent, or null for a root.
bForceNon-zero to recompute even when nothing changed.
Returns
Non-zero when the world transform was recomputed.
Ghidra address:
NTSC-U/C: 0x0037f1f0
Ghidra address:
PAL: 0x003ed908

Reimplemented from RndTransformable.

◆ Collide() [1/2]

void RndCam::Collide ( const Vector2 & point,
std::list< Collision > & collisions )
overridevirtual

Record the camera as struck when a screen point falls inside mScreenRect, then test the children.

Parameters
pointThe screen point, in fractions of the display.
collisionsThe list to add to.
Ghidra address:
NTSC-U/C: 0x002205f8
Ghidra address:
PAL: 0x002293c8

Reimplemented from RndCollideable.

◆ DumpText()

void RndCam::DumpText ( PrnStream & stream)
overridevirtual

Write a description of the camera and its bases.

A dump level above 1 adds the projections and the view volumes.

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

Reimplemented from RndObject.

◆ Save()

void RndCam::Save ( BinStream & stream)
overridevirtual

Write the camera and its bases.

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

Implements RndObject.

◆ Replace()

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

Replace a referenced object with another.

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

Implements RndObject.

◆ ClassName()

const char * RndCam::ClassName ( ) const
inlineoverridevirtual

Report the class name.

Returns
sClassName.
Ghidra address:
NTSC-U/C: 0x0037f268
Ghidra address:
PAL: 0x003ed980

Implements RndObject.

◆ Copy()

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

Copy another camera and its bases.

Parameters
pSourceThe camera to copy from.
nFlagsThe set of fields to copy.
Ghidra address:
NTSC-U/C: 0x00220d38
Ghidra address:
PAL: 0x00229b08

Implements RndObject.

◆ Load()

void RndCam::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: 0x00220ae8
Ghidra address:
PAL: 0x002298b8

Implements RndObject.

◆ WorldToScreen()

void RndCam::WorldToScreen ( const Vector3 & world,
Vector2 & screen ) const

Project a world point to a screen point through mWorldProject and mScreenRect.

A point that projects to a depth of exactly 0 skips the perspective divide. The name is inferred.

Parameters
worldThe point in world space.
screenReceives the point in fractions of the target.
Ghidra address:
NTSC-U/C: 0x002204b8
Ghidra address:
PAL: 0x00229288

◆ SetTargetTex()

void RndCam::SetTargetTex ( RndTex * pTex)

Render into a texture rather than the display, or stop.

Parameters
pTexThe texture, or null for the display.
Ghidra address:
NTSC-U/C: 0x002205a0
Ghidra address:
PAL: 0x00229370

◆ SetFrustum()

void RndCam::SetFrustum ( float fNear,
float fFar,
float fFov )

Set the view volume.

The near plane is kept at least a thousandth of the far plane.

Parameters
fNearThe distance to the near plane.
fFarThe distance to the far plane.
fFovThe field of view in radians, or 0 for an orthographic projection.
Ghidra address:
NTSC-U/C: 0x002218d8
Ghidra address:
PAL: 0x0022a6a8

◆ UpdateProjection()

void RndCam::UpdateProjection ( )

Rebuild the local projection and the local view volume, then the world projection.

Ghidra address:
NTSC-U/C: 0x00221930
Ghidra address:
PAL: 0x0022a700

◆ UpdateWorldProject()

void RndCam::UpdateWorldProject ( )

Rebuild the world projection and the world view volume from the world transform.

The basis is orthonormalised first, so a scaled camera projects without the scale.

Ghidra address:
NTSC-U/C: 0x00221ac0
Ghidra address:
PAL: 0x0022a890

◆ CreateDefault()

void RndCam::CreateDefault ( )
static

Create the internal camera [default cam], 150 units back along y.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00220410
Ghidra address:
PAL: 0x002291e0

◆ ConvertFov()

float RndCam::ConvertFov ( float fFrom,
float fTo,
float fFov )
static

Report the field of view that covers the same extent at another aspect.

The name is inferred.

Parameters
fFromThe extent the field of view spans.
fToThe extent the result spans.
fFovThe field of view in radians.
Returns
The field of view in radians.
Ghidra address:
NTSC-U/C: 0x00221f08
Ghidra address:
PAL: 0x0022acd8

◆ GetFarPlane()

float RndCam::GetFarPlane ( ) const
inline
Returns
The distance to the far plane.

◆ GetFov()

float RndCam::GetFov ( ) const
inline
Returns
The field of view in radians, 0 for orthographic.

◆ GetInvWorldXfm()

const Transform & RndCam::GetInvWorldXfm ( ) const
inline
Returns
The inverse of mOrthoWorldXfm.

◆ GetLocalProject()

const Transform & RndCam::GetLocalProject ( ) const
inline
Returns
Camera space to the unit projection.

◆ GetNearPlane()

float RndCam::GetNearPlane ( ) const
inline
Returns
The distance to the near plane.

◆ GetOrthoWorldXfm()

const Transform & RndCam::GetOrthoWorldXfm ( ) const
inline
Returns
The world transform with an orthonormal basis.

◆ GetScreenRect()

const Rect & RndCam::GetScreenRect ( ) const
inline
Returns
The area drawn to, in fractions of the target.

◆ SetScreenRect()

void RndCam::SetScreenRect ( const Rect & rect)
inline
Parameters
rectThe area drawn to, in fractions of the target.

◆ GetTargetTex()

RndTex * RndCam::GetTargetTex ( ) const
inline
Returns
The texture drawn to, or null for the display.

◆ GetWorldFrustum()

const Frustum & RndCam::GetWorldFrustum ( ) const
inline
Returns
The view volume in world space.

◆ GetZRange()

const Vector2 & RndCam::GetZRange ( ) const
inline
Returns
The depth range the projection maps to.

◆ SetZRange()

void RndCam::SetZRange ( const Vector2 & range)
inline
Parameters
rangeThe depth range the projection maps to.

◆ ReleaseTargetTex()

void RndCam::ReleaseTargetTex ( )
protected

Drop the reference on mTargetTex.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00221df0
Ghidra address:
PAL: 0x0022abc0

◆ AcquireTargetTex()

void RndCam::AcquireTargetTex ( )
protected

Take a reference on mTargetTex and rebuild the projection.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00221e20
Ghidra address:
PAL: 0x0022abf0

◆ Collide() [2/2]

virtual void RndCollideable::Collide ( const Segment & segment,
std::list< Collision > & collisions )
virtual

Test a segment against the collideable and add what it strikes to a list.

The base body tests the children.

Parameters
segmentThe segment.
collisionsThe list to add to.
Ghidra address:
NTSC-U/C: 0x002224c8
Ghidra address:
PAL: 0x0022b298

Reimplemented from RndCollideable.

Member Data Documentation

◆ sCurrent

RndCam* RndCam::sCurrent
static

The camera drawing is set up for.

Ghidra address:
NTSC-U/C: 0x003b0988
Ghidra address:
PAL: 0x0042f820

◆ sDefault

RndCam* RndCam::sDefault
static

The internal camera CreateDefault() made.

Ghidra address:
NTSC-U/C: 0x003b098c
Ghidra address:
PAL: 0x0042f824

◆ sClassName

const char* RndCam::sClassName
static

The class name a .rnd file writes, Cam.

Ghidra address:
NTSC-U/C: 0x003b0990
Ghidra address:
PAL: 0x0042f828

◆ sRev

int RndCam::sRev
static

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

Ghidra address:
NTSC-U/C: 0x003b0994
Ghidra address:
PAL: 0x0042f82c

◆ mOrthoWorldXfm

Transform RndCam::mOrthoWorldXfm
protected

The world transform with an orthonormal basis.

◆ mInvWorldXfm

Transform RndCam::mInvWorldXfm
protected

The inverse of mOrthoWorldXfm.

◆ mLocalProject

Transform RndCam::mLocalProject
protected

Camera space to the unit projection.

◆ mInvLocalProject

Transform RndCam::mInvLocalProject
protected

The inverse of mLocalProject.

◆ mWorldProject

Transform RndCam::mWorldProject
protected

World space to the unit projection.

◆ mInvWorldProject

Transform RndCam::mInvWorldProject
protected

The inverse of mWorldProject.

◆ mLocalFrustum

Frustum RndCam::mLocalFrustum
protected

The view volume in camera space.

◆ mWorldFrustum

Frustum RndCam::mWorldFrustum
protected

The view volume in world space.

◆ mNearPlane

float RndCam::mNearPlane
protected

The distance to the near plane.

◆ mFarPlane

float RndCam::mFarPlane
protected

The distance to the far plane.

◆ mFov

float RndCam::mFov
protected

The field of view in radians, 0 for orthographic.

◆ mZRange

Vector2 RndCam::mZRange
protected

The depth range the projection maps to.

◆ mScreenRect

Rect RndCam::mScreenRect
protected

The area drawn to, in fractions of the target.

◆ mTargetTex

RndTex* RndCam::mTargetTex
protected

The texture drawn to, or null for the display.


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