resonance 1.0.1
Loading...
Searching...
No Matches
meshanim.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <vector>
5
6#include "math/color.h"
7#include "math/vector2.h"
8#include "math/vector3.h"
9#include "os/hxstr.h"
10#include "rnd/animatable.h"
11#include "rnd/manager.h"
12
13namespace Rnd {
14class Dbg;
15class Mesh;
16class Stream;
17} // namespace Rnd
18
19namespace Rnd {
20
45class MeshAnim : public Animatable {
46private:
55 void AddRefObjects();
56
65 void ClearKeys();
66
75 void ReleaseObjects();
76
77 // Data members follow the recovered offset order.
78
79 // The mesh whose vertices this animation drives. The dump labels it "light:"; see the class
80 // documentation for why the label is wrong.
81 Mesh *mMesh; // +0x18
82
83public:
85 enum { kSerialVersion = 0 };
86
93 enum { kCopyShareKeys = 0x40 };
94
102 struct PointsKey {
103 std::vector<Vector3> mValues;
104 float mFrame;
105 };
106
108 struct TexsKey {
109 std::vector<Vector2> mValues;
110 float mFrame;
111 };
112
114 struct ColorsKey {
115 std::vector<Color> mValues;
116 float mFrame;
117 };
118
126 MeshAnim(const HxStr &name);
127
132 virtual ~MeshAnim();
133
144 virtual float FilteredFrameEnd();
145
156 virtual void DumpText(Dbg &sink);
157
168 virtual void Save(Stream &stream);
169
182 virtual void Replace(Object *pFrom, Object *pTo);
183
191 virtual const HxStr &ClassName() const;
192
205 virtual void Copy(const Object *pSource, unsigned nFlags);
206
218 virtual void Load(Stream &stream);
219
231 void CopyVertKeys(int nFromVert, int nToVert);
232
243 void AppendVertKeys(int nVert);
244
256 void SetMesh(Mesh *pMesh);
257
269 void SetKeysOwner(MeshAnim *pOwner);
270
277 std::list<PointsKey> mVertPointsKeys;
279 std::list<TexsKey> mVertTexsKeys;
281 std::list<ColorsKey> mVertColorsKeys;
282
287
288protected:
301 virtual void SetFrameSelf(float flFrame);
302};
303
316
329
337
352
353} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Animatable()
Construct an animatable with no children, no filters, and a zero frame.
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
Per-vertex animation of one mesh.
Definition meshanim.h:45
virtual void Load(Stream &stream)
Load the animation.
virtual const HxStr & ClassName() const
Return the registered class name, "MeshAnim".
virtual float FilteredFrameEnd()
Report the frame of the last keyframe across the three channels.
virtual ~MeshAnim()
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy another animation over this one.
virtual void Save(Stream &stream)
Serialise the animation.
void SetKeysOwner(MeshAnim *pOwner)
Make another animation the one whose channels drive this one.
MeshAnim(const HxStr &name)
Construct an animation with no keyframes that owns its own channels.
virtual void SetFrameSelf(float flFrame)
Interpolate the three channels at a frame and write the result into the mesh.
virtual void Replace(Object *pFrom, Object *pTo)
Replace one object reference with another.
std::list< ColorsKey > mVertColorsKeys
Colour keyframes.
Definition meshanim.h:281
void AppendVertKeys(int nVert)
Append a copy of one vertex slot to every keyframe of all three channels.
MeshAnim * mKeysOwner
Definition meshanim.h:286
@ kSerialVersion
Definition meshanim.h:85
void CopyVertKeys(int nFromVert, int nToVert)
Copy one vertex slot over another in every keyframe of all three channels.
std::list< PointsKey > mVertPointsKeys
Position keyframes.
Definition meshanim.h:277
void SetMesh(Mesh *pMesh)
Change the mesh this animation deforms.
virtual void DumpText(Dbg &sink)
Write the animation to the engine text sink.
std::list< TexsKey > mVertTexsKeys
Texture coordinate keyframes.
Definition meshanim.h:279
@ kCopyShareKeys
Definition meshanim.h:93
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
The rendering engine.
Definition animhelper.h:3
Object * CreateRegisteredMeshAnim(const HxStr &name)
Allocate and construct a mesh animation for the registered "MeshAnim" class.
Manager TheManager
The renderer's object registry.
void RegisterMeshAnimClass()
Register the "MeshAnim" class with Rnd::Manager.
Definition meshanim.h:349
MeshAnim * NewMeshAnim(const HxStr &name)
Allocate and construct a mesh animation, without the narrowing CreateRegisteredMeshAnim() performs.
HxStr g_meshAnimClassName
Registered class name of Rnd::MeshAnim, the string "MeshAnim".
One keyframe of the vertex colour channel.
Definition meshanim.h:114
float mFrame
Definition meshanim.h:116
std::vector< Color > mValues
Definition meshanim.h:115
One keyframe of the vertex position channel.
Definition meshanim.h:102
float mFrame
Definition meshanim.h:104
std::vector< Vector3 > mValues
Definition meshanim.h:103
One keyframe of the first texture coordinate channel.
Definition meshanim.h:108
std::vector< Vector2 > mValues
Definition meshanim.h:109
float mFrame
Definition meshanim.h:110