|
resonance 1.0.1
|
Camera. More...
#include <cam.h>


Classes | |
| struct | Rect |
| Rectangle the projected image is placed in. More... | |
Public Member Functions | |
| 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 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 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 Public Member Functions inherited from Rnd::Drawable | |
| static Drawable * | Find (const HxStr &name) |
| Resolve a registry key to a drawable. | |
Public Attributes | |
| 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. | |
Static Public Attributes | |
| 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". | |
Protected Member Functions | |
| virtual void | FindCollisions (const Vector2 &point, std::list< Collision > &collisions) |
| Report whether a screen point lies inside the screen rectangle. | |
| virtual int | DrawShowing () |
| Make this camera the one the frame is drawn through. | |
| 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 | |
| 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 |
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... | |
Camera.
Its RTTI descriptor is at 0x008eeeb8. It has three public non-virtual bases: Rnd::Drawable at offset 0, Rnd::Transformable at 0x20, and Rnd::Collideable at 0xd0. The class is 0x330 bytes. The factory at 0x004b2470 proves that size by allocating exactly that much under the tag "Rnd::Cam". The virtual Rnd::Object subobject sits at 0x310. The constructor proves the offset by writing that address into all three virtual-base pointers.
Each matrix and each frustum member is quadword aligned in the original. The four bytes between the end of the Rnd::Collideable subobject at 0xdc and the first matrix at 0xe0 are the padding that alignment produces rather than a member.
The member titles come from the text DumpText() writes: "nearPlane:", " farPlane:", " fov:", "yRatio:", "screenRect:", "zRange:", " targetTex:", " localProject:", "worldProject:", and "invWorldProject:". Both frustum member names come from the same dump. The names of the two matrices the dump omits come from what builds them. That is, 0xe0 is the inverse of the world transform and 0x160 is the inverse of the local projection.
Four vtables belong to the class. The six-entry table at 0x00820958 is addressed by the Rnd::Drawable vptr at 0x10 and stores the two virtuals declared here after the three Rnd::Drawable ones. The three-entry table at 0x00820938 is addressed by the Rnd::Transformable vptr at 0xc8, the three-entry table at 0x00820918 by the Rnd::Collideable vptr at 0xd8, and the eight-entry table at 0x00820990 by the Rnd::Object subobject vptr, each entry with the adjustment back to the Cam pointer.
The routine at 0x004b1ff0 is an out-of-line copy of an inline accessor that returns Cam::sCurrent. It has no caller, because every reader in the image loads the global directly.
|
explicit |
Construct a camera with the default projection.
The near plane starts at 1.0, the far plane at 1000.0, the field of view at a right angle, the vertical ratio at 0.75, the depth range at 0.0 to 1.0, and the screen rectangle at the whole target. Every projection matrix retains only its fourth column, and the final call builds them all.
| name | The registry key for this object. |
|
virtual |
Clear Cam::sCurrent when it addresses this camera and release the render target.
| void * Rnd::Cam::operator new | ( | size_t | nSize | ) |
Allocate a camera from the tagged heap under the tag "Rnd::Cam".
| nSize | The object size, which the compiler supplies. |
| void Rnd::Cam::operator delete | ( | void * | pBlock | ) |
Release a camera to the tagged heap.
| pBlock | The block. |
| void Rnd::Cam::UpdateProjection | ( | ) |
Build the local frustum and both local projection matrices.
The aspect ratio is the vertical ratio scaled by the height of the screen rectangle and divided by its width. A field of view of zero selects an orthographic projection and any other value a perspective one, the second scaling by the reciprocal tangent of the half angle. Either way the matrices map camera space x to screen x, camera space y to depth, and camera space z to negated screen y, which establishes that this engine looks down its y axis with z upwards. UpdateWorldProject() runs afterwards.
| void Rnd::Cam::UpdateWorldProject | ( | ) |
Compose the world projection, its inverse, and the world frustum.
The inverse of the world transform becomes the world-to-camera matrix, the six local frustum planes are moved into world space, the world projection is the world-to-camera matrix followed by the local projection, and the inverse world projection is the inverse local projection followed by the world transform.
Build the segment under a point of the screen rectangle.
The point is moved into the unit square of mScreenRect, then onto the far side of the projection through mInvWorldProject. A perspective camera starts the segment at its world position and runs it flLength along the direction to that far point. An orthographic camera starts the segment at the far point itself and runs it flLength along its world y axis.
The image has no caller. The title is inferred.
| ptScreen | The point, in the coordinates the screen rectangle is expressed in. |
| flLength | The length of the segment. |
Place a world point in the unit square of the projected image.
The point is carried through mWorldProject, divided by its depth, and mapped from -1..1 onto 0..1. A point at zero depth skips the division, which leaves the result indeterminate.
Inline. CreditsRoll's two classifiers expand it, and the out-of-line copy in the camera's translation unit has no caller. The title is inferred.
| pt | The world point. |
Carry a point of the unit square of the projected image onto the far side of the projection.
The point is mapped from 0..1 onto -1..1 with a depth of one and carried through mInvWorldProject. The screen rectangle is not applied.
The image has no caller. The title is inferred.
| ptUnit | The point in the unit square. |
| void Rnd::Cam::SetScreenRect | ( | const Rect & | rect | ) |
Replace mScreenRect and rebuild the projection.
The image has no caller. The title is inferred.
| rect | The fraction of the render target the projected image is placed in. |
| void Rnd::Cam::SetFrustum | ( | float | flNear, |
| float | flFar, | ||
| float | flFov ) |
Set the clip distances and the field of view, then rebuild the projection.
The near distance is raised to a thousandth of the far distance when it is smaller. UpdateProjection() runs afterwards. AppTunnel and TnlCameraRig are the callers. The title is inferred.
| flNear | The near clip distance. |
| flFar | The far clip distance. |
| flFov | The field of view, zero for an orthographic projection. |
|
inline |
Report the near clip distance.
The out-of-line copy has no callers. AppTunnel's constructor inlines it.
|
inline |
Report the far clip distance.
The out-of-line copy has no callers. AppTunnel's constructor inlines it.
|
inline |
Report the field of view, zero for an orthographic projection.
The out-of-line copy has no callers. AppTunnel's constructor inlines it.
| void Rnd::Cam::SetTargetTex | ( | Tex * | pTex | ) |
Set the texture this camera draws into, or none to draw into the frame buffer.
The previous target loses its reference on this camera and the new one gains one. A new target is then resized, through a call that takes its width, its height, and a depth capped at 0x20, after which the render target is acquired and UpdateTargetAspect() runs.
The routine is not virtual. Rnd::PsCam declares a virtual of the same title that chains here, which is what places that virtual in a slot of its own rather than in one of these.
| pTex | The render target, or null to draw into the frame buffer. |
Place a point of the screen rectangle in render target pixels.
Vtable slot 4 of the Rnd::Drawable table. This implementation writes nothing and returns its result slot untouched. The value a caller receives is therefore indeterminate, and only Rnd::PsCam::ScreenToPixels() produces one.
| ptScreen | The point, in the coordinates the screen rectangle is expressed in. |
Reimplemented in Rnd::PsCam.
|
virtual |
Take the aspect ratio from the render target and rebuild the projection.
Vtable slot 5 of the Rnd::Drawable table. With a render target the vertical ratio becomes the target height divided by its width. With none the ratio is untouched, and Rnd::PsCam overrides this routine to supply a default.
Reimplemented in Rnd::PsCam.
|
virtual |
Report the class key a .rnd file writes for a camera.
The returned string is the global at 0x006f9590, which the class registration fills with "Cam".
Implements Rnd::Object.
|
virtual |
Write a description of this camera to sink.
The three base descriptions come first. The near plane, the far plane, the field of view, the screen rectangle, the depth range, and the render target name follow at any positive dump level, and the vertical ratio, the local and world projections, both frustums, and the inverse world projection only from level two. A camera with no render target writes "no object" in place of the target's quoted name.
| sink | The diagnostic sink to write to. |
Reimplemented from Rnd::Drawable.
Repoint the render target when the object it addressed is replaced.
The three base implementations run first. A replacement is cast to Rnd::Tex. A replacement that is not a texture therefore clears the render target rather than storing a pointer of the wrong type.
| pFrom | The object going away. |
| pTo | The object to store instead, or null. |
Reimplemented from Rnd::Drawable.
|
virtual |
Recompose the world transform and, when it changed, the world projection.
Rnd::Transformable vtable slot 2. The base routine reports whether it recomposed, and only then does UpdateWorldProject() run, which is what makes the projection follow the camera without rebuilding it every frame.
| pParent | The transform to compose against. |
| nForce | Non-zero to recompose regardless of the dirty flag. |
Reimplemented from Rnd::Transformable.
|
virtual |
Write this camera's serialised form to stream.
The three base forms follow the revision word in the order Transformable, Drawable, Collideable, which is not the order the bases are declared in.
| stream | The stream to write to. |
Reimplemented from Rnd::Drawable.
|
virtual |
Copy the state of pSource into this camera.
The render target is transferred with its reference, and the projection is rebuilt from the copied parameters rather than copied.
| pSource | The camera to copy from. |
| nFlags | The set of fields to copy. |
Reimplemented from Rnd::Drawable.
|
virtual |
Read this camera's serialised form from stream.
A revision above 8 is rejected with "Can't load new Cam". Three revision-gated words are read and discarded, which is how the reader steps over fields the format has dropped. The depth range arrives from revision 4, the render target from revision 5, and the Collideable form from revision 8.
| stream | The stream to read from. |
Reimplemented from Rnd::Drawable.
Build a camera the class registry vends.
| name | The registry key for the new camera. |
|
protectedvirtual |
Report whether a screen point lies inside the screen rectangle.
Vtable slot 2 of the Rnd::Collideable table. A showing camera whose rectangle strictly encloses the point appends itself at distance zero. The Rnd::Collideable query runs afterwards either way.
| point | The screen point. |
| collisions | The list to append an intersection to. |
Reimplemented from Rnd::Collideable.
|
protectedvirtual |
Make this camera the one the frame is drawn through.
Vtable slot 3 of the Rnd::Drawable table. Rnd::PsCam overrides it with the routine that also submits the display registers.
Reimplemented from Rnd::Drawable.
Reimplemented in Rnd::PsCam.
|
static |
Camera the frame is being drawn through.
Rnd::Cam::DrawShowing() stores itself here, the destructor clears it when it addresses the camera going away, and Rnd::PsCam::DrawShowing() stores its own camera the same way.
Creator the registered "Cam" class builds through.
Starts as Cam::NewCam(). Rnd::PsCam::Init() installs Rnd::PsCam::NewCam(), and a camera loaded from a file on the PlayStation 2 is therefore a Rnd::PsCam.
|
static |
Registered class name of Rnd::Cam, the string "Cam".
| Vector3 Rnd::Cam::mWorldToCam[kXfmRowCount] |
Inverse of the world transform, which maps world space into camera space.
Rnd::Mesh::PrepareDraw() reads the second component of the translation row to obtain the depth of a bounding sphere, which is what proves the routine that fills it is an inverse rather than a transpose. +0xe0
| Vector3 Rnd::Cam::mLocalProject[kXfmRowCount] |
Projection from camera space onto the screen rectangle.
+0x120
| Vector3 Rnd::Cam::mWorldProject[kXfmRowCount] |
mWorldToCam followed by mLocalProject.
+0x1a0
| Vector3 Rnd::Cam::mInvWorldProject[kXfmRowCount] |
mInvLocalProject followed by the world transform.
+0x1e0
|
protected |
| Frustum Rnd::Cam::mWorldFrustum |
The view volume in world space.
Rnd::Mesh::PrepareDraw() tests a bounding sphere against these planes. They are not the same planes as Rnd::g_drawFrustum, which a separate test uses. +0x280
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| Rect Rnd::Cam::mScreenRect |
Fraction of the render target the projected image is placed in.
Rnd::Mesh::PrepareDraw() reads the width to scale its projected size estimate. +0x2f8
| Tex* Rnd::Cam::mpTargetTex |
Texture this camera draws into, or null to draw into the frame buffer.
Rnd::PsMesh::DrawShowing() tests it and suppresses its depth register writes while it is set, which is what makes a camera with a render target skip them. +0x308