resonance 1.0.1
Loading...
Searching...
No Matches
multimesh.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
5#include "math/transform.h"
6#include "os/hxstr.h"
7#include "rnd/drawable.h"
8#include "rnd/manager.h"
9
10namespace Rnd {
11class Dbg;
12class Mesh;
13class Stream;
14} // namespace Rnd
15
16namespace Rnd {
17
39class MultiMesh : public Drawable {
40public:
42 enum { kSerialVersion = 0 };
43
51 MultiMesh(const HxStr &name);
52
57 virtual ~MultiMesh();
58
69 virtual void DumpText(Dbg &sink);
70
81 virtual void Save(Stream &stream);
82
94 virtual void Replace(Object *pFrom, Object *pTo);
95
103 virtual const HxStr &ClassName() const;
104
117 virtual void Copy(const Object *pSource, unsigned nFlags);
118
130 virtual void Load(Stream &stream);
131
141
151
162 std::list<Transform> &GetTransforms() {
163 return mTransforms;
164 }
165
175 Mesh *GetMesh() const {
176 return mMesh;
177 }
178
191
202 void RemoveTransform(int nIndex);
203
213 void SetMesh(Mesh *pMesh);
214
215protected:
227 virtual int DrawShowing();
228
229 // Both members are protected because Rnd::PsMultiMesh reads the mesh and walks the transform
230 // list to submit its GIF packets. The order below is the recovered offset order.
231 Mesh *mMesh; // +0x14
232 std::list<Transform> mTransforms; // +0x18
233};
234
247
261
271extern MultiMesh *(*g_pfnNewMultiMesh)(const HxStr &name);
272
280
297
309
310} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
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
Draws one mesh many times, once per recorded instance transform.
Definition multimesh.h:39
void SetMesh(Mesh *pMesh)
Replace the mesh every instance draws, moving this object's reference to the new mesh.
@ kSerialVersion
Definition multimesh.h:42
virtual ~MultiMesh()
virtual void Replace(Object *pFrom, Object *pTo)
Replace one object reference with another.
Mesh * GetMesh() const
Report the mesh every instance draws.
Definition multimesh.h:175
void AcquireMeshRef()
Take a reference on the instanced mesh.
virtual int DrawShowing()
Draw the mesh once per instance.
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy another multi-mesh over this one.
void RemoveTransform(int nIndex)
Remove one instance by position.
MultiMesh(const HxStr &name)
Construct an empty multi-mesh.
virtual void Save(Stream &stream)
Serialise the multi-mesh.
std::list< Transform > & GetTransforms()
Report the instance transforms.
Definition multimesh.h:162
virtual void DumpText(Dbg &sink)
Write the multi-mesh to the engine text sink.
Mesh * mMesh
Definition multimesh.h:231
Transform & GetTransform(int nIndex)
Report one instance transform by position.
virtual void Load(Stream &stream)
Load the multi-mesh.
void ReleaseMeshRef()
Release the reference on the instanced mesh.
virtual const HxStr & ClassName() const
Return the registered class name, "MultiMesh".
std::list< Transform > mTransforms
Definition multimesh.h:232
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
The rendering engine.
Definition animhelper.h:3
void RegisterMultiMeshClass()
Point g_pfnNewMultiMesh at NewMultiMesh() and register the "MultiMesh" class with Rnd::Manager.
Definition multimesh.h:293
Object * CreateRegisteredMultiMesh(const HxStr &name)
Build a multi-mesh for the registered "MultiMesh" class.
MultiMesh * NewMultiMesh(const HxStr &name)
Allocate and construct a multi-mesh.
int g_nRndMultiMeshLoadVersion
Serial version of the multi-mesh record currently being read.
Manager TheManager
The renderer's object registry.
HxStr g_multiMeshClassName
Registered class name of Rnd::MultiMesh, the string "MultiMesh".
MultiMesh *(* g_pfnNewMultiMesh)(const HxStr &name)
Creator the registered "MultiMesh" class builds through.
Affine transform stored as three basis rows and a translation row.
Definition transform.h:14