wavelength 1.0.0
Loading...
Searching...
No Matches
rndtransformable.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
5#include "math/transform.h"
6#include "math/vector3.h"
7#include "os/binstream.h"
8#include "os/prnstream.h"
9#include "rnd/rndobject.h"
10
17class RndTransformable : public virtual RndObject {
18public:
37
44
52
60 virtual void SetBillboard(int nBillboard);
61
73 virtual int UpdateWorldXfm(RndTransformable *pParent, int bForce);
74
84 void DumpText(PrnStream &stream) override;
85
93 void Save(BinStream &stream) override;
94
105 void Replace(RndObject *pFrom, RndObject *pTo) override;
106
116 void Copy(const RndObject *pSource, int nFlags) override;
117
125 void Load(BinStream &stream) override;
126
134 void SetOrigin(const Vector3 &origin);
135
144
156
165
173
185
200 static void CollectChildren(std::list<RndObject *> &objects, RndTransformable *pTransformable) {
201 if (pTransformable == nullptr) {
202 return;
203 }
204 for (RndTransformable *pChild : pTransformable->mTransList) {
205 objects.push_back(pChild);
206 CollectChildren(objects, pChild);
207 }
208 }
209
216 static int sRev;
217
219 const Transform &GetLocalXfm() const {
220 return mLocalXfm;
221 }
222
225 return mLocalXfm;
226 }
227
229 void SetLocalXfm(const Transform &xfm) {
230 mLocalXfm = xfm;
231 }
232
234 const Transform &GetWorldXfm() const {
235 return mWorldXfm;
236 }
237
240 return mWorldXfm;
241 }
242
244 int GetDirty() const {
245 return mDirty;
246 }
247
249 void SetDirty(int nDirty) {
250 mDirty = nDirty;
251 }
252
254 const std::list<RndTransformable *> &GetTransList() const {
255 return mTransList;
256 }
257
258protected:
268
278
279 std::list<RndTransformable *> mTransList;
280
282
284
286
287 int mDirty;
288
290};
291
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
RndObject(const char *pszName)
Construct an object and register it under a name.
Billboard
How the world transform turns to face the current camera.
Definition rndtransformable.h:20
@ kBillboardScaleSimpleXYZ
Definition rndtransformable.h:35
@ kBillboardX
Definition rndtransformable.h:22
@ kBillboardScaleX
Definition rndtransformable.h:30
@ kBillboardScaleXZ
Definition rndtransformable.h:33
@ kBillboardXYZ
Definition rndtransformable.h:26
@ kBillboardSimpleXYZ
Definition rndtransformable.h:27
@ kBillboardScaleXYZ
Definition rndtransformable.h:34
@ kBillboardScaleY
Definition rndtransformable.h:31
@ kBillboardNone
Definition rndtransformable.h:21
@ kBillboardZ
Definition rndtransformable.h:24
@ kBillboardScaleZ
Definition rndtransformable.h:32
@ kBillboardLocalRotate
Definition rndtransformable.h:28
@ kBillboardY
Definition rndtransformable.h:23
@ kBillboardXZ
Definition rndtransformable.h:25
@ kBillboardScale
Definition rndtransformable.h:29
~RndTransformable() override
Drop the references on the children.
void AcquireTransRefs()
Take a reference on every child.
RndTransformable * Parent()
Find the transformable whose children include this object.
void ClearTrans()
Remove every child.
void DumpText(PrnStream &stream) override
Write a description of the transformable.
void Load(BinStream &stream) override
Read what Save() wrote, or an earlier version of it.
RndTransformable()
Construct a transformable with identity transforms, no origin offset, and no billboard.
void ReleaseTransRefs()
Drop the reference on every child without emptying the list.
void RemoveTrans(RndTransformable *pTrans)
Remove a child.
static int sRev
The format version Save() writes and Load() accepts.
Definition rndtransformable.h:216
void SetDirty(int nDirty)
Definition rndtransformable.h:249
int mBillboard
Definition rndtransformable.h:289
int GetDirty() const
Definition rndtransformable.h:244
void Save(BinStream &stream) override
Write the transforms, the names of the children, the billboard mode, and the origin.
void SetOrigin(const Vector3 &origin)
Set the point the world transform subtracts first when there is no billboard.
bool AddTrans(RndTransformable *pTrans)
Append a child and mark its world transform dirty.
void SetLocalXfm(const Transform &xfm)
Definition rndtransformable.h:229
Vector3 mOrigin
Definition rndtransformable.h:285
void Copy(const RndObject *pSource, int nFlags) override
Copy the transforms, the billboard mode, the origin, and the children when the flags request them.
virtual int UpdateWorldXfm(RndTransformable *pParent, int bForce)
Recompute the world transform when it, or the parent's, changed, and then the children's.
virtual void SetBillboard(int nBillboard)
Set the billboard mode.
Transform & GetWorldXfm()
Definition rndtransformable.h:239
std::list< RndTransformable * > mTransList
Definition rndtransformable.h:279
Transform mWorldXfm
Definition rndtransformable.h:283
const Transform & GetWorldXfm() const
Definition rndtransformable.h:234
int mDirty
Definition rndtransformable.h:287
static void CollectChildren(std::list< RndObject * > &objects, RndTransformable *pTransformable)
Append every transform descendant of a transformable, depth first, each before its descendants.
Definition rndtransformable.h:200
const Transform & BillboardXfm()
Report the world transform turned to face the current camera.
Transform & GetLocalXfm()
Definition rndtransformable.h:224
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a child with another object.
Transform mLocalXfm
Definition rndtransformable.h:281
const std::list< RndTransformable * > & GetTransList() const
Definition rndtransformable.h:254
const Transform & GetLocalXfm() const
Definition rndtransformable.h:219
PrnStream & operator<<(PrnStream &stream, RndTransformable::Billboard eBillboard)
Write the name of a billboard mode.
Affine transform stored as three basis rows and a translation row.
Definition transform.h:18
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:14