-
-
Notifications
You must be signed in to change notification settings - Fork 554
Expand file tree
/
Copy pathObjectViewer.h
More file actions
288 lines (215 loc) · 7.25 KB
/
Copy pathObjectViewer.h
File metadata and controls
288 lines (215 loc) · 7.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#ifndef __OBJECT_VIEWER_H__
#define __OBJECT_VIEWER_H__
#if RENDERING
#include "GlWindow.h"
class CMeshInstance;
class CVertMeshInstance;
class CSkelMeshInstance;
class CSkeletalMesh;
class CAnimSet;
class CStaticMesh;
struct CMeshVertex;
struct CBaseMeshLod;
class UUnrealMaterial;
class UVertMesh;
class USkeleton;
class UIMenuItem;
enum class EAnimRetargetingMode;
#define TEST_FILES 1 // comment line to disable some notifications
/*-----------------------------------------------------------------------------
Basic object viewer
-----------------------------------------------------------------------------*/
class CObjectViewer
{
public:
const UObject* Object;
CApplication* Window;
const UObject* JumpAfterFrame;
bool bHasVisualObject;
CObjectViewer(const UObject* Obj, CApplication* Win, bool InNonVisualObject = false);
virtual ~CObjectViewer()
{}
virtual void Dump();
#if TEST_FILES
virtual void Test()
{}
#endif
virtual void Export();
virtual void ShowHelp();
virtual void Draw2D();
virtual void ProcessKey(unsigned key);
virtual void ProcessKeyUp(unsigned key)
{}
#if HAS_UI
virtual UIMenuItem* GetObjectMenu(UIMenuItem* menu);
#endif
virtual void Draw3D(float TimeDelta)
{}
void JumpTo(const UObject* Object)
{
JumpAfterFrame = Object;
}
};
/*-----------------------------------------------------------------------------
Material viewer
-----------------------------------------------------------------------------*/
class CMaterialViewer : public CObjectViewer
{
public:
bool IsTexture;
static bool ShowOutline;
static bool ShowChannels;
static int ShapeIndex;
CMaterialViewer(UUnrealMaterial* Material, CApplication* Window);
virtual ~CMaterialViewer() override;
virtual void ShowHelp() override;
virtual void ProcessKey(unsigned key) override;
virtual void Draw2D() override;
virtual void Draw3D(float TimeDelta) override;
protected:
void FlushProps();
void OutlineMaterial(const UObject *Obj, int indent = 0);
UUnrealMaterial* NonConstMaterial;
};
/*-----------------------------------------------------------------------------
Basic mesh viewer (ULodMesh)
-----------------------------------------------------------------------------*/
class CMeshViewer : public CObjectViewer
{
public:
// linked data
CMeshInstance *Inst;
// debug rendering
unsigned DrawFlags;
bool Wireframe;
CMeshViewer(const UObject* Mesh, CApplication* Window)
: CObjectViewer(Mesh, Window)
, DrawFlags(0)
, Wireframe(false)
{}
virtual ~CMeshViewer() override;
void InitViewerPosition(const CVec3 &Mins, const CVec3 &Maxs); //?? CBox Bounds?
virtual void ShowHelp() override;
virtual void ProcessKey(unsigned key) override;
#if HAS_UI
virtual UIMenuItem* GetObjectMenu(UIMenuItem* menu) override;
#endif
virtual void Draw3D(float TimeDelta) override;
virtual void DrawMesh(CMeshInstance *Inst);
// Print a text about mesh material. Automatically highlights material if mouse points
// at its text record on screen.
void PrintMaterialInfo(int Index, UUnrealMaterial *Material, int NumFaces);
void DisplayUV(const CMeshVertex* Verts, int VertexSize, const CBaseMeshLod* Mesh, int UVIndex);
};
/*-----------------------------------------------------------------------------
Vertex mesh viewer (UVertMesh)
-----------------------------------------------------------------------------*/
class CVertMeshViewer : public CMeshViewer
{
public:
int AnimIndex;
CVertMeshViewer(UVertMesh* Mesh, CApplication* Window);
virtual void ShowHelp() override;
virtual void ProcessKey(unsigned key) override;
virtual void Dump() override;
virtual void Export() override;
#if TEST_FILES
virtual void Test() override;
#endif
virtual void Draw2D() override;
virtual void Draw3D(float TimeDelta) override;
};
/*-----------------------------------------------------------------------------
Skeletal mesh viewer (USkeletalMesh)
-----------------------------------------------------------------------------*/
extern UObject *GForceAnimSet;
class CSkelMeshViewer : public CMeshViewer
{
public:
int AnimIndex;
bool IsFollowingMesh;
int ShowSkel; // 0 - mesh, 1 - mesh+skel, 2 - skel only
bool ShowLabels;
bool ShowAttach;
bool ShowUV;
CSkelMeshViewer(CSkeletalMesh* Mesh, CApplication* Window);
void TagMesh(CSkelMeshInstance *Inst);
static void UntagAllMeshes();
virtual void ShowHelp() override;
#if HAS_UI
virtual UIMenuItem* GetObjectMenu(UIMenuItem* menu) override;
#endif
virtual void Dump() override;
virtual void Export() override;
virtual void Draw2D() override;
virtual void Draw3D(float TimeDelta) override;
virtual void ProcessKey(unsigned key) override;
virtual void ProcessKeyUp(unsigned key) override;
void SetAnim(const CAnimSet* AnimSet);
void AttachAnimSet();
void FindUE4Animations();
virtual void DrawMesh(CMeshInstance *Inst) override;
static TArray<CSkelMeshInstance*> TaggedMeshes; // for displaying multipart meshes
private:
CSkeletalMesh* Mesh;
const CAnimSet* Anim;
bool bIsUE4Mesh;
USkeleton* Skeleton;
int HighlightMeshIndex;
void SetRetargetingMode(EAnimRetargetingMode NewMode);
};
/*-----------------------------------------------------------------------------
Static mesh viewer (CStaticMesh)
-----------------------------------------------------------------------------*/
class CStatMeshViewer : public CMeshViewer
{
public:
CStatMeshViewer(CStaticMesh* Mesh, CApplication* Window);
virtual void ShowHelp() override;
#if HAS_UI
virtual UIMenuItem* GetObjectMenu(UIMenuItem* menu) override;
#endif
virtual void Dump() override;
virtual void Draw2D() override;
virtual void ProcessKey(unsigned key) override;
private:
CStaticMesh *Mesh;
bool ShowUV;
};
/*-----------------------------------------------------------------------------
Macros for easier object format verification
-----------------------------------------------------------------------------*/
#if TEST_FILES
#define VERIFY(MeshField, MField) \
if (Mesh->MeshField != Mesh->MField) appNotify(#MeshField" "#MField);
//#define VERIFY2(MeshField, MField) \
// if (M->MeshField != Mesh->MField) appNotify(#MeshField" "#MField);
#define VERIFY_NULL(Field) \
if (Mesh->Field != 0) appNotify("%s != 0", #Field);
#define VERIFY_NOT_NULL(Field) \
if (Mesh->Field == 0) appNotify("%s == 0", #Field);
#define TEST_ARRAY(array) \
{ \
int min = 0x40000000, max = -0x40000000; \
for (int i = 0; i < array.Num(); i++) \
{ \
if (array[i] < min) min = array[i]; \
if (array[i] > max) max = array[i]; \
} \
if (array.Num()) \
appPrintf(#array": [%d .. %d]\n", min, max); \
}
#define TEST_ARRAY2(array,field) \
{ \
int min = 0x40000000, max = -0x40000000; \
for (int i = 0; i < array.Num(); i++) \
{ \
if (array[i].field < min) min = array[i].field; \
if (array[i].field > max) max = array[i].field; \
} \
if (array.Num()) \
appPrintf(#array"."#field": [%d .. %d]\n", min, max); \
}
#endif
#endif // RENDERING
#endif // __OBJECT_VIEWER_H__