-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportScene.py
More file actions
212 lines (166 loc) · 7.62 KB
/
Copy pathImportScene.py
File metadata and controls
212 lines (166 loc) · 7.62 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
"""
Copyright (C) 2017 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.
"""
import os, sys
from DisplayGlobalSettings import *
from DisplayHierarchy import DisplayHierarchy
from DisplayMarker import DisplayMarker
from DisplayMesh import DisplayMesh
from DisplayUserProperties import DisplayUserProperties
from DisplayPivotsAndLimits import DisplayPivotsAndLimits
from DisplaySkeleton import DisplaySkeleton
from DisplayNurb import DisplayNurb
from DisplayPatch import DisplayPatch
from DisplayCamera import DisplayCamera
from DisplayLight import DisplayLight
from DisplayLodGroup import DisplayLodGroup
from DisplayPose import DisplayPose
from DisplayAnimation import DisplayAnimation
from DisplayGenericInfo import DisplayGenericInfo
def DisplayMetaData(pScene):
sceneInfo = pScene.GetSceneInfo()
if sceneInfo:
print("\n\n--------------------\nMeta-Data\n--------------------\n")
print(" Title: %s" % sceneInfo.mTitle.Buffer())
print(" Subject: %s" % sceneInfo.mSubject.Buffer())
print(" Author: %s" % sceneInfo.mAuthor.Buffer())
print(" Keywords: %s" % sceneInfo.mKeywords.Buffer())
print(" Revision: %s" % sceneInfo.mRevision.Buffer())
print(" Comment: %s" % sceneInfo.mComment.Buffer())
thumbnail = sceneInfo.GetSceneThumbnail()
if thumbnail:
print(" Thumbnail:")
if thumbnail.GetDataFormat() == FbxThumbnail.eRGB_24 :
print(" Format: RGB")
elif thumbnail.GetDataFormat() == FbxThumbnail.eRGBA_32:
print(" Format: RGBA")
if thumbnail.GetSize() == FbxThumbnail.eNOT_SET:
print(" Size: no dimensions specified (%ld bytes)", thumbnail.GetSizeInBytes())
elif thumbnail.GetSize() == FbxThumbnail.e64x64:
print(" Size: 64 x 64 pixels (%ld bytes)", thumbnail.GetSizeInBytes())
elif thumbnail.GetSize() == FbxThumbnail.e128x128:
print(" Size: 128 x 128 pixels (%ld bytes)", thumbnail.GetSizeInBytes())
def DisplayContent(pScene):
lNode = pScene.GetRootNode()
if lNode:
for i in range(lNode.GetChildCount()):
DisplayNodeContent(lNode.GetChild(i))
def DisplayNodeContent(pNode):
if pNode.GetNodeAttribute() == None:
print("NULL Node Attribute\n")
else:
lAttributeType = (pNode.GetNodeAttribute().GetAttributeType())
if lAttributeType == FbxNodeAttribute.EType.eMarker:
DisplayMarker(pNode)
elif lAttributeType == FbxNodeAttribute.EType.eSkeleton:
DisplaySkeleton(pNode)
elif lAttributeType == FbxNodeAttribute.EType.eMesh:
DisplayMesh(pNode)
elif lAttributeType == FbxNodeAttribute.EType.eNurbs:
DisplayNurb(pNode)
elif lAttributeType == FbxNodeAttribute.EType.ePatch:
DisplayPatch(pNode)
elif lAttributeType == FbxNodeAttribute.EType.eCamera:
DisplayCamera(pNode)
elif lAttributeType == FbxNodeAttribute.EType.eLight:
DisplayLight(pNode)
DisplayUserProperties(pNode)
DisplayTarget(pNode)
DisplayPivotsAndLimits(pNode)
DisplayTransformPropagation(pNode)
DisplayGeometricTransform(pNode)
for i in range(pNode.GetChildCount()):
DisplayNodeContent(pNode.GetChild(i))
def DisplayTarget(pNode):
if pNode.GetTarget():
DisplayString(" Target Name: ", pNode.GetTarget().GetName())
def DisplayTransformPropagation(pNode):
print(" Transformation Propagation")
# Rotation Space
lRotationOrder = pNode.GetRotationOrder(FbxNode.EPivotSet.eSourcePivot)
print(" Rotation Space:",)
if lRotationOrder == EFbxRotationOrder.eEulerXYZ:
print("Euler XYZ")
elif lRotationOrder == EFbxRotationOrder.eEulerXZY:
print("Euler XZY")
elif lRotationOrder == EFbxRotationOrder.eEulerYZX:
print("Euler YZX")
elif lRotationOrder == EFbxRotationOrder.eEulerYXZ:
print("Euler YXZ")
elif lRotationOrder == EFbxRotationOrder.eEulerZXY:
print("Euler ZXY")
elif lRotationOrder == EFbxRotationOrder.eEulerZYX:
print("Euler ZYX")
elif lRotationOrder == EFbxRotationOrder.eSphericXYZ:
print("Spheric XYZ")
# Use the Rotation space only for the limits
# (keep using eEULER_XYZ for the rest)
if pNode.GetUseRotationSpaceForLimitOnly(FbxNode.EPivotSet.eSourcePivot):
print(" Use the Rotation Space for Limit specification only: Yes")
else:
print(" Use the Rotation Space for Limit specification only: No")
# Inherit Type
lInheritType = pNode.GetTransformationInheritType()
print(" Transformation Inheritance:",)
if lInheritType == FbxTransform.EInheritType.eInheritRrSs:
print("RrSs")
elif lInheritType == FbxTransform.EInheritType.eInheritRSrs:
print("RSrs")
elif lInheritType == FbxTransform.EInheritType.eInheritRrs:
print("Rrs")
def DisplayGeometricTransform(pNode):
print(" Geometric Transformations")
# Translation
lTmpVector = pNode.GetGeometricTranslation(FbxNode.EPivotSet.eSourcePivot)
print(" Translation: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2]))
# Rotation
lTmpVector = pNode.GetGeometricRotation(FbxNode.EPivotSet.eSourcePivot)
print(" Rotation: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2]))
# Scaling
lTmpVector = pNode.GetGeometricScaling(FbxNode.EPivotSet.eSourcePivot)
print(" Scaling: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2]))
if __name__ == "__main__":
try:
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
from FbxCommon import *
except ImportError:
print("Error: module FbxCommon failed to import.\n")
sys.exit(1)
# Prepare the FBX SDK.
lSdkManager, lScene = InitializeSdkObjects()
# Load the scene.
# The example can take a FBX file as an argument.
if len(sys.argv) > 1:
print("\n\nFile: %s\n" % sys.argv[1])
lResult = LoadScene(lSdkManager, lScene, sys.argv[1])
else :
lResult = False
print("\n\nUsage: ImportScene <FBX file name>\n")
if not lResult:
print("\n\nAn error occurred while loading the scene...")
else :
DisplayMetaData(lScene)
print("\n\n---------------------\nGlobal Light Settings\n---------------------\n")
DisplayGlobalLightSettings(lScene)
print("\n\n----------------------\nGlobal Camera Settings\n----------------------\n")
DisplayGlobalCameraSettings(lScene)
print("\n\n--------------------\nGlobal Time Settings\n--------------------\n")
DisplayGlobalTimeSettings(lScene.GetGlobalSettings())
print("\n\n---------\nHierarchy\n---------\n")
DisplayHierarchy(lScene)
print("\n\n------------\nNode Content\n------------\n")
DisplayContent(lScene)
print("\n\n----\nPose\n----\n")
DisplayPose(lScene)
print("\n\n---------\nAnimation\n---------\n")
DisplayAnimation(lScene)
#now display generic information
print("\n\n---------\nGeneric Information\n---------\n")
DisplayGenericInfo(lScene)
# Destroy all objects created by the FBX SDK.
lSdkManager.Destroy()
sys.exit(0)