-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cxx
356 lines (290 loc) · 9.87 KB
/
main.cxx
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
/****************************************************************************************
Copyright (C) 2014 Autodesk, Inc.
All rights reserved.
Use of this software is subject to the terms of the Autodesk license agreement
provided at the time of installation or download, or which otherwise accompanies
this software in either electronic or hard copy form.
****************************************************************************************/
/////////////////////////////////////////////////////////////////////////
//
// This example illustrates how to detect if a scene is password
// protected, import and browse the scene to access node and animation
// information. It displays the content of the FBX file which name is
// passed as program argument. You can try it with the various FBX files
// output by the export examples.
//
/////////////////////////////////////////////////////////////////////////
#include "../Common/Common.h"
#include "DisplayCommon.h"
#include "DisplayHierarchy.h"
#include "DisplayAnimation.h"
#include "DisplayMarker.h"
#include "DisplaySkeleton.h"
#include "DisplayMesh.h"
#include "DisplayNurb.h"
#include "DisplayPatch.h"
#include "DisplayLodGroup.h"
#include "DisplayCamera.h"
#include "DisplayLight.h"
#include "DisplayGlobalSettings.h"
#include "DisplayPose.h"
#include "DisplayPivotsAndLimits.h"
#include "DisplayUserProperties.h"
#include "DisplayGenericInfo.h"
// Local function prototypes.
void DisplayContent(FbxScene* pScene);
void DisplayContent(FbxNode* pNode);
void DisplayTarget(FbxNode* pNode);
void DisplayTransformPropagation(FbxNode* pNode);
void DisplayGeometricTransform(FbxNode* pNode);
void DisplayMetaData(FbxScene* pScene);
static bool gVerbose = true;
int main(int argc, char** argv)
{
FbxManager* lSdkManager = NULL;
FbxScene* lScene = NULL;
bool lResult;
// Prepare the FBX SDK.
InitializeSdkObjects(lSdkManager, lScene);
// Load the scene.
// The example can take a FBX file as an argument.
FbxString lFilePath("");
for( int i = 1, c = argc; i < c; ++i )
{
if( FbxString(argv[i]) == "-test" ) gVerbose = false;
else if( lFilePath.IsEmpty() ) lFilePath = argv[i];
}
if( lFilePath.IsEmpty() )
{
lResult = false;
FBXSDK_printf("\n\nUsage: ImportScene <FBX file name>\n\n");
}
else
{
FBXSDK_printf("\n\nFile: %s\n\n", lFilePath.Buffer());
lResult = LoadScene(lSdkManager, lScene, lFilePath.Buffer());
}
if(lResult == false)
{
FBXSDK_printf("\n\nAn error occurred while loading the scene...");
}
else
{
// Display the scene.
DisplayMetaData(lScene);
FBXSDK_printf("\n\n---------------------\nGlobal Light Settings\n---------------------\n\n");
if( gVerbose ) DisplayGlobalLightSettings(&lScene->GetGlobalSettings());
FBXSDK_printf("\n\n----------------------\nGlobal Camera Settings\n----------------------\n\n");
if( gVerbose ) DisplayGlobalCameraSettings(&lScene->GetGlobalSettings());
FBXSDK_printf("\n\n--------------------\nGlobal Time Settings\n--------------------\n\n");
if( gVerbose ) DisplayGlobalTimeSettings(&lScene->GetGlobalSettings());
FBXSDK_printf("\n\n---------\nHierarchy\n---------\n\n");
if( gVerbose ) DisplayHierarchy(lScene);
FBXSDK_printf("\n\n------------\nNode Content\n------------\n\n");
if( gVerbose ) DisplayContent(lScene);
FBXSDK_printf("\n\n----\nPose\n----\n\n");
if( gVerbose ) DisplayPose(lScene);
FBXSDK_printf("\n\n---------\nAnimation\n---------\n\n");
if( gVerbose ) DisplayAnimation(lScene);
//now display generic information
FBXSDK_printf("\n\n---------\nGeneric Information\n---------\n\n");
if( gVerbose ) DisplayGenericInfo(lScene);
}
// Destroy all objects created by the FBX SDK.
DestroySdkObjects(lSdkManager, lResult);
return 0;
}
void DisplayContent(FbxScene* pScene)
{
int i;
FbxNode* lNode = pScene->GetRootNode();
if(lNode)
{
for(i = 0; i < lNode->GetChildCount(); i++)
{
DisplayContent(lNode->GetChild(i));
}
}
}
void DisplayContent(FbxNode* pNode)
{
FbxNodeAttribute::EType lAttributeType;
int i;
FbxControlSet example;
if(pNode->GetNodeAttribute() == NULL)
{
FBXSDK_printf("NULL Node Attribute\n\n");
}
else
{
lAttributeType = (pNode->GetNodeAttribute()->GetAttributeType());
switch (lAttributeType)
{
default:
break;
case FbxNodeAttribute::eMarker:
DisplayMarker(pNode);
//Assign pNode's ControlSet.
example=ExampleControlSet(pNode);
//Set the axis not to use.
example.SetUseAxis(false);
break;
case FbxNodeAttribute::eSkeleton:
DisplaySkeleton(pNode);
break;
case FbxNodeAttribute::eMesh:
DisplayMesh(pNode);
break;
case FbxNodeAttribute::eNurbs:
DisplayNurb(pNode);
break;
case FbxNodeAttribute::ePatch:
DisplayPatch(pNode);
break;
case FbxNodeAttribute::eCamera:
DisplayCamera(pNode);
break;
case FbxNodeAttribute::eLight:
DisplayLight(pNode);
break;
case FbxNodeAttribute::eLODGroup:
DisplayLodGroup(pNode);
break;
}
}
DisplayUserProperties(pNode);
DisplayTarget(pNode);
DisplayPivotsAndLimits(pNode);
DisplayTransformPropagation(pNode);
DisplayGeometricTransform(pNode);
for(i = 0; i < pNode->GetChildCount(); i++)
{
DisplayContent(pNode->GetChild(i));
}
}
void DisplayTarget(FbxNode* pNode)
{
if(pNode->GetTarget() != NULL)
{
DisplayString(" Target Name: ", (char *) pNode->GetTarget()->GetName());
}
}
void DisplayTransformPropagation(FbxNode* pNode)
{
FBXSDK_printf(" Transformation Propagation\n");
//
// Rotation Space
//
EFbxRotationOrder lRotationOrder;
pNode->GetRotationOrder(FbxNode::eSourcePivot, lRotationOrder);
FBXSDK_printf(" Rotation Space: ");
switch (lRotationOrder)
{
case eEulerXYZ:
FBXSDK_printf("Euler XYZ\n");
break;
case eEulerXZY:
FBXSDK_printf("Euler XZY\n");
break;
case eEulerYZX:
FBXSDK_printf("Euler YZX\n");
break;
case eEulerYXZ:
FBXSDK_printf("Euler YXZ\n");
break;
case eEulerZXY:
FBXSDK_printf("Euler ZXY\n");
break;
case eEulerZYX:
FBXSDK_printf("Euler ZYX\n");
break;
case eSphericXYZ:
FBXSDK_printf("Spheric XYZ\n");
break;
}
//
// Use the Rotation space only for the limits
// (keep using eEulerXYZ for the rest)
//
FBXSDK_printf(" Use the Rotation Space for Limit specification only: %s\n",
pNode->GetUseRotationSpaceForLimitOnly(FbxNode::eSourcePivot) ? "Yes" : "No");
//
// Inherit Type
//
FbxTransform::EInheritType lInheritType;
pNode->GetTransformationInheritType(lInheritType);
FBXSDK_printf(" Transformation Inheritance: ");
switch (lInheritType)
{
case FbxTransform::eInheritRrSs:
FBXSDK_printf("RrSs\n");
break;
case FbxTransform::eInheritRSrs:
FBXSDK_printf("RSrs\n");
break;
case FbxTransform::eInheritRrs:
FBXSDK_printf("Rrs\n");
break;
}
}
void DisplayGeometricTransform(FbxNode* pNode)
{
FbxVector4 lTmpVector;
FBXSDK_printf(" Geometric Transformations\n");
//
// Translation
//
lTmpVector = pNode->GetGeometricTranslation(FbxNode::eSourcePivot);
FBXSDK_printf(" Translation: %f %f %f\n", lTmpVector[0], lTmpVector[1], lTmpVector[2]);
//
// Rotation
//
lTmpVector = pNode->GetGeometricRotation(FbxNode::eSourcePivot);
FBXSDK_printf(" Rotation: %f %f %f\n", lTmpVector[0], lTmpVector[1], lTmpVector[2]);
//
// Scaling
//
lTmpVector = pNode->GetGeometricScaling(FbxNode::eSourcePivot);
FBXSDK_printf(" Scaling: %f %f %f\n", lTmpVector[0], lTmpVector[1], lTmpVector[2]);
}
void DisplayMetaData(FbxScene* pScene)
{
FbxDocumentInfo* sceneInfo = pScene->GetSceneInfo();
if (sceneInfo)
{
FBXSDK_printf("\n\n--------------------\nMeta-Data\n--------------------\n\n");
FBXSDK_printf(" Title: %s\n", sceneInfo->mTitle.Buffer());
FBXSDK_printf(" Subject: %s\n", sceneInfo->mSubject.Buffer());
FBXSDK_printf(" Author: %s\n", sceneInfo->mAuthor.Buffer());
FBXSDK_printf(" Keywords: %s\n", sceneInfo->mKeywords.Buffer());
FBXSDK_printf(" Revision: %s\n", sceneInfo->mRevision.Buffer());
FBXSDK_printf(" Comment: %s\n", sceneInfo->mComment.Buffer());
FbxThumbnail* thumbnail = sceneInfo->GetSceneThumbnail();
if (thumbnail)
{
FBXSDK_printf(" Thumbnail:\n");
switch (thumbnail->GetDataFormat())
{
case FbxThumbnail::eRGB_24:
FBXSDK_printf(" Format: RGB\n");
break;
case FbxThumbnail::eRGBA_32:
FBXSDK_printf(" Format: RGBA\n");
break;
}
switch (thumbnail->GetSize())
{
default:
break;
case FbxThumbnail::eNotSet:
FBXSDK_printf(" Size: no dimensions specified (%ld bytes)\n", thumbnail->GetSizeInBytes());
break;
case FbxThumbnail::e64x64:
FBXSDK_printf(" Size: 64 x 64 pixels (%ld bytes)\n", thumbnail->GetSizeInBytes());
break;
case FbxThumbnail::e128x128:
FBXSDK_printf(" Size: 128 x 128 pixels (%ld bytes)\n", thumbnail->GetSizeInBytes());
}
}
}
}