wavelength 1.0.0
Loading...
Searching...
No Matches
rndblur.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <list>
5
6#include "math/transform.h"
7#include "os/binstream.h"
8#include "os/mem.h"
9#include "os/prnstream.h"
10#include "rnd/rnddrawable.h"
11#include "rnd/rndmesh.h"
12#include "rnd/rndtext.h"
13
21class RndBlur : public RndDrawable {
22public:
30 explicit RndBlur(const char *pszName);
31
38 ~RndBlur() override;
39
46 void *operator new(size_t nSize) {
47 return PoolMemAlloc(static_cast<int>(nSize), "Blur", 0);
48 }
49
55 void operator delete(void *pBlock) {
56 PoolMemFree(pBlock);
57 }
58
68 void ListDrawObjects(std::list<RndObject *> &objects) override;
69
80 void ListDrawables(std::list<RndDrawable *> &drawables) override;
81
97 int DrawShowing() override;
98
106 void DumpText(PrnStream &stream) override;
107
115 void Save(BinStream &stream) override;
116
127 void Replace(RndObject *pFrom, RndObject *pTo) override;
128
136 const char *ClassName() const override {
137 return sClassName;
138 }
139
149 void Copy(const RndObject *pSource, int nFlags) override;
150
160 void Load(BinStream &stream) override;
161
171 void SetLength(int nLength);
172
182 void SetRate(int nRate);
183
192 static RndObject *New(const char *pszName) {
193 return new RndBlur(pszName);
194 }
195
202 static const char *sClassName;
203
210 static int sRev;
211
217 static int sLoadRev;
218
220 float GetFalloff() const {
221 return mFalloff;
222 }
223
225 void SetFalloff(float fFalloff) {
226 mFalloff = fFalloff;
227 }
228
230 RndMesh *GetMesh() const {
231 return mMesh;
232 }
233
235 const std::list<Transform> &GetXfms() const {
236 return mXfms;
237 }
238
240 std::list<Transform> &GetXfms() {
241 return mXfms;
242 }
243
244protected:
254
264
265private:
266 RndMesh *mMesh;
267 RndText *mText;
268 int mLength;
269 int mRate;
270 float mFalloff;
271 std::list<Transform> mXfms;
272 int mCountdown;
273};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
const std::list< Transform > & GetXfms() const
Definition rndblur.h:235
float GetFalloff() const
Definition rndblur.h:220
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a subject with another object.
void Load(BinStream &stream) override
Read what Save() wrote.
static int sRev
The format version Save() writes and Load() accepts.
Definition rndblur.h:210
const char * ClassName() const override
Report the class name.
Definition rndblur.h:136
void Copy(const RndObject *pSource, int nFlags) override
Copy the subjects, the length, the rate, and the falloff, and discard the recorded transforms.
void AcquireRefs()
Take a reference on the subjects and discard the recorded transforms.
RndMesh * GetMesh() const
Definition rndblur.h:230
~RndBlur() override
Drop the references on the subjects.
static int sLoadRev
The version Load() read last.
Definition rndblur.h:217
void ReleaseRefs()
Drop the references on the subjects.
RndBlur(const char *pszName)
Construct a trail without a subject, recording nothing, every frame, at full falloff.
std::list< Transform > & GetXfms()
Definition rndblur.h:240
void DumpText(PrnStream &stream) override
Write a description of the trail and its base.
void Save(BinStream &stream) override
Write the version, the base, the subjects' names, the length, the rate, and the falloff.
static const char * sClassName
The class name a .rnd file writes, Blur.
Definition rndblur.h:202
static RndObject * New(const char *pszName)
Create a trail.
Definition rndblur.h:192
void ListDrawObjects(std::list< RndObject * > &objects) override
Add the objects of the mesh and of the text to a list.
void SetLength(int nLength)
Set how many transforms the trail records and discard the recorded ones.
int DrawShowing() override
Draw the subject, then once per recorded transform with a falling alpha.
void ListDrawables(std::list< RndDrawable * > &drawables) override
Add the trail when its subject draws at the current transform or a recorded one, then the children,...
void SetRate(int nRate)
Set how many frames pass between two recorded transforms and discard the recorded ones.
void SetFalloff(float fFalloff)
Definition rndblur.h:225
RndDrawable()
Construct a showing drawable without a highlight or children.
Definition rnddrawable.h:23
Triangle mesh with a material.
Definition rndmesh.h:31
RndObject(const char *pszName)
Construct an object and register it under a name.
Text drawn with a bitmap font as a mesh of one quad per character.
Definition rndtext.h:27
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.