forked from izrik/FbxSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Visitor.cs
460 lines (403 loc) · 16.9 KB
/
Visitor.cs
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
using System;
using FbxSharp;
using System.Collections.Generic;
namespace FbxSharp
{
public partial class Visitor
{
// public virtual void Visit(FbxObject obj) { }
// public virtual void Visit(FbxScene scene) { }
// public virtual void Visit(FbxNode node) { }
// public virtual void Visit(FbxNodeAttribute obj) { }
// public virtual void Visit(FbxSurfaceMaterial obj) { }
// public virtual void Visit(FbxSurfaceLambert obj) { }
// public virtual void Visit(FbxSurfacePhong obj) { }
// public virtual void Visit(FbxMesh obj) { }
// public virtual void Visit(FbxGeometry obj) { }
// public virtual void Visit(FbxGeometryBase obj) { }
// public virtual void Visit(FbxLayerElementTexture tex) { }
// public virtual void Visit(FbxLayerContainer layerContainer) { }
// public virtual void Visit(FbxDocument obj) { }
// public virtual void Visit(FbxCollection obj) { }
// public virtual void Visit(FbxAnimLayer obj) { }
// public virtual void Visit(FbxAnimStack obj) { }
// public virtual void Visit(FbxAnimCurve obj) { }
// public virtual void Visit(FbxAnimCurveNode obj) { }
// public virtual void Visit(FbxDeformer obj) { }
// public virtual void Visit(FbxPose pose) { }
// public virtual void Visit(FbxSubDeformer obj) { }
// public virtual void Visit(FbxTexture obj) { }
// public virtual void Visit(FbxVideo obj) { }
// public virtual void Visit(FbxCamera obj) { }
// public virtual void Visit(FbxLight obj) { }
// public virtual void Visit(FbxNull obj) { }
// public virtual void Visit(FbxSkeleton obj) { }
/*********************************/
// public void Accept(object obj)
// {
// Accept(obj, new HashSet<object>());
// }
//
// protected void Accept(object obj, ISet<object> visitedObjects)
// {
// if (obj == null) return;
// if (visitedObjects.Contains(obj)) return;
// visitedObjects.Add(obj);
//
// var type = obj.GetType();
//
// // var prop = obj as Property;
// // if (prop != null)
// // {
// // Accept(prop, visitedObjects);
// // return;
// // }
//
// if (type == typeof(FbxObject))
// _AcceptFbxObject((FbxObject)obj, visitedObjects);
// else if (type == typeof(FbxScene))
// _AcceptFbxScene((FbxScene)obj, visitedObjects);
// else if (type == typeof(FbxNode))
// _AcceptFbxNode((FbxNode)obj, visitedObjects);
// else if (type == typeof(FbxNodeAttribute))
// _AcceptFbxNodeAttribute((FbxNodeAttribute)obj, visitedObjects);
// else if (type == typeof(FbxSurfaceMaterial))
// _AcceptFbxSurfaceMaterial((FbxSurfaceMaterial)obj, visitedObjects);
// else if (type == typeof(FbxSurfaceLambert))
// _AcceptFbxSurfaceLambert((FbxSurfaceLambert)obj, visitedObjects);
// else if (type == typeof(FbxSurfacePhong))
// _AcceptFbxSurfacePhong((FbxSurfacePhong)obj, visitedObjects);
// else if (type == typeof(FbxMesh))
// _AcceptFbxMesh((FbxMesh)obj, visitedObjects);
// else if (type == typeof(FbxGeometry))
// _AcceptFbxGeometry((FbxGeometry)obj, visitedObjects);
// else if (type == typeof(FbxGeometryBase))
// _AcceptFbxGeometryBase((FbxGeometryBase)obj, visitedObjects);
// else if (type == typeof(FbxLayerElementTexture))
// _AcceptFbxLayerElementTexture((FbxLayerElementTexture)obj, visitedObjects);
// else if (type == typeof(FbxLayerContainer))
// _AcceptFbxLayerContainer((FbxLayerContainer)obj, visitedObjects);
// else if (type == typeof(FbxDocument))
// _AcceptFbxDocument((FbxDocument)obj, visitedObjects);
// else if (type == typeof(FbxCollection))
// _AcceptFbxCollection((FbxCollection)obj, visitedObjects);
// else if (type == typeof(FbxAnimLayer))
// _AcceptFbxAnimLayer((FbxAnimLayer)obj, visitedObjects);
// else if (type == typeof(FbxAnimStack))
// _AcceptFbxAnimStack((FbxAnimStack)obj, visitedObjects);
// else if (type == typeof(FbxAnimCurve))
// _AcceptFbxAnimCurve((FbxAnimCurve)obj, visitedObjects);
// else if (type == typeof(FbxAnimCurveNode))
// _AcceptFbxAnimCurveNode((FbxAnimCurveNode)obj, visitedObjects);
// else if (type == typeof(FbxDeformer))
// _AcceptFbxDeformer((FbxDeformer)obj, visitedObjects);
// else if (type == typeof(FbxPose))
// _AcceptFbxPose((FbxPose)obj, visitedObjects);
// else if (type == typeof(FbxSubDeformer))
// _AcceptFbxSubDeformer((FbxSubDeformer)obj, visitedObjects);
// else if (type == typeof(FbxTexture))
// _AcceptFbxTexture((FbxTexture)obj, visitedObjects);
// else if (type == typeof(FbxVideo))
// _AcceptFbxVideo((FbxVideo)obj, visitedObjects);
// else if (type == typeof(FbxCamera))
// Camera((FbxCamera)obj, visitedObjects);
// else if (type == typeof(FbxLight))
// _AcceptFbxLight((FbxLight)obj, visitedObjects);
// else if (type == typeof(FbxNull))
// _AcceptFbxNull((FbxNull)obj, visitedObjects);
// else if (type == typeof(FbxSkeleton))
// _AcceptFbxSkeleton((FbxSkeleton)obj, visitedObjects);
// }
protected void _AcceptFbxObject(FbxObject obj, ISet<object> visitedObjects)
{
//Accept(obj.GetDocument());
//Accept(obj.GetRootDocument());
Accept(obj.GetScene(), visitedObjects);
int i;
for (i = 0; i < obj.GetSrcObjectCount(); i++)
{
Accept(obj.GetSrcObject(i), visitedObjects);
}
for (i = 0; i < obj.GetDstObjectCount(); i++)
{
Accept(obj.GetDstObject(i), visitedObjects);
}
FbxProperty prop = obj.GetFirstProperty();
while (prop != null && prop.IsValid())
{
for (i = 0; i < prop.GetSrcObjectCount(); i++)
{
var srcObj = prop.GetSrcObject(i);
Accept(srcObj, visitedObjects);
}
for (i = 0; i < prop.GetDstObjectCount(); i++)
{
var dstObj = prop.GetDstObject(i);
Accept(dstObj, visitedObjects);
}
// TODO: object references in properties
// TODO: object references in src and dst properties
prop = obj.GetNextProperty(prop);
}
prop = obj.RootProperty;
for (i = 0; i < prop.GetSrcObjectCount(); i++)
{
var srcObj = prop.GetSrcObject(i);
Accept(srcObj, visitedObjects);
}
for (i = 0; i < prop.GetDstObjectCount(); i++)
{
var dstObj = prop.GetDstObject(i);
Accept(dstObj, visitedObjects);
}
}
protected void _AcceptFbxScene(FbxScene scene, ISet<object> visitedObjects)
{
// GenericNodeCount
// CharacterCount
// CharacterPoseCount
int i;
for (i = 0; i < scene.GetPoseCount(); i++)
{
Accept(scene.GetPose(i), visitedObjects);
}
for (i = 0; i < scene.GetMaterialCount(); i++)
{
Accept(scene.GetMaterial(i), visitedObjects);
}
for (i = 0; i < scene.GetTextureCount(); i++)
{
Accept(scene.GetTexture(i), visitedObjects);
}
for (i = 0; i < scene.GetNodeCount(); i++)
{
Accept(scene.GetNode(i), visitedObjects);
}
//for (i = 0; i < scene.GetGeometryCount(); i++)
//{
// Accept(scene.GetGeometry(i));
//}
//for (i = 0; i < scene.GetVideoCount(); i++)
//{
// Accept(scene.GetVideo(i));
//}
if (scene.GetRootNode() != null)
{
Accept(scene.GetRootNode(), visitedObjects);
}
// other stuff
}
protected void _AcceptFbxNode(FbxNode node, ISet<object> visitedObjects)
{
if (node.GetParent() != null)
Accept(node.GetParent(), visitedObjects);
int i;
for (i = 0; i < node.GetChildCount(); i++)
{
Accept(node.GetChild(i), visitedObjects);
}
//if (node.GetTarget() != null)
//{
// Accept(node.GetTarget());
//}
//if (node.GetTargetUp() != null)
//{
// Accept(node.GetTargetUp());
//}
for (i = 0; i < node.GetNodeAttributeCount(); i++)
{
Accept(node.GetNodeAttributeByIndex(i), visitedObjects);
}
for (i = 0; i < node.GetMaterialCount(); i++)
{
Accept(node.GetMaterial(i), visitedObjects);
}
}
protected void _AcceptFbxNodeAttribute(FbxNodeAttribute obj, ISet<object> visitedObjects)
{
Accept(obj.GetNode(), visitedObjects);
}
protected void _AcceptFbxSurfaceMaterial(FbxSurfaceMaterial obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxSurfaceLambert(FbxSurfaceLambert obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxSurfacePhong(FbxSurfacePhong obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxMesh(FbxMesh obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxGeometry(FbxGeometry obj, ISet<object> visitedObjects)
{
int i;
for (i = 0; i < obj.GetDeformerCount(); i++)
{
Accept(obj.GetDeformer(i), visitedObjects);
}
// geometry weighted map
// shape
}
protected void _AcceptFbxGeometryBase(FbxGeometryBase obj, ISet<object> visitedObjects)
{
// TODO: geometry elements
}
protected void _AcceptFbxLayerElementTexture(FbxLayerElementTexture tex, ISet<object> visitedObjects)
{
throw new NotImplementedException();
//if (tex == null) return;
//
//LayerElementArrayT<Texture> tarray = tex.GetDirectArray();
//
//int i;
//for (i = 0; i < tarray.List.Count; i++)
//{
// Accept(tarray.GetAt(i));
//}
}
protected void _AcceptFbxLayerContainer(FbxLayerContainer layerContainer, ISet<object> visitedObjects)
{
int j;
for (j = 0; j < layerContainer.GetLayerCount(); j++)
{
FbxLayer layer = layerContainer.GetLayer(j);
int i;
FbxLayerElementMaterial mats = layer.GetMaterials();
if (mats != null)
{
FbxLayerElementTemplate<FbxSurfaceMaterial> _mats = mats;
LayerElementArrayT<FbxSurfaceMaterial> marray = _mats.GetDirectArray();
//for (i = 0; i < marray.GetCount(); i++)
//{
// Accept(marray.GetAt(i));
//}
}
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureEmissive));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureEmissiveFactor));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureAmbient));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureAmbientFactor));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureDiffuseFactor));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureSpecular));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureNormalMap));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureSpecularFactor));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureShininess));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureBump));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureTransparency));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureTransparencyFactor));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureReflection));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureReflectionFactor));
//Accept(this, layer.GetTextures(LayerElement.EType.eTextureDisplacement));
}
}
protected void _AcceptFbxDocument(FbxDocument obj, ISet<object> visitedObjects)
{
int i;
//for (i = 0; i < obj.GetRootMemberCount(); i++)
//{
// Accept(obj.GetRootMember(i));
//}
//
//if (obj.GetDocumentInfo() != null)
//{
// Accept(obj.GetDocumentInfo());
//}
}
protected void _AcceptFbxCollection(FbxCollection obj, ISet<object> visitedObjects)
{
int i;
//for (i = 0; i < obj.GetMemberCount(); i++)
//{
// Accept(obj.GetMember(i));
//}
}
protected void _AcceptFbxAnimLayer(FbxAnimLayer obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxAnimStack(FbxAnimStack obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxAnimCurve(FbxAnimCurve obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxAnimCurveBase(FbxAnimCurveBase obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxAnimCurveNode(FbxAnimCurveNode obj, ISet<object> visitedObjects)
{
int i;
int j;
//for (i = 0; i < obj.GetChannelsCount(); i++)
//{
// for (j = 0; j < obj.GetCurveCount((uint)i); j++)
// {
// AnimCurve curve = obj.GetCurve((uint)i, (uint)j);
// Accept(curve);
// }
//}
}
protected void _AcceptFbxDeformer(FbxDeformer obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxPose(FbxPose pose, ISet<object> visitedObjects)
{
int i;
for (i = 0; i < pose.GetCount(); i++)
{
Accept(pose.GetNode(i), visitedObjects);
}
}
protected void _AcceptFbxSubDeformer(FbxSubDeformer obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxTexture(FbxTexture obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxVideo(FbxVideo obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxCamera(FbxCamera obj, ISet<object> visitedObjects)
{
//throw new NotImplementedException(); // R: -- TODO -- temporarily commented out.
}
protected void _AcceptFbxLight(FbxLight obj, ISet<object> visitedObjects)
{
//TODO: shadow texture
}
protected void _AcceptFbxNull(FbxNull obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxSkeleton(FbxSkeleton obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxAnimEvaluator(FbxAnimEvaluator obj, ISet<object> visitedObjects)
{
//TODO: GetPropertyCurveNode
}
protected void _AcceptFbxAnimEvalClassic(FbxAnimEvalClassic obj, ISet<object> visitedObjects)
{
}
protected void _AcceptFbxSkin(FbxSkin obj, ISet<object> visitedObjects)
{
//TODO: GetGeometry
//TODO: Clusters
}
protected void _AcceptFbxGlobalSettings(FbxGlobalSettings obj, ISet<object> visitedObjects)
{
// TODO: default camera
}
protected void _AcceptFbxIOBase(FbxIOBase obj, ISet<object> visitedObjects)
{
throw new NotImplementedException();
}
protected void _AcceptFbxImporter(FbxImporter obj, ISet<object> visitedObjects)
{
throw new NotImplementedException();
}
protected void _AcceptFbxCluster(FbxCluster obj, ISet<object> visitedObjects)
{
//TODO: link
//TODO: associated model
}
}
}