resonance 1.0.1
Loading...
Searching...
No Matches
blur.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
5#include "os/hxstr.h"
6#include "rnd/drawable.h"
7#include "rnd/transformable.h"
8
9namespace Rnd {
10class Dbg;
11class Mesh;
12class Object;
13class Stream;
14class Text;
15} // namespace Rnd
16
17namespace Rnd {
18
39class Blur : public Drawable {
40public:
49 struct Xfm {
51 };
52
64 explicit Blur(const HxStr &name);
65
70 virtual ~Blur();
71
82 void SetMesh(Mesh *pMesh);
83
93 void SetText(Text *pText);
94
104 void SetLength(int nLength);
105
115 void SetRate(int nRate);
116
124 void SetFalloff(float flFalloff);
125
133 Mesh *GetMesh() const;
134
142 Text *GetText() const;
143
151 int GetLength() const;
152
160 int GetRate() const;
161
169 float GetFalloff() const;
170
181 virtual void DumpText(Dbg &sink);
182
190 virtual void Save(Stream &stream);
191
203 virtual void Replace(Object *pFrom, Object *pTo);
204
215 virtual const HxStr &ClassName() const;
216
228 virtual void Copy(const Object *pSource, unsigned nFlags);
229
240 virtual void Load(Stream &stream);
241
250 static Blur *NewBlur(const HxStr &name);
251
265 static Blur *NewFromHook(const HxStr &name);
266
278 static Blur *Find(const HxStr &name);
279
288 static void Init();
289
290protected:
309 virtual int DrawShowing();
310
311private:
320 void AcquireObjectRefs();
321
330 void ReleaseObjectRefs();
331
332 // NTSC-U/C: 0x004c34c0, PAL: 0x005015e8
333 // Discards the recorded transforms. The out-of-line copy has no caller, and the
334 // setters clear mXfms directly. The name is inferred.
335 void ClearXfms() {
336 mXfms.clear();
337 }
338
339 // Declared in recovered offset order. Every member but mXfms is private because the image
340 // supplies an accessor for each of the others that anything outside the class reads.
341
342 Mesh *mpMesh; // +0x14
343 Text *mpText; // +0x18
344 int mLength; // +0x1c
345 int mRate; // +0x20
346 float mFalloff; // +0x24
347
348public:
357 std::list<Xfm> mXfms;
358
359private:
360 // Frames still to pass before the next transform is recorded. DrawShowing() counts it down and
361 // reloads it from mRate.
362 int mCountdown; // +0x2c
363};
364
372
382extern int g_nRndBlurLoadRevision;
383
396extern Blur *(*g_pfnNewBlur)(const HxStr &name);
397
398} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Motion trail that redraws one drawable at the transforms it recently occupied.
Definition blur.h:39
static void Init()
Install the trail factory and register the class key with Rnd::TheManager.
static Blur * Find(const HxStr &name)
Resolve a registry key to a trail.
virtual void Load(Stream &stream)
Read this trail's serialised form from stream.
void SetMesh(Mesh *pMesh)
Set the mesh the trail is drawn from and discard the recorded transforms.
virtual ~Blur()
void SetFalloff(float flFalloff)
Set the fraction of the subject's alpha the oldest trail step is drawn with.
int GetRate() const
Report how many frames pass between two recorded transforms.
int GetLength() const
Report how many transforms the trail records.
void SetText(Text *pText)
Set the text the trail is drawn from and discard the recorded transforms.
float GetFalloff() const
Report the alpha fraction of the oldest trail step.
Mesh * GetMesh() const
Report the mesh the trail is drawn from.
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy the state of pSource into this trail.
virtual void DumpText(Dbg &sink)
Write a description of this trail to sink.
Text * GetText() const
Report the text the trail is drawn from.
virtual const HxStr & ClassName() const
Report the class key a .rnd file writes for a trail.
static Blur * NewBlur(const HxStr &name)
Build a trail the class registry vends.
virtual void Save(Stream &stream)
Write this trail's serialised form to stream.
void SetRate(int nRate)
Set how many frames pass between two recorded transforms and discard the recorded ones.
static Blur * NewFromHook(const HxStr &name)
Build a trail through g_pfnNewBlur.
virtual int DrawShowing()
Draw the subject at its own transform, then once per recorded transform.
virtual void Replace(Object *pFrom, Object *pTo)
Repoint a subject when the object it addressed is replaced.
Blur(const HxStr &name)
Construct a trail with no subject.
std::list< Xfm > mXfms
The transforms recorded for the trail.
Definition blur.h:357
void SetLength(int nLength)
Set how many transforms the trail records and discard the recorded transforms.
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
Drawable()
Construct a visible drawable with no children.
Indexed triangle mesh with one material.
Definition mesh.h:46
Base of every object the renderer can load, resolve by name, and serialise.
Definition object.h:43
Byte stream that every renderer object serialises itself through.
Definition stream.h:31
Run of text drawn as a quad per glyph.
Definition text.h:57
The rendering engine.
Definition animhelper.h:3
constexpr int kXfmRowFloatCount
Floats in one transform row.
Definition transformable.h:15
constexpr int kXfmRowCount
Rows in one transform.
Definition transformable.h:12
HxStr g_blurClassName
Class key a .rnd file writes for a trail.
int g_nRndBlurLoadRevision
Revision word the reader of the .rnd container has most recently consumed.
One recorded transform.
Definition blur.h:49
float m[kXfmRowCount][kXfmRowFloatCount]
Definition blur.h:50