Last active
February 7, 2017 12:56
-
-
Save whaison/209b933ddcd09473547f60518f347733 to your computer and use it in GitHub Desktop.
ImportScene_00100.py included ||||||\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 DisplaySke…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from fbx import * | |
import os, sys | |
import re | |
#===================class Node========================= | |
import FbxCommon | |
#===================class Node========================= | |
#==================================================== | |
#================== DisplayCommon.py =================== | |
#==================================================== | |
def DisplayString(pHeader, pValue="" , pSuffix=""): | |
lString = pHeader | |
lString += str(pValue) | |
lString += pSuffix | |
print(lString) | |
DebugLog( str( lString ) ) | |
def DisplayBool(pHeader, pValue, pSuffix=""): | |
lString = pHeader | |
if pValue: | |
lString += "true" | |
else: | |
lString += "false" | |
lString += pSuffix | |
print(lString) | |
DebugLog( str( lString ) ) | |
def DisplayInt(pHeader, pValue, pSuffix=""): | |
lString = pHeader | |
lString += str(pValue) | |
lString += pSuffix | |
print(lString) | |
DebugLog( str( lString ) ) | |
def DisplayDouble(pHeader, pValue, pSuffix=""): | |
print("%s%f%s" % (pHeader, pValue, pSuffix)) | |
DebugLog("DisplayDouble () pHeader =" +str(pHeader)+" pValue= "+ str(pValue)+" pSuffix ="+str(pSuffix) ) | |
#(pHeader, pValue, pSuffix)) | |
def Display2DVector(pHeader, pValue, pSuffix=""): | |
print("%s%f, %f%s" % (pHeader, pValue[0], pValue[1], pSuffix)) | |
DebugLog("Display2DVector () pHeader =" +str(pHeader)+" pValue[0]= "+ str(pValue[0])+" pValue[1] ="+str(pValue[1]) +" pSuffix ="+str(pSuffix) ) | |
def Display3DVector(pHeader, pValue, pSuffix=""): | |
print("%s%f, %f, %f%s" % (pHeader, pValue[0], pValue[1], pValue[2], pSuffix)) | |
DebugLog("Display3DVector () pHeader =" +str(pHeader)+" pValue[0]= "+ str(pValue[0])+" pValue[1] ="+str(pValue[1]) +" pValue[2] ="+str(pValue[2]) +" pSuffix ="+str(pSuffix) ) | |
def Display4DVector(pHeader, pValue, pSuffix=""): | |
print("%s%f, %f, %f, %f%s" % (pHeader, pValue[0], pValue[1], pValue[2], pValue[3], pSuffix)) | |
DebugLog("Display4DVector () pHeader =" +str(pHeader)+" pValue[0]= "+ str(pValue[0])+" pValue[1] ="+str(pValue[1]) +" pValue[2] ="+str(pValue[2]) +" pValue[3] ="+str(pValue[3]) +" pSuffix ="+str(pSuffix) ) | |
def DisplayColor(pHeader, pValue, pSuffix=""): | |
print("%s%f (red), %f (green), %f (blue)%s" % (pHeader, pValue.mRed, pValue.mGreen, pValue.mBlue, pSuffix)) | |
DebugLog("DisplayColor () pHeader =" +str(pHeader)+" pValue.mRed= "+ str(pValue.mRed)+" pValue.mGreen ="+str(pValue.mGreen) +" pValue.mBlue ="+str(pValue.mBlue) +" pSuffix ="+str(pSuffix) ) | |
#==================================================== | |
#================== DisplayCommon.py ===================END | |
#==================================================== | |
#==================================================== | |
#================== DisplayGlobalSettings.py ===================STA | |
#==================================================== | |
#from DisplayGlobalSettings import * | |
from fbx import FbxGlobalLightSettings | |
from fbx import FbxGlobalCameraSettings | |
def DisplayGlobalLightSettings(pScene): | |
lGlobalLightSettings = pScene.GlobalLightSettings() | |
DisplayColor("ImportScene_00100.py 0067 line globalTimeSettings.py DisplayGlobalLightSettings () Default Ambient Color: ", lGlobalLightSettings.GetAmbientColor()) | |
DisplayBool("Fog Enabled: ", lGlobalLightSettings.GetFogEnable()) | |
DisplayColor("Fog Color: ", lGlobalLightSettings.GetFogColor()) | |
lFogMode = lGlobalLightSettings.GetFogMode() | |
if(lFogMode == FbxGlobalLightSettings.eLinear): | |
DisplayString("Fog Mode: Linear") | |
elif(lFogMode == FbxGlobalLightSettings.eExponential): | |
DisplayString("Fog Mode: Exponential") | |
elif(lFogMode == FbxGlobalLightSettings.eExponentialSquareRoot): | |
DisplayString("Fog Mode: Exponential Square Root") | |
else: | |
DisplayString("Fog Mode: UNKNOWN") | |
DisplayDouble("Fog Density: ", lGlobalLightSettings.GetFogDensity()) | |
DisplayDouble("Fog Start: ", lGlobalLightSettings.GetFogStart()) | |
DisplayDouble("Fog End: ", lGlobalLightSettings.GetFogEnd()) | |
DisplayBool("Shadow Enabled: ", lGlobalLightSettings.GetShadowEnable()) | |
DisplayDouble("Fog Density: ", lGlobalLightSettings.GetShadowIntensity()) | |
DisplayInt("Shadow Planes Count: ", lGlobalLightSettings.GetShadowPlaneCount()) | |
DisplayString("") | |
def DisplayGlobalCameraSettings(pScene): | |
lGlobalSettings = pScene.GetGlobalSettings() | |
DisplayString(" ImportScene_00100.py 0095 line globalTimeSettings.py DisplayGlobalCameraSettings () Default Camera: ", lGlobalSettings.GetDefaultCamera().Buffer()) | |
DisplayString("") | |
def DisplayGlobalTimeSettings(pGlobalSettings): | |
DebugLog("100 line DisplayGlobalTimeSettings() pGlobalSettings= "+ str(pGlobalSettings) ) | |
lTimeModes = [ "Default Mode", "Cinema", "PAL", "Frames 30", | |
"NTSC Drop Frame", "Frames 50", "Frames 60", | |
"Frames 100", "Frames 120", "NTSC Full Frame", | |
"Frames 30 Drop", "Frames 1000" ] | |
pGlobalSettings_GetTimeMode =pGlobalSettings.GetTimeMode() | |
DebugLog("105 line pGlobalSettings.GetTimeMode() = "+ str( pGlobalSettings_GetTimeMode ) ) | |
lTimeModes_Arr_pGlobalSettings_GetTimeMode =lTimeModes[ pGlobalSettings_GetTimeMode ] | |
DebugLog("105 line lTimeModes_Arr_pGlobalSettings_GetTimeMode = "+ str( lTimeModes_Arr_pGlobalSettings_GetTimeMode ) ) | |
DisplayString(" ImportScene_00100.py 0105line globalTimeSettings.py DisplayGlobalTimeSettings () Time Mode: ", lTimeModes[pGlobalSettings.GetTimeMode()]) | |
lTs = pGlobalSettings.GetTimelineDefaultTimeSpan() | |
lStart = lTs.GetStart() | |
lEnd = lTs.GetStop() | |
DisplayString("Timeline default timespan: ") | |
lTmpStr="" | |
DisplayString(" Start: ", lStart.GetTimeString(lTmpStr, 10)) | |
DisplayString(" Stop : ", lEnd.GetTimeString(lTmpStr, 10)) | |
DisplayString("") | |
#==================================================== | |
#================== DisplayGlobalLightSettings.py ===================END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayHierarchy.py ===================STA | |
#==================================================== | |
#==================================================== | |
def DisplayHierarchy(pScene): | |
lRootNode = pScene.GetRootNode() | |
for i in range(lRootNode.GetChildCount()): | |
DisplayNodeHierarchy(lRootNode.GetChild(i), 0) | |
def DisplayNodeHierarchy(pNode, pDepth): | |
lString = "" | |
for i in range(pDepth): | |
lString += " " | |
lString += pNode.GetName() | |
print(lString) | |
for i in range(pNode.GetChildCount()): | |
DisplayNodeHierarchy(pNode.GetChild(i), pDepth + 1) | |
#==================================================== | |
#====================DisplayHierarchy .py =================== END | |
#================================================================ | |
#==================================================== | |
#==================================================== | |
#==================== DisplayMarker.py ============== STA | |
#==================================================== | |
#from DisplayCommon import * | |
from fbx import FbxMarker | |
from fbx import FbxColor | |
def DisplayMarker(pNode): | |
lMarker = pNode.GetNodeAttribute() | |
DisplayString("Marker Name: ", pNode.GetName()) | |
# Type | |
lString = " Marker Type: " | |
if lMarker.GetType() == FbxMarker.eStandard: | |
lString += "Standard" | |
elif lMarker.GetType() == FbxMarker.eOptical: | |
lString += "Optical" | |
elif lMarker.GetType() == FbxMarker.eEffectorIK: | |
lString += "IK Effector" | |
elif lMarker.GetType() == FbxMarker.eEffectorFK: | |
lString += "FK Effector" | |
DisplayString(lString) | |
# Look | |
lString = " Marker Look: " | |
if lMarker.Look.Get() == FbxMarker.eCube: | |
lString += "Cube" | |
elif lMarker.Look.Get() == FbxMarker.eHardCross: | |
lString += "Hard Cross" | |
elif lMarker.Look.Get() == FbxMarker.eLightCross: | |
lString += "Light Cross" | |
elif lMarker.Look.Get() == FbxMarker.eSphere: | |
lString += "Sphere" | |
DisplayString(lString) | |
# Size | |
#lString = " Size: " | |
#lString += str(lMarker.Size.Get()) | |
DisplayDouble(" Size: ", lMarker.Size.Get()) | |
# Color | |
c = lMarker.Color.Get() | |
color = FbxColor(c[0], c[1], c[2]) | |
DisplayColor(" Color: ", color) | |
# IKPivot | |
Display3DVector(" IKPivot: ", lMarker.IKPivot.Get()) | |
#==================================================== | |
#==================== DisplayMarker.py ============== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#===================================== | |
#==================================================== | |
#==================== DisplayMesh.py =========================STA | |
#==================================================== | |
#from DisplayCommon import * | |
from fbx import FbxLayerElement | |
from fbx import FbxSurfaceMaterial | |
from fbx import FbxLayeredTexture | |
from fbx import FbxTexture | |
from fbx import FbxCriteria | |
#from DisplayMaterial import DisplayMaterial | |
#from DisplayTexture import DisplayTexture | |
#from DisplayLink import DisplayLink | |
#from DisplayShape import DisplayShape | |
def DisplayMesh(pNode): | |
lMesh = pNode.GetNodeAttribute () | |
DisplayString("Mesh Name: ", pNode.GetName()) | |
DisplayControlsPoints(lMesh) | |
DisplayPolygons(lMesh) | |
DisplayMaterialMapping(lMesh) | |
DisplayMaterial(lMesh) | |
DisplayTexture(lMesh) | |
DisplayMaterialConnections(lMesh) | |
DisplayLink(lMesh) | |
DisplayShape(lMesh) | |
def DisplayControlsPoints(pMesh): | |
lControlPointsCount = pMesh.GetControlPointsCount() | |
lControlPoints = pMesh.GetControlPoints() | |
DisplayString(" Control Points") | |
for i in range(lControlPointsCount): | |
DisplayInt(" Control Point ", i) | |
Display3DVector(" Coordinates: ", lControlPoints[i]) | |
for j in range(pMesh.GetLayerCount()): | |
leNormals = pMesh.GetLayer(j).GetNormals() | |
if leNormals: | |
if leNormals.GetMappingMode() == FbxLayerElement.eByControlPoint: | |
header = " Normal Vector (on layer %d): " % j | |
if leNormals.GetReferenceMode() == FbxLayerElement.eDirect: | |
Display3DVector(header, leNormals.GetDirectArray().GetAt(i)) | |
DisplayString("") | |
def DisplayPolygons(pMesh): | |
lPolygonCount = pMesh.GetPolygonCount() | |
lControlPoints = pMesh.GetControlPoints() | |
DisplayString(" Polygons") | |
vertexId = 0 | |
for i in range(lPolygonCount): | |
DisplayInt(" Polygon ", i) | |
for l in range(pMesh.GetLayerCount()): | |
lePolgrp = pMesh.GetLayer(l).GetPolygonGroups() | |
if lePolgrp: | |
if lePolgrp.GetMappingMode() == FbxLayerElement.eByPolygon: | |
if lePolgrp.GetReferenceMode() == FbxLayerElement.eIndex: | |
header = " Assigned to group (on layer %d): " % l | |
polyGroupId = lePolgrp.GetIndexArray().GetAt(i) | |
DisplayInt(header, polyGroupId) | |
else: | |
# any other mapping modes don't make sense | |
DisplayString(" \"unsupported group assignment\"") | |
lPolygonSize = pMesh.GetPolygonSize(i) | |
for j in range(lPolygonSize): | |
lControlPointIndex = pMesh.GetPolygonVertex(i, j) | |
Display3DVector(" Coordinates: ", lControlPoints[lControlPointIndex]) | |
for l in range(pMesh.GetLayerCount()): | |
leVtxc = pMesh.GetLayer(l).GetVertexColors() | |
if leVtxc: | |
header = " Color vertex (on layer %d): " % l | |
if leVtxc.GetMappingMode() == FbxLayerElement.eByControlPoint: | |
if leVtxc.GetReferenceMode() == FbxLayerElement.eDirect: | |
DisplayColor(header, leVtxc.GetDirectArray().GetAt(lControlPointIndex)) | |
elif leVtxc.GetReferenceMode() == FbxLayerElement.eIndexToDirect: | |
id = leVtxc.GetIndexArray().GetAt(lControlPointIndex) | |
DisplayColor(header, leVtxc.GetDirectArray().GetAt(id)) | |
elif leVtxc.GetMappingMode() == FbxLayerElement.eByPolygonVertex: | |
if leVtxc.GetReferenceMode() == FbxLayerElement.eDirect: | |
DisplayColor(header, leVtxc.GetDirectArray().GetAt(vertexId)) | |
elif leVtxc.GetReferenceMode() == FbxLayerElement.eIndexToDirect: | |
id = leVtxc.GetIndexArray().GetAt(vertexId) | |
DisplayColor(header, leVtxc.GetDirectArray().GetAt(id)) | |
elif leVtxc.GetMappingMode() == FbxLayerElement.eByPolygon or \ | |
leVtxc.GetMappingMode() == FbxLayerElement.eAllSame or \ | |
leVtxc.GetMappingMode() == FbxLayerElement.eNone: | |
# doesn't make much sense for UVs | |
pass | |
leUV = pMesh.GetLayer(l).GetUVs() | |
if leUV: | |
header = " Texture UV (on layer %d): " % l | |
if leUV.GetMappingMode() == FbxLayerElement.eByControlPoint: | |
if leUV.GetReferenceMode() == FbxLayerElement.eDirect: | |
Display2DVector(header, leUV.GetDirectArray().GetAt(lControlPointIndex)) | |
elif leUV.GetReferenceMode() == FbxLayerElement.eIndexToDirect: | |
id = leUV.GetIndexArray().GetAt(lControlPointIndex) | |
Display2DVector(header, leUV.GetDirectArray().GetAt(id)) | |
elif leUV.GetMappingMode() == FbxLayerElement.eByPolygonVertex: | |
lTextureUVIndex = pMesh.GetTextureUVIndex(i, j) | |
if leUV.GetReferenceMode() == FbxLayerElement.eDirect or \ | |
leUV.GetReferenceMode() == FbxLayerElement.eIndexToDirect: | |
Display2DVector(header, leUV.GetDirectArray().GetAt(lTextureUVIndex)) | |
elif leUV.GetMappingMode() == FbxLayerElement.eByPolygon or \ | |
leUV.GetMappingMode() == FbxLayerElement.eAllSame or \ | |
leUV.GetMappingMode() == FbxLayerElement.eNone: | |
# doesn't make much sense for UVs | |
pass | |
# # end for layer | |
vertexId += 1 | |
# # end for polygonSize | |
# # end for polygonCount | |
# check visibility for the edges of the mesh | |
for l in range(pMesh.GetLayerCount()): | |
leVisibility=pMesh.GetLayer(0).GetVisibility() | |
if leVisibility: | |
header = " Edge Visibilty (on layer %d): " % l | |
DisplayString(header) | |
# should be eByEdge | |
if leVisibility.GetMappingMode() == FbxLayerElement.eByEdge: | |
# should be eDirect | |
for j in range(pMesh.GetMeshEdgeCount()): | |
DisplayInt(" Edge ", j) | |
DisplayBool(" Edge visibilty: ", leVisibility.GetDirectArray().GetAt(j)) | |
DisplayString("") | |
def DisplayTextureNames(pProperty): | |
lTextureName = "" | |
lLayeredTextureCount = pProperty.GetSrcObjectCount(FbxCriteria.ObjectType(FbxLayeredTexture.ClassId)) | |
if lLayeredTextureCount > 0: | |
for j in range(lLayeredTextureCount): | |
lLayeredTexture = pProperty.GetSrcObject(FbxCriteria.ObjectType(FbxLayeredTexture.ClassId), j) | |
lNbTextures = lLayeredTexture.GetSrcObjectCount(FbxCriteria.ObjectType(FbxTexture.ClassId)) | |
lTextureName = " Texture " | |
for k in range(lNbTextures): | |
lTextureName += "\"" | |
lTextureName += lLayeredTexture.GetName() | |
lTextureName += "\"" | |
lTextureName += " " | |
lTextureName += "of " | |
lTextureName += pProperty.GetName().Buffer() | |
lTextureName += " on layer " | |
lTextureName += j | |
lTextureName += " |" | |
else: | |
#no layered texture simply get on the property | |
lNbTextures = pProperty.GetSrcObjectCount(FbxCriteria.ObjectType(FbxTexture.ClassId)) | |
if lNbTextures > 0: | |
lTextureName = " Texture " | |
lTextureName += " " | |
for j in range(lNbTextures): | |
lTexture = pProperty.GetSrcObject(FbxCriteria.ObjectType(FbxTexture.ClassId),j) | |
if lTexture: | |
lTextureName += "\"" | |
lTextureName += lTexture.GetName() | |
lTextureName += "\"" | |
lTextureName += " " | |
lTextureName += "of " | |
lTextureName += pProperty.GetName().Buffer() | |
lTextureName += " |" | |
return lTextureName | |
def DisplayMaterialTextureConnections(pMaterial, pMatId, l ): | |
lConnectionString = " Material " + str(pMatId) + " (on layer " + str(l) +") -- " | |
#Show all the textures | |
#Diffuse Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sDiffuse) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#DiffuseFactor Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sDiffuseFactor) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#Emissive Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sEmissive) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#EmissiveFactor Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sEmissiveFactor) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#Ambient Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sAmbient) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#AmbientFactor Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sAmbientFactor) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#Specular Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sSpecular) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#SpecularFactor Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sSpecularFactor) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#Shininess Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sShininess) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#Bump Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sBump) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#Normal Map Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sNormalMap) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#Transparent Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sTransparentColor) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#TransparencyFactor Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sTransparencyFactor) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#Reflection Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sReflection) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#ReflectionFactor Textures | |
lProperty = pMaterial.FindProperty(FbxSurfaceMaterial.sReflectionFactor) | |
lConnectionString += DisplayTextureNames(lProperty) | |
#if(lMaterial != NULL) | |
DisplayString(lConnectionString) | |
def DisplayMaterialConnections(pMesh): | |
lPolygonCount = pMesh.GetPolygonCount() | |
DisplayString(" Polygons Material Connections") | |
#check whether the material maps with only one mesh | |
lIsAllSame = True | |
for l in range(pMesh.GetLayerCount()): | |
lLayerMaterial = pMesh.GetLayer(l).GetMaterials() | |
if lLayerMaterial: | |
if lLayerMaterial.GetMappingMode() == FbxLayerElement.eByPolygon: | |
lIsAllSame = False | |
break | |
#For eAllSame mapping type, just out the material and texture mapping info once | |
if lIsAllSame: | |
for l in range(pMesh.GetLayerCount()): | |
lLayerMaterial = pMesh.GetLayer(l).GetMaterials() | |
if lLayerMaterial: | |
if lLayerMaterial.GetMappingMode() == FbxLayerElement.eAllSame: | |
lMaterial = pMesh.GetNode().GetMaterial(lLayerMaterial.GetIndexArray().GetAt(0)) | |
lMatId = lLayerMaterial.GetIndexArray().GetAt(0) | |
if lMatId >=0: | |
DisplayInt(" All polygons share the same material on layer ", l) | |
DisplayMaterialTextureConnections(lMaterial, lMatId, l) | |
else: | |
#layer 0 has no material | |
if l == 0: | |
DisplayString(" no material applied") | |
#For eByPolygon mapping type, just out the material and texture mapping info once | |
else: | |
for i in range(lPolygonCount): | |
DisplayInt(" Polygon ", i) | |
for l in range(pMesh.GetLayerCount()): | |
lLayerMaterial = pMesh.GetLayer(l).GetMaterials() | |
if lLayerMaterial: | |
lMatId = -1 | |
lMaterial = pMesh.GetNode().GetMaterial(lLayerMaterial.GetIndexArray().GetAt(i)) | |
lMatId = lLayerMaterial.GetIndexArray().GetAt(i) | |
if lMatId >= 0: | |
DisplayMaterialTextureConnections(lMaterial, lMatId, l) | |
def DisplayMaterialMapping(pMesh): | |
lMappingTypes = [ "None", "By Control Point", "By Polygon Vertex", "By Polygon", "By Edge", "All Same" ] | |
lReferenceMode = [ "Direct", "Index", "Index to Direct"] | |
lMtrlCount = 0 | |
lNode = None | |
if pMesh: | |
lNode = pMesh.GetNode() | |
if lNode: | |
lMtrlCount = lNode.GetMaterialCount() | |
for l in range(pMesh.GetLayerCount()): | |
leMat = pMesh.GetLayer(l).GetMaterials() | |
if leMat: | |
header = " Material layer %d: " % l | |
DisplayString(header) | |
DisplayString(" Mapping: ", lMappingTypes[leMat.GetMappingMode()]) | |
DisplayString(" ReferenceMode: ", lReferenceMode[leMat.GetReferenceMode()]) | |
lMaterialCount = 0 | |
if leMat.GetReferenceMode() == FbxLayerElement.eDirect or \ | |
leMat.GetReferenceMode() == FbxLayerElement.eIndexToDirect: | |
lMaterialCount = lMtrlCount | |
if leMat.GetReferenceMode() == FbxLayerElement.eIndex or \ | |
leMat.GetReferenceMode() == FbxLayerElement.eIndexToDirect: | |
lString = " Indices: " | |
lIndexArrayCount = leMat.GetIndexArray().GetCount() | |
for i in range(lIndexArrayCount): | |
lString += str(leMat.GetIndexArray().GetAt(i)) | |
if i < lIndexArrayCount - 1: | |
lString += ", " | |
DisplayString(lString) | |
DisplayString("") | |
#===================================== | |
#==================================================== | |
#==================== DisplayMesh.py ========================= END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayMaterial.py =================== | |
#==================================================== | |
#==================================================== | |
def DisplayMaterial(pGeometry): | |
lMaterialCount = 0 | |
lNode = None | |
if pGeometry: | |
lNode = pGeometry.GetNode() | |
if lNode: | |
lMaterialCount = lNode.GetMaterialCount() | |
for l in range(pGeometry.GetLayerCount()): | |
leMat = pGeometry.GetLayer(l).GetMaterials() | |
if leMat: | |
if leMat.GetReferenceMode() == FbxLayerElement.eIndex: | |
#Materials are in an undefined external table | |
continue | |
if lMaterialCount > 0: | |
theColor = FbxColor() | |
header = " Materials on layer %d: " % l | |
DisplayString(header) | |
for lCount in range(lMaterialCount): | |
DisplayInt(" Material ", lCount) | |
lMaterial = lNode.GetMaterial(lCount) | |
DisplayString(" Name: \"", lMaterial.GetName(), "\"") | |
#Get the implementation to see if it's a hardware shader. | |
lImplementation = GetImplementation(lMaterial, "ImplementationHLSL") | |
lImplemenationType = "HLSL" | |
if not lImplementation: | |
lImplementation = GetImplementation(lMaterial, "ImplementationCGFX") | |
lImplemenationType = "CGFX" | |
if lImplementation: | |
#Now we have a hardware shader, let's read it | |
print(" Hardware Shader Type: %s\n" % lImplemenationType.Buffer()) | |
lRootTable = lImplementation.GetRootTable() | |
lFileName = lRootTable.DescAbsoluteURL.Get() | |
lTechniqueName = lRootTable.DescTAG.Get() | |
lTable = lImplementation.GetRootTable() | |
lEntryNum = lTable.GetEntryCount() | |
for i in range(lEntryNum): | |
lEntry = lTable.GetEntry(i) | |
lEntry.GetEntryType(True) | |
lTest = lEntry.GetSource() | |
print(" Entry: %s\n" % lTest.Buffer()) | |
if cmp( FbxPropertyEntryView.sEntryType, lEntrySrcType ) == 0: | |
lFbxProp = lMaterial.FindPropertyHierarchical(lEntry.GetSource()) | |
if not lFbxProp.IsValid(): | |
lFbxProp = lMaterial.RootProperty.FindHierarchical(lEntry.GetSource()) | |
elif cmp( FbxConstantEntryView.sEntryType, lEntrySrcType ) == 0: | |
lFbxProp = lImplementation.GetConstants().FindHierarchical(lEntry.GetSource()) | |
if lFbxProp.IsValid(): | |
if lFbxProp.GetSrcObjectCount( FbxCriteria.ObjectType(FbxTexture.ClassId) ) > 0: | |
#do what you want with the texture | |
for j in range(lFbxProp.GetSrcObjectCount(FbxCriteria.ObjectType(FbxTexture.ClassId))): | |
lTex = lFbxProp.GetSrcObject(FbxCriteria.ObjectType(FbxTexture.ClassId),j) | |
print(" Texture: %s\n" % lTex.GetFileName()) | |
else: | |
lFbxType = lFbxProp.GetPropertyDataType() | |
if (lFbxType == eFbxBool): | |
lFbxProp = FbxPropertyBool1(lFbxProp) | |
DisplayBool(" Bool: ", lFbxProp.Get()) | |
elif (lFbxType == eFbxInt): | |
lFbxProp = FbxPropertyInteger1(lFbxProp) | |
DisplayInt(" Int: ", lFbxProp.Get()) | |
elif (lFbxType == eFbxEnum): | |
lFbxProp = FbxPropertyEnum(lFbxProp) | |
DisplayInt(" Enum: ", lFbxProp.Get()) | |
elif (lFbxType == eFbxFloat): | |
lFbxProp = FbxPropertyFloat1(lFbxProp) | |
DisplayDouble(" Float: ", lFbxProp.Get()) | |
elif ( lFbxType == eFbxDouble): | |
lFbxProp = FbxPropertyDouble1(lFbxProp) | |
DisplayDouble(" Double: ", lFbxProp.Get()) | |
elif ( lFbxType == eFbxString ): | |
lFbxProp = FbxPropertyString(lFbxProp) | |
DisplayString(" String: ", lFbxProp.Get()) | |
elif ( lFbxType == eFbxDouble2): | |
lFbxProp = FbxPropertyDouble2(lFbxProp) | |
res, lDouble2= lFbxProp.Get() | |
lVect = [] | |
lVect[0] = lDouble2[0] | |
lVect[1] = lDouble2[1] | |
Display2DVector(" 2D vector: ", lVect) | |
elif ( lFbxType == eFbxDouble3): | |
lFbxProp = FbxPropertyDouble3(lFbxProp) | |
res, lDouble3 = lFbxProp.Get() | |
lVect = [] | |
lVect[0] = lDouble3[0] | |
lVect[1] = lDouble3[1] | |
lVect[2] = lDouble3[2] | |
Display3DVector(" 3D vector: ", lVect) | |
elif ( lFbxType == eFbxDouble4): | |
lFbxProp = FbxPropertyDouble4(lFbxProp) | |
res, lDouble4 = lFbxProp.Get() | |
lVect = [] | |
lVect[0] = lDouble4[0] | |
lVect[1] = lDouble4[1] | |
lVect[2] = lDouble4[2] | |
lVect[3] = lDouble4[3] | |
Display4DVector(" 4D vector: ", lVect) | |
elif ( lFbxType == eFbxDouble4x4): | |
lFbxProp = FbxPropertyXMatrix(lFbxProp) | |
res, lDouble44 = lFbxProp.Get(EFbxType.eFbxDouble44) | |
for j in range(4): | |
lVect = [] | |
lVect[0] = lDouble44[j][0] | |
lVect[1] = lDouble44[j][1] | |
lVect[2] = lDouble44[j][2] | |
lVect[3] = lDouble44[j][3] | |
Display4DVector(" 4x4D vector: ", lVect) | |
elif (lMaterial.GetClassId().Is(FbxSurfacePhong.ClassId)): | |
# We found a Phong material. Display its properties. | |
# Display the Ambient Color | |
lFbxDouble3 = lMaterial.Ambient | |
theColor.Set(lFbxDouble3.Get()[0], lFbxDouble3.Get()[1], lFbxDouble3.Get()[2]) | |
DisplayColor(" Ambient: ", theColor) | |
# Display the Diffuse Color | |
lFbxDouble3 = lMaterial.Diffuse | |
theColor.Set(lFbxDouble3.Get()[0], lFbxDouble3.Get()[1], lFbxDouble3.Get()[2]) | |
DisplayColor(" Diffuse: ", theColor) | |
# Display the Specular Color (unique to Phong materials) | |
lFbxDouble3 = lMaterial.Specular | |
theColor.Set(lFbxDouble3.Get()[0], lFbxDouble3.Get()[1], lFbxDouble3.Get()[2]) | |
DisplayColor(" Specular: ", theColor) | |
# Display the Emissive Color | |
lFbxDouble3 = lMaterial.Emissive | |
theColor.Set(lFbxDouble3.Get()[0], lFbxDouble3.Get()[1], lFbxDouble3.Get()[2]) | |
DisplayColor(" Emissive: ", theColor) | |
# Opacity is Transparency factor now | |
lFbxDouble1 = lMaterial.TransparencyFactor | |
DisplayDouble(" Opacity: ", 1.0-lFbxDouble1.Get()) | |
# Display the Shininess | |
lFbxDouble1 = lMaterial.Shininess | |
DisplayDouble(" Shininess: ", lFbxDouble1.Get()) | |
# Display the Reflectivity | |
lFbxDouble3 = lMaterial.Reflection | |
theColor.Set(lFbxDouble3.Get()[0], lFbxDouble3.Get()[1], lFbxDouble3.Get()[2]) | |
DisplayColor(" Reflectivity: ", theColor) | |
elif lMaterial.GetClassId().Is(FbxSurfaceLambert.ClassId): | |
# We found a Lambert material. Display its properties. | |
# Display the Ambient Color | |
lFbxDouble3 = lMaterial.Ambient | |
theColor.Set(lFbxDouble3.Get()[0], lFbxDouble3.Get()[1], lFbxDouble3.Get()[2]) | |
DisplayColor(" Ambient: ", theColor) | |
# Display the Diffuse Color | |
lFbxDouble3 = lMaterial.Diffuse | |
theColor.Set(lFbxDouble3.Get()[0], lFbxDouble3.Get()[1], lFbxDouble3.Get()[2]) | |
DisplayColor(" Diffuse: ", theColor) | |
# Display the Emissive | |
lFbxDouble3 = lMaterial.Emissive | |
theColor.Set(lFbxDouble3.Get()[0], lFbxDouble3.Get()[1], lFbxDouble3.Get()[2]) | |
DisplayColor(" Emissive: ", theColor) | |
# Display the Opacity | |
lFbxDouble1 = lMaterial.TransparencyFactor | |
DisplayDouble(" Opacity: ", 1.0-lFbxDouble1.Get()) | |
else: | |
DisplayString("Unknown type of Material") | |
lString = lMaterial.ShadingModel | |
DisplayString(" Shading Model: ", lString.Get().Buffer()) | |
DisplayString("") | |
#==================================================== | |
#==================================================== | |
#================== DisplayMaterial.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayTextureInfo.py =================== STA | |
#==================================================== | |
#==================================================== | |
from fbx import FbxSurfaceMaterial | |
from fbx import FbxLayerElement | |
from fbx import FbxLayeredTexture | |
from fbx import FbxTexture | |
from fbx import FbxCriteria | |
def DisplayTextureInfo(pTexture, pBlendMode): | |
DisplayString(" Name: \"", pTexture.GetName(), "\"") | |
DisplayString(" File Name: \"", pTexture.GetFileName(), "\"") | |
DisplayDouble(" Scale U: ", pTexture.GetScaleU()) | |
DisplayDouble(" Scale V: ", pTexture.GetScaleV()) | |
DisplayDouble(" Translation U: ", pTexture.GetTranslationU()) | |
DisplayDouble(" Translation V: ", pTexture.GetTranslationV()) | |
DisplayBool(" Swap UV: ", pTexture.GetSwapUV()) | |
DisplayDouble(" Rotation U: ", pTexture.GetRotationU()) | |
DisplayDouble(" Rotation V: ", pTexture.GetRotationV()) | |
DisplayDouble(" Rotation W: ", pTexture.GetRotationW()) | |
lAlphaSources = [ "None", "RGB Intensity", "Black" ] | |
DisplayString(" Alpha Source: ", lAlphaSources[pTexture.GetAlphaSource()]) | |
DisplayDouble(" Cropping Left: ", pTexture.GetCroppingLeft()) | |
DisplayDouble(" Cropping Top: ", pTexture.GetCroppingTop()) | |
DisplayDouble(" Cropping Right: ", pTexture.GetCroppingRight()) | |
DisplayDouble(" Cropping Bottom: ", pTexture.GetCroppingBottom()) | |
lMappingTypes = [ "Null", "Planar", "Spherical", "Cylindrical", "Box", "Face", "UV", "Environment"] | |
DisplayString(" Mapping Type: ", lMappingTypes[pTexture.GetMappingType()]) | |
if pTexture.GetMappingType() == FbxTexture.ePlanar: | |
lPlanarMappingNormals = ["X", "Y", "Z" ] | |
DisplayString(" Planar Mapping Normal: ", lPlanarMappingNormals[pTexture.GetPlanarMappingNormal()]) | |
lBlendModes = ["Translucent", "Add", "Modulate", "Modulate2"] | |
if pBlendMode >= 0: | |
DisplayString(" Blend Mode: ", lBlendModes[pBlendMode]) | |
DisplayDouble(" Alpha: ", pTexture.GetDefaultAlpha()) | |
lMaterialUses = ["Model Material", "Default Material"] | |
DisplayString(" Material Use: ", lMaterialUses[pTexture.GetMaterialUse()]) | |
pTextureUses = ["Standard", "Shadow Map", "Light Map", "Spherical Reflexion Map", "Sphere Reflexion Map"] | |
DisplayString(" Texture Use: ", pTextureUses[pTexture.GetTextureUse()]) | |
DisplayString("") | |
def FindAndDisplayTextureInfoByProperty(pProperty, pDisplayHeader, pMaterialIndex): | |
if pProperty.IsValid(): | |
#Here we have to check if it's layeredtextures, or just textures: | |
lLayeredTextureCount = pProperty.GetSrcObjectCount(FbxCriteria.ObjectType(FbxLayeredTexture.ClassId)) | |
if lLayeredTextureCount > 0: | |
for j in range(lLayeredTextureCount): | |
DisplayInt(" Layered Texture: ", j) | |
lLayeredTexture = pProperty.GetSrcObject(FbxCriteria.ObjectType(FbxLayeredTexture.ClassId), j) | |
lNbTextures = lLayeredTexture.GetSrcObjectCount(FbxCriteria.ObjectType(FbxTexture.ClassId)) | |
for k in range(lNbTextures): | |
lTexture = lLayeredTexture.GetSrcObject(FbxCriteria.ObjectType(FbxTexture.ClassId),k) | |
if lTexture: | |
if pDisplayHeader: | |
DisplayInt(" Textures connected to Material ", pMaterialIndex) | |
pDisplayHeader = False | |
# NOTE the blend mode is ALWAYS on the LayeredTexture and NOT the one on the texture. | |
# Why is that? because one texture can be shared on different layered textures and might | |
# have different blend modes. | |
lBlendMode = lLayeredTexture.GetTextureBlendMode(k) | |
DisplayString(" Textures for ", pProperty.GetName()) | |
DisplayInt(" Texture ", k) | |
DisplayTextureInfo(lTexture, lBlendMode) | |
else: | |
# no layered texture simply get on the property | |
lNbTextures = pProperty.GetSrcObjectCount(FbxCriteria.ObjectType(FbxTexture.ClassId)) | |
for j in range(lNbTextures): | |
lTexture = pProperty.GetSrcObject(FbxCriteria.ObjectType(FbxTexture.ClassId),j) | |
if lTexture: | |
# display connectMareial header only at the first time | |
if pDisplayHeader: | |
DisplayInt(" Textures connected to Material ", pMaterialIndex) | |
pDisplayHeader = False | |
DisplayString(" Textures for ", pProperty.GetName().Buffer()) | |
DisplayInt(" Texture ", j) | |
DisplayTextureInfo(lTexture, -1) | |
lNbTex = pProperty.GetSrcObjectCount(FbxCriteria.ObjectType(FbxTexture.ClassId)) | |
for lTextureIndex in range(lNbTex): | |
lTexture = pProperty.GetSrcObject(FbxCriteria.ObjectType(FbxTexture.ClassId), lTextureIndex) | |
def DisplayTexture(pGeometry): | |
lNbMat = pGeometry.GetNode().GetSrcObjectCount(FbxCriteria.ObjectType(FbxSurfaceMaterial.ClassId)) | |
for lMaterialIndex in range(lNbMat): | |
lMaterial = pGeometry.GetNode().GetSrcObject(FbxCriteria.ObjectType(FbxSurfaceMaterial.ClassId), lMaterialIndex) | |
lDisplayHeader = True | |
#go through all the possible textures | |
if lMaterial: | |
for lTextureIndex in range(FbxLayerElement.sTypeTextureCount()): | |
lProperty = lMaterial.FindProperty(FbxLayerElement.sTextureChannelNames(lTextureIndex)) | |
FindAndDisplayTextureInfoByProperty(lProperty, lDisplayHeader, lMaterialIndex) | |
#==================================================== | |
#==================================================== | |
#================== DisplayTextureInfo.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayLink.py =================== STA | |
#==================================================== | |
#==================================================== | |
#from DisplayCommon import * | |
from fbx import FbxDeformer | |
from fbx import FbxAMatrix | |
#from fbx import FbxLayeredTexture | |
#from fbx import FbxTexture | |
def DisplayLink(pGeometry): | |
#Display cluster now | |
lSkinCount=pGeometry.GetDeformerCount(FbxDeformer.eSkin) | |
#lLinkCount = pGeometry.GetLinkCount() | |
for i in range(lSkinCount): | |
lClusterCount = pGeometry.GetDeformer(i, FbxDeformer.eSkin).GetClusterCount() | |
for j in range(lClusterCount): | |
DisplayInt(" Cluster ", i) | |
lCluster = pGeometry.GetDeformer(i, FbxDeformer.eSkin).GetCluster(j) | |
#lLink = pGeometry.GetLink(i) | |
lClusterModes = [ "Normalize", "Additive", "Total1" ] | |
DisplayString(" Mode: ", lClusterModes[lCluster.GetLinkMode()]) | |
if lCluster.GetLink(): | |
DisplayString(" Name: ", lCluster.GetLink().GetName()) | |
lString1 = " Link Indices: " | |
lString2 = " Weight Values: " | |
lIndexCount = lCluster.GetControlPointIndicesCount() | |
lIndices = lCluster.GetControlPointIndices() | |
lWeights = lCluster.GetControlPointWeights() | |
for k in range(lIndexCount): | |
lString1 += str(lIndices[k]) | |
lString2 += str(lWeights[k]) | |
if k < lIndexCount - 1: | |
lString1 += ", " | |
lString2 += ", " | |
print(lString1) | |
print(lString2) | |
DisplayString("") | |
lMatrix = FbxAMatrix() | |
lMatrix = lCluster.GetTransformMatrix(lMatrix) | |
Display3DVector(" Transform Translation: ", lMatrix.GetT()) | |
Display3DVector(" Transform Rotation: ", lMatrix.GetR()) | |
Display3DVector(" Transform Scaling: ", lMatrix.GetS()) | |
lMatrix = lCluster.GetTransformLinkMatrix(lMatrix) | |
Display3DVector(" Transform Link Translation: ", lMatrix.GetT()) | |
Display3DVector(" Transform Link Rotation: ", lMatrix.GetR()) | |
Display3DVector(" Transform Link Scaling: ", lMatrix.GetS()) | |
if lCluster.GetAssociateModel(): | |
lMatrix = lCluster.GetTransformAssociateModelMatrix(lMatrix) | |
DisplayString(" Associate Model: ", lCluster.GetAssociateModel().GetName()) | |
Display3DVector(" Associate Model Translation: ", lMatrix.GetT()) | |
Display3DVector(" Associate Model Rotation: ", lMatrix.GetR()) | |
Display3DVector(" Associate Model Scaling: ", lMatrix.GetS()) | |
DisplayString("") | |
#==================================================== | |
#==================================================== | |
#================== DisplayLink.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayShape.py =================== STA | |
#==================================================== | |
#==================================================== | |
from fbx import FbxDeformer | |
#from DisplayCommon import * | |
def DisplayShape(pGeometry): | |
lBlendShapeCount = pGeometry.GetDeformerCount(FbxDeformer.eBlendShape) | |
for lBlendShapeIndex in range(lBlendShapeCount): | |
lBlendShape = pGeometry.GetDeformer(lBlendShapeIndex, FbxDeformer.eBlendShape) | |
DisplayString(" BlendShape ", lBlendShape.GetName()) | |
lBlendShapeChannelCount = lBlendShape.GetBlendShapeChannelCount() | |
for lBlendShapeChannelIndex in range(lBlendShapeChannelCount): | |
lBlendShapeChannel = lBlendShape.GetBlendShapeChannel(lBlendShapeChannelIndex) | |
DisplayString(" BlendShapeChannel ", lBlendShapeChannel.GetName()) | |
DisplayDouble(" Default Deform Value: ", lBlendShapeChannel.DeformPercent.Get()) | |
lTargetShapeCount = lBlendShapeChannel.GetTargetShapeCount() | |
for lTargetShapeIndex in range(lTargetShapeCount): | |
lShape = lBlendShapeChannel.GetTargetShape(lTargetShapeIndex) | |
DisplayString(" TargetShape ", lShape.GetName()) | |
lControlPointsCount = lShape.GetControlPointsCount() | |
lControlPoints = lShape.GetControlPoints() | |
lNormals = lShape.GetLayer(0).GetNormals().GetDirectArray() | |
for j in range(lControlPointsCount): | |
DisplayInt(" Control Point ", j) | |
Display3DVector(" Coordinates: ", lControlPoints[j]) | |
if lNormals.GetCount() == lControlPointsCount: | |
Display3DVector(" Normal Vector: ", lNormals.GetAt(j)) | |
DisplayString("") | |
#==================================================== | |
#==================================================== | |
#================== DisplayShape.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplaySkeleton.py ================== = STA | |
#==================================================== | |
#==================================================== | |
from fbx import FbxSkeleton | |
def DisplaySkeleton(pNode): | |
lSkeleton = pNode.GetNodeAttribute() | |
DisplayString("Skeleton Name: ", pNode.GetName()) | |
lSkeletonTypes = [ "Root", "Limb", "Limb Node", "Effector" ] | |
DisplayString(" Type: ", lSkeletonTypes[lSkeleton.GetSkeletonType()]) | |
if lSkeleton.GetSkeletonType() == FbxSkeleton.eLimb: | |
DisplayDouble(" Limb Length: ", lSkeleton.LimbLength.Get()) | |
elif lSkeleton.GetSkeletonType() == FbxSkeleton.eLimbNode: | |
DisplayDouble(" Limb Node Size: ", lSkeleton.Size.Get()) | |
elif lSkeleton.GetSkeletonType() == FbxSkeleton.eRoot: | |
DisplayDouble(" Limb Root Size: ", lSkeleton.Size.Get()) | |
DisplayColor(" Color: ", lSkeleton.GetLimbNodeColor()) | |
#==================================================== | |
#==================================================== | |
#================== DisplaySkeleton.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayUserProperties.py =================== STA | |
#==================================================== | |
#==================================================== | |
from fbx import FbxProperty | |
from fbx import FbxPropertyFlags | |
from fbx import FbxPropertyDouble1 | |
from fbx import FbxPropertyDouble3 | |
from fbx import FbxPropertyBool1 | |
from fbx import FbxPropertyInteger1 | |
from fbx import FbxPropertyString | |
from fbx import FbxPropertyFloat1 | |
from fbx import eFbxBool | |
from fbx import eFbxDouble | |
from fbx import eFbxDouble4 | |
from fbx import eFbxInt | |
from fbx import eFbxDouble3 | |
from fbx import eFbxFloat | |
from fbx import eFbxString | |
from fbx import eFbxEnum | |
#from fbx import DTColor3 | |
#from fbx import DTColor4 | |
def DisplayUserProperties(pObject): | |
lCount = 0 | |
lTitleStr = " Property Count: " | |
lProperty = pObject.GetFirstProperty() | |
while lProperty.IsValid(): | |
if lProperty.GetFlag(FbxPropertyFlags.eUserDefined): | |
lCount += 1 | |
lProperty = pObject.GetNextProperty(lProperty) | |
if lCount == 0: | |
return # there are no user properties to display | |
DisplayInt(lTitleStr, lCount) | |
lProperty = pObject.GetFirstProperty() | |
i = 0 | |
while lProperty.IsValid(): | |
if lProperty.GetFlag(FbxPropertyFlags.eUserDefined): | |
DisplayInt(" Property ", i) | |
lString = lProperty.GetLabel() | |
DisplayString(" Display Name: ", lString.Buffer()) | |
lString = lProperty.GetName() | |
DisplayString(" Internal Name: ", lString.Buffer()) | |
DisplayString(" Type: ", lProperty.GetPropertyDataType().GetName()) | |
if lProperty.HasMinLimit(): | |
DisplayDouble(" Min Limit: ", lProperty.GetMinLimit()) | |
if lProperty.HasMaxLimit(): | |
DisplayDouble(" Max Limit: ", lProperty.GetMaxLimit()) | |
DisplayBool (" Is Animatable: ", lProperty.GetFlag(FbxPropertyFlags.eAnimatable)) | |
lPropertyDataType=lProperty.GetPropertyDataType() | |
# BOOL | |
if lPropertyDataType.GetType() == eFbxBool: | |
lProperty = FbxPropertyBool1(lProperty) | |
val = lProperty.Get() | |
DisplayBool(" Default Value: ", val) | |
# REAL | |
elif lPropertyDataType.GetType() == eFbxDouble: | |
lProperty = FbxPropertyDouble1(lProperty) | |
val = lProperty.Get() | |
DisplayDouble(" Default Value: ", val) | |
elif lPropertyDataType.GetType() == eFbxFloat: | |
lProperty = FbxPropertyFloat1(lProperty) | |
val = lProperty.Get() | |
DisplayDouble(" Default Value: ",val) | |
# COLOR | |
#elif lPropertyDataType.Is(DTColor3) or lPropertyDataType.Is(DTColor4): | |
#val = lProperty.Get() | |
#lDefault=FbxGet <FbxColor> (lProperty) | |
#sprintf(lBuf, "R=%f, G=%f, B=%f, A=%f", lDefault.mRed, lDefault.mGreen, lDefault.mBlue, lDefault.mAlpha) | |
#DisplayString(" Default Value: ", lBuf) | |
# pass | |
# INTEGER | |
elif lPropertyDataType.GetType() == eFbxInt: | |
lProperty = FbxPropertyInteger1(lProperty) | |
val = lProperty.Get() | |
DisplayInt(" Default Value: ", val) | |
# VECTOR | |
elif lPropertyDataType.GetType() == eFbxDouble3: | |
lProperty = FbxPropertyDouble3(lProperty) | |
val = lProperty.Get() | |
lBuf = "X=%f, Y=%f, Z=%f", (val[0], val[1], val[2]) | |
DisplayString(" Default Value: ", lBuf) | |
elif lPropertyDataType.GetType() == eFbxDouble4: | |
lProperty = FbxPropertyDouble4(lProperty) | |
val = lProperty.Get() | |
lBuf = "X=%f, Y=%f, Z=%f, W=%f", (val[0], val[1], val[2], val[3]) | |
DisplayString(" Default Value: ", lBuf) | |
# # LIST | |
# elif lPropertyDataType.GetType() == eFbxEnum: | |
# val = lProperty.Get() | |
# DisplayInt(" Default Value: ", val) | |
# UNIDENTIFIED | |
else: | |
DisplayString(" Default Value: UNIDENTIFIED") | |
i += 1 | |
lProperty = pObject.GetNextProperty(lProperty) | |
#==================================================== | |
#==================================================== | |
#================== DisplayUserProperties.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayPivotsAndLimits.py =================== STA | |
#==================================================== | |
#==================================================== | |
from fbx import FbxNode | |
def DisplayPivotsAndLimits(pNode): | |
# Pivots | |
print(" Pivot Information") | |
lPivotState = pNode.GetPivotState(FbxNode.eSourcePivot) | |
if lPivotState == FbxNode.ePivotActive: | |
print(" Pivot State: Active") | |
else: | |
print(" Pivot State: Reference") | |
lTmpVector = pNode.GetPreRotation(FbxNode.eSourcePivot) | |
print(" Pre-Rotation: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2])) | |
lTmpVector = pNode.GetPostRotation(FbxNode.eSourcePivot) | |
print(" Post-Rotation: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2])) | |
lTmpVector = pNode.GetRotationPivot(FbxNode.eSourcePivot) | |
print(" Rotation Pivot: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2])) | |
lTmpVector = pNode.GetRotationOffset(FbxNode.eSourcePivot) | |
print(" Rotation Offset: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2])) | |
lTmpVector = pNode.GetScalingPivot(FbxNode.eSourcePivot) | |
print(" Scaling Pivot: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2])) | |
lTmpVector = pNode.GetScalingOffset(FbxNode.eSourcePivot) | |
print(" Scaling Offset: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2])) | |
print(" Limits Information") | |
lIsActive = pNode.TranslationActive | |
lMinXActive = pNode.TranslationMinX | |
lMinYActive = pNode.TranslationMinY | |
lMinZActive = pNode.TranslationMinZ | |
lMaxXActive = pNode.TranslationMaxX | |
lMaxYActive = pNode.TranslationMaxY | |
lMaxZActive = pNode.TranslationMaxZ | |
lMinValues = pNode.TranslationMin | |
lMaxValues = pNode.TranslationMax | |
if lIsActive: | |
print(" Translation limits: Active") | |
else: | |
print(" Translation limits: Inactive") | |
print(" X") | |
if lMinXActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f" % lMinValues.Get()[0]) | |
if lMaxXActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[0]) | |
print(" Y") | |
if lMinYActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f" % lMinValues.Get()[1]) | |
if lMaxYActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[1]) | |
print(" Z") | |
if lMinZActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f"% lMinValues.Get()[2]) | |
if lMaxZActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[2]) | |
lIsActive = pNode.RotationActive | |
lMinXActive = pNode.RotationMinX | |
lMinYActive = pNode.RotationMinY | |
lMinZActive = pNode.RotationMinZ | |
lMaxXActive = pNode.RotationMaxX | |
lMaxYActive = pNode.RotationMaxY | |
lMaxZActive = pNode.RotationMaxZ | |
lMinValues = pNode.RotationMin | |
lMaxValues = pNode.RotationMax | |
if lIsActive: | |
print(" Rotation limits: Active") | |
else: | |
print(" Rotation limits: Inactive") | |
print(" X") | |
if lMinXActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f" % lMinValues.Get()[0]) | |
if lMaxXActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[0]) | |
print(" Y") | |
if lMinYActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f" % lMinValues.Get()[1]) | |
if lMaxYActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[1]) | |
print(" Z") | |
if lMinZActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f"% lMinValues.Get()[2]) | |
if lMaxZActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[2]) | |
lIsActive = pNode.ScalingActive | |
lMinXActive = pNode.ScalingMinX | |
lMinYActive = pNode.ScalingMinY | |
lMinZActive = pNode.ScalingMinZ | |
lMaxXActive = pNode.ScalingMaxX | |
lMaxYActive = pNode.ScalingMaxY | |
lMaxZActive = pNode.ScalingMaxZ | |
lMinValues = pNode.ScalingMin | |
lMaxValues = pNode.ScalingMax | |
if lIsActive: | |
print(" Scaling limits: Active") | |
else: | |
print(" Scaling limits: Inactive") | |
print(" X") | |
if lMinXActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f" % lMinValues.Get()[0]) | |
if lMaxXActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[0]) | |
print(" Y") | |
if lMinYActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f" % lMinValues.Get()[1]) | |
if lMaxYActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[1]) | |
print(" Z") | |
if lMinZActive: | |
print(" Min Limit: Active") | |
else: | |
print(" Min Limit: Inactive") | |
print(" Min Limit Value: %f"% lMinValues.Get()[2]) | |
if lMaxZActive: | |
print(" Max Limit: Active") | |
else: | |
print(" Max Limit: Inactive") | |
print(" Max Limit Value: %f" % lMaxValues.Get()[2]) | |
#==================================================== | |
#==================================================== | |
#================== DisplayPivotsAndLimits.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayPose.py =================== STA | |
#==================================================== | |
#==================================================== | |
#from fbx import FbxCamera | |
def DisplayPose(pScene): | |
lPoseCount = pScene.GetPoseCount() | |
for i in range(lPoseCount): | |
lPose = pScene.GetPose(i) | |
lName = lPose.GetName() | |
DisplayString("Pose Name: ", lName) | |
DisplayBool(" Is a bind pose: ", lPose.IsBindPose()) | |
DisplayInt(" Number of items in the pose: ", lPose.GetCount()) | |
DisplayString("","") | |
for j in range(lPose.GetCount()): | |
lName = lPose.GetNodeName(j).GetCurrentName() | |
DisplayString(" Item name: ", lName) | |
if not lPose.IsBindPose(): | |
# Rest pose can have local matrix | |
DisplayBool(" Is local space matrix: ", lPose.IsLocalMatrix(j)) | |
DisplayString(" Matrix value: ","") | |
lMatrixValue = "" | |
for k in range(4): | |
lMatrix = lPose.GetMatrix(j) | |
lRow = lMatrix.GetRow(k) | |
lRowValue = "%9.4f %9.4f %9.4f %9.4f\n" % (lRow[0], lRow[1], lRow[2], lRow[3]) | |
lMatrixValue += " " + lRowValue | |
DisplayString("", lMatrixValue) | |
lPoseCount = pScene.GetCharacterPoseCount() | |
for i in range(lPoseCount): | |
lPose = pScene.GetCharacterPose(i) | |
lCharacter = lPose.GetCharacter() | |
if not lCharacter: | |
break | |
DisplayString("Character Pose Name: ", lCharacter.mName.Buffer()) | |
lNodeId = eCharacterHips | |
while lCharacter.GetCharacterLink(lNodeId, lCharacterLink): | |
lAnimStack = None | |
if lAnimStack == None: | |
lScene = lCharacterLink.mNode.GetScene() | |
if lScene: | |
lAnimStack = lScene.GetMember(FBX_TYPE(FbxAnimStack), 0) | |
lGlobalPosition = lCharacterLink.mNode.GetGlobalFromAnim(KTIME_ZERO, lAnimStack) | |
DisplayString(" Matrix value: ","") | |
lMatrixValue = "" | |
for k in range(4): | |
lRow = lGlobalPosition.GetRow(k) | |
lRowValue = "%9.4f %9.4f %9.4f %9.4f\n" % (lRow[0], lRow[1], lRow[2], lRow[3]) | |
lMatrixValue += " " + lRowValue | |
DisplayString("", lMatrixValue) | |
lNodeId = ECharacterNodeId(int(lNodeId) + 1) | |
#==================================================== | |
#==================================================== | |
#================== DisplayPose.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayAnimation.py =================== STA | |
#==================================================== | |
#==================================================== | |
def DisplayAnimation(pScene): | |
for i in range(pScene.GetSrcObjectCount(FbxCriteria.ObjectType(FbxAnimStack.ClassId))): | |
lAnimStack = pScene.GetSrcObject(FbxCriteria.ObjectType(FbxAnimStack.ClassId), i) | |
lOutputString = "Animation Stack Name: " | |
lOutputString += lAnimStack.GetName() | |
lOutputString += "\n" | |
print(lOutputString) | |
DebugLog("DisplayAnimation () 00100 lOutputString==" +str(lOutputString) ) | |
DisplayAnimationStack(lAnimStack, pScene.GetRootNode(), True) | |
DisplayAnimationStack(lAnimStack, pScene.GetRootNode(), False) | |
def DisplayAnimationStack(pAnimStack, pNode, isSwitcher): | |
nbAnimLayers = pAnimStack.GetSrcObjectCount(FbxCriteria.ObjectType(FbxAnimLayer.ClassId)) | |
lOutputString = "Animation stack contains " | |
lOutputString += str(nbAnimLayers) | |
lOutputString += " Animation Layer(s)" | |
print(lOutputString) | |
DebugLog("DisplayAnimation () def DisplayAnimationStack() 00200 lOutputString==" +str(lOutputString) ) | |
for l in range(nbAnimLayers): | |
lAnimLayer = pAnimStack.GetSrcObject(FbxCriteria.ObjectType(FbxAnimLayer.ClassId), l) | |
lOutputString = "AnimLayer " | |
lOutputString += str(l) | |
print(lOutputString) | |
DisplayAnimationLayer(lAnimLayer, pNode, isSwitcher) | |
def DisplayAnimationLayer(pAnimLayer, pNode, isSwitcher=False): | |
lOutputString = " Node Name: " | |
lOutputString += pNode.GetName() | |
lOutputString += "\n" | |
print(lOutputString) | |
DebugLog("DisplayAnimation () def DisplayAnimationLayer() 00300 lOutputString==" +str(lOutputString) ) | |
DisplayChannels(pNode, pAnimLayer, DisplayCurveKeys, DisplayListCurveKeys, isSwitcher) | |
for lModelCount in range(pNode.GetChildCount()): | |
DisplayAnimationLayer(pAnimLayer, pNode.GetChild(lModelCount), isSwitcher) | |
def DisplayChannels(pNode, pAnimLayer, DisplayCurve, DisplayListCurve, isSwitcher): | |
lAnimCurve = None | |
KFCURVENODE_T_X = "X" | |
KFCURVENODE_T_Y = "Y" | |
KFCURVENODE_T_Z = "Z" | |
KFCURVENODE_R_X = "X" | |
KFCURVENODE_R_Y = "Y" | |
KFCURVENODE_R_Z = "Z" | |
KFCURVENODE_R_W = "W" | |
KFCURVENODE_S_X = "X" | |
KFCURVENODE_S_Y = "Y" | |
KFCURVENODE_S_Z = "Z" | |
# Display general curves. | |
if not isSwitcher: | |
lAnimCurve = pNode.LclTranslation.GetCurve(pAnimLayer, KFCURVENODE_T_X) | |
if lAnimCurve: | |
print(" TX") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 T r a n s f o r m X lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = pNode.LclTranslation.GetCurve(pAnimLayer, KFCURVENODE_T_Y) | |
if lAnimCurve: | |
print(" TY") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 T r a n s f o r m Y lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = pNode.LclTranslation.GetCurve(pAnimLayer, KFCURVENODE_T_Z) | |
if lAnimCurve: | |
print(" TZ") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 T r a n s f o r m Z lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = pNode.LclRotation.GetCurve(pAnimLayer, KFCURVENODE_R_X) | |
if lAnimCurve: | |
print(" RX") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 R o t a t i o n X lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = pNode.LclRotation.GetCurve(pAnimLayer, KFCURVENODE_R_Y) | |
if lAnimCurve: | |
print(" RY") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 R o t a t i o n Y lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = pNode.LclRotation.GetCurve(pAnimLayer, KFCURVENODE_R_Z) | |
if lAnimCurve: | |
print(" RZ") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 R o t a t i o n Z lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = pNode.LclScaling.GetCurve(pAnimLayer, KFCURVENODE_S_X) | |
if lAnimCurve: | |
print(" SX") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 S c a l e X lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = pNode.LclScaling.GetCurve(pAnimLayer, KFCURVENODE_S_Y) | |
if lAnimCurve: | |
print(" SY") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 S c a l e Y lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = pNode.LclScaling.GetCurve(pAnimLayer, KFCURVENODE_S_Z) | |
if lAnimCurve: | |
print(" SZ") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00400 S c a l e Z lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
# Display curves specific to a light or marker. | |
lNodeAttribute = pNode.GetNodeAttribute() | |
KFCURVENODE_COLOR_RED = "X" | |
KFCURVENODE_COLOR_GREEN = "Y" | |
KFCURVENODE_COLOR_BLUE = "Z" | |
if lNodeAttribute: | |
lAnimCurve = lNodeAttribute.Color.GetCurve(pAnimLayer, KFCURVENODE_COLOR_RED) | |
if lAnimCurve: | |
print(" Red") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Red lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = lNodeAttribute.Color.GetCurve(pAnimLayer, KFCURVENODE_COLOR_GREEN) | |
if lAnimCurve: | |
print(" Green") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Green lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = lNodeAttribute.Color.GetCurve(pAnimLayer, KFCURVENODE_COLOR_BLUE) | |
if lAnimCurve: | |
print(" Blue") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Blue lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
# Display curves specific to a light. | |
light = pNode.GetLight() | |
if light: | |
lAnimCurve = light.Intensity.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Intensity") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Intensity lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = light.OuterAngle.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Cone Angle") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Cone Angle lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = light.Fog.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Fog") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Fog lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
# Display curves specific to a camera. | |
camera = pNode.GetCamera() | |
if camera: | |
lAnimCurve = camera.FieldOfView.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Field of View") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Field of View lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = camera.FieldOfViewX.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Field of View X") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Field of View X lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = camera.FieldOfViewY.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Field of View Y") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Field of View Y lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = camera.OpticalCenterX.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Optical Center X") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Optical Center X lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = camera.OpticalCenterY.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Optical Center Y") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Optical Center Y lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
lAnimCurve = camera.Roll.GetCurve(pAnimLayer) | |
if lAnimCurve: | |
print(" Roll") | |
DebugLog("ImportScene00100.py DisplayAnimation () def DisplayChannels() 00500 Roll lAnimCurve==" +str(lAnimCurve) ) | |
DisplayCurve(lAnimCurve) | |
# Display curves specific to a geometry. | |
if lNodeAttribute.GetAttributeType() == FbxNodeAttribute.eMesh or \ | |
lNodeAttribute.GetAttributeType() == FbxNodeAttribute.eNurbs or \ | |
lNodeAttribute.GetAttributeType() == FbxNodeAttribute.ePatch: | |
lGeometry = lNodeAttribute | |
lBlendShapeDeformerCount = lGeometry.GetDeformerCount(FbxDeformer.eBlendShape) | |
for lBlendShapeIndex in range(lBlendShapeDeformerCount): | |
lBlendShape = lGeometry.GetDeformer(lBlendShapeIndex, FbxDeformer.eBlendShape) | |
lBlendShapeChannelCount = lBlendShape.GetBlendShapeChannelCount() | |
for lChannelIndex in range(lBlendShapeChannelCount): | |
lChannel = lBlendShape.GetBlendShapeChannel(lChannelIndex) | |
lChannelName = lChannel.GetName() | |
lAnimCurve = lGeometry.GetShapeChannel(lBlendShapeIndex, lChannelIndex, pAnimLayer, True) | |
if lAnimCurve: | |
print(" Shape %s" % lChannelName) | |
DisplayCurve(lAnimCurve) | |
# Display curves specific to properties | |
lProperty = pNode.GetFirstProperty() | |
while lProperty.IsValid(): | |
if lProperty.GetFlag(FbxPropertyFlags.eUserDefined): | |
lFbxFCurveNodeName = lProperty.GetName() | |
lCurveNode = lProperty.GetCurveNode(pAnimLayer) | |
if not lCurveNode: | |
lProperty = pNode.GetNextProperty(lProperty) | |
continue | |
lDataType = lProperty.GetPropertyDataType() | |
if lDataType.GetType() == eFbxBool or lDataType.GetType() == eFbxDouble or lDataType.GetType() == eFbxFloat or lDataType.GetType() == eFbxInt: | |
lMessage = " ImportScene00100.py DisplayAnimation () def DisplayChannels() 00800 Property " | |
lMessage += lProperty.GetName() | |
if lProperty.GetLabel().GetLen() > 0: | |
lMessage += " (Label: " | |
lMessage += lProperty.GetLabel() | |
lMessage += ")" | |
DisplayString(lMessage) | |
for c in range(lCurveNode.GetCurveCount(0)): | |
lAnimCurve = lCurveNode.GetCurve(0, c) | |
if lAnimCurve: | |
DisplayCurve(lAnimCurve) | |
elif lDataType.GetType() == eFbxDouble3 or lDataType.GetType() == eFbxDouble4 or lDataType.Is(FbxColor3DT) or lDataType.Is(FbxColor4DT): | |
if lDataType.Is(FbxColor3DT) or lDataType.Is(FbxColor4DT): | |
lComponentName1 = KFCURVENODE_COLOR_RED | |
lComponentName2 = KFCURVENODE_COLOR_GREEN | |
lComponentName3 = KFCURVENODE_COLOR_BLUE | |
else: | |
lComponentName1 = "X" | |
lComponentName2 = "Y" | |
lComponentName3 = "Z" | |
lMessage = " ImportScene00100.py DisplayAnimation () def DisplayChannels() 00900 Property " | |
lMessage += lProperty.GetName() | |
if lProperty.GetLabel().GetLen() > 0: | |
lMessage += " (Label: " | |
lMessage += lProperty.GetLabel() | |
lMessage += ")" | |
DisplayString(lMessage) | |
for c in range(lCurveNode.GetCurveCount(0)): | |
lAnimCurve = lCurveNode.GetCurve(0, c) | |
if lAnimCurve: | |
DisplayString(" ImportScene00100.py DisplayAnimation () def DisplayChannels() 01000 Component ", lComponentName1) | |
DisplayCurve(lAnimCurve) | |
for c in range(lCurveNode.GetCurveCount(1)): | |
lAnimCurve = lCurveNode.GetCurve(1, c) | |
if lAnimCurve: | |
DisplayString(" ImportScene00100.py DisplayAnimation () def DisplayChannels() 01100 Component ", lComponentName2) | |
DisplayCurve(lAnimCurve) | |
for c in range(lCurveNode.GetCurveCount(2)): | |
lAnimCurve = lCurveNode.GetCurve(2, c) | |
if lAnimCurve: | |
DisplayString(" ImportScene00100.py DisplayAnimation () def DisplayChannels() 01200 Component ", lComponentName3) | |
DisplayCurve(lAnimCurve) | |
elif lDataType.GetType() == eFbxEnum: | |
lMessage = " ImportScene00100.py DisplayAnimation () def DisplayChannels() 01300 Property " | |
lMessage += lProperty.GetName() | |
if lProperty.GetLabel().GetLen() > 0: | |
lMessage += " (Label: " | |
lMessage += lProperty.GetLabel() | |
lMessage += ")" | |
DisplayString(lMessage) | |
for c in range(lCurveNode.GetCurveCount(0)): | |
lAnimCurve = lCurveNode.GetCurve(0, c) | |
if lAnimCurve: | |
DisplayListCurve(lAnimCurve, lProperty) | |
lProperty = pNode.GetNextProperty(lProperty) | |
def InterpolationFlagToIndex(flags): | |
#if (flags&KFCURVE_INTERPOLATION_CONSTANT)==KFCURVE_INTERPOLATION_CONSTANT: | |
# return 1 | |
#if (flags&KFCURVE_INTERPOLATION_LINEAR)==KFCURVE_INTERPOLATION_LINEAR: | |
# return 2 | |
#if (flags&KFCURVE_INTERPOLATION_CUBIC)==KFCURVE_INTERPOLATION_CUBIC: | |
# return 3 | |
return 0 | |
def ConstantmodeFlagToIndex(flags): | |
#if (flags&KFCURVE_CONSTANT_STANDARD)==KFCURVE_CONSTANT_STANDARD: | |
# return 1 | |
#if (flags&KFCURVE_CONSTANT_NEXT)==KFCURVE_CONSTANT_NEXT: | |
# return 2 | |
return 0 | |
def TangeantmodeFlagToIndex(flags): | |
#if (flags&KFCURVE_TANGEANT_AUTO) == KFCURVE_TANGEANT_AUTO: | |
# return 1 | |
#if (flags&KFCURVE_TANGEANT_AUTO_BREAK)==KFCURVE_TANGEANT_AUTO_BREAK: | |
# return 2 | |
#if (flags&KFCURVE_TANGEANT_TCB) == KFCURVE_TANGEANT_TCB: | |
# return 3 | |
#if (flags&KFCURVE_TANGEANT_USER) == KFCURVE_TANGEANT_USER: | |
# return 4 | |
#if (flags&KFCURVE_GENERIC_BREAK) == KFCURVE_GENERIC_BREAK: | |
# return 5 | |
#if (flags&KFCURVE_TANGEANT_BREAK) ==KFCURVE_TANGEANT_BREAK: | |
# return 6 | |
return 0 | |
def TangeantweightFlagToIndex(flags): | |
#if (flags&KFCURVE_WEIGHTED_NONE) == KFCURVE_WEIGHTED_NONE: | |
# return 1 | |
#if (flags&KFCURVE_WEIGHTED_RIGHT) == KFCURVE_WEIGHTED_RIGHT: | |
# return 2 | |
#if (flags&KFCURVE_WEIGHTED_NEXT_LEFT) == KFCURVE_WEIGHTED_NEXT_LEFT: | |
# return 3 | |
return 0 | |
def TangeantVelocityFlagToIndex(flags): | |
#if (flags&KFCURVE_VELOCITY_NONE) == KFCURVE_VELOCITY_NONE: | |
# return 1 | |
#if (flags&KFCURVE_VELOCITY_RIGHT) == KFCURVE_VELOCITY_RIGHT: | |
# return 2 | |
#if (flags&KFCURVE_VELOCITY_NEXT_LEFT) == KFCURVE_VELOCITY_NEXT_LEFT: | |
# return 3 | |
return 0 | |
def DisplayCurveKeys(pCurve): | |
interpolation = [ "?", "constant", "linear", "cubic"] | |
constantMode = [ "?", "Standard", "Next" ] | |
cubicMode = [ "?", "Auto", "Auto break", "Tcb", "User", "Break", "User break" ] | |
tangentWVMode = [ "?", "None", "Right", "Next left" ] | |
lKeyCount = pCurve.KeyGetCount() | |
for lCount in range(lKeyCount): | |
lTimeString = "" | |
lKeyValue = pCurve.KeyGetValue(lCount) | |
lKeyTime = pCurve.KeyGetTime(lCount) | |
lOutputString = " ImportScene00100.py 1866 DisplayAnimation () def DisplayCurveKeys() 01400 Key Time: " | |
lOutputString += lKeyTime.GetTimeString(lTimeString) | |
lOutputString += ".... Key Value: " | |
lOutputString += str(lKeyValue) | |
lOutputString += " [ " | |
lOutputString += interpolation[ InterpolationFlagToIndex(pCurve.KeyGetInterpolation(lCount)) ] | |
#if (pCurve.KeyGetInterpolation(lCount)&KFCURVE_INTERPOLATION_CONSTANT) == KFCURVE_INTERPOLATION_CONSTANT: | |
# lOutputString += " | " | |
# lOutputString += constantMode[ ConstantmodeFlagToIndex(pCurve.KeyGetConstantMode(lCount)) ] | |
#elif (pCurve.KeyGetInterpolation(lCount)&KFCURVE_INTERPOLATION_CUBIC) == KFCURVE_INTERPOLATION_CUBIC: | |
# lOutputString += " | " | |
# lOutputString += cubicMode[ TangeantmodeFlagToIndex(pCurve.KeyGetTangeantMode(lCount)) ] | |
# lOutputString += " | " | |
# lOutputString += tangentWVMode[ TangeantweightFlagToIndex(pCurve.KeyGetTangeantWeightMode(lCount)) ] | |
# lOutputString += " | " | |
# lOutputString += tangentWVMode[ TangeantVelocityFlagToIndex(pCurve.KeyGetTangeantVelocityMode(lCount)) ] | |
lOutputString += " ]" | |
print(lOutputString) | |
def DisplayCurveDefault(pCurve): | |
lOutputString = " ImportScene00100.py 1887 DisplayAnimation () def DisplayCurveDefault() 01500 Default Value: " | |
lOutputString += pCurve.GetValue() | |
print(lOutputString) | |
def DisplayListCurveKeys(pCurve, pProperty): | |
lKeyCount = pCurve.KeyGetCount() | |
for lCount in range(lKeyCount): | |
lKeyValue = static_cast<int>(pCurve.KeyGetValue(lCount)) | |
lKeyTime = pCurve.KeyGetTime(lCount) | |
lOutputString = " ImportScene00100.py 1899 DisplayAnimation () def DisplayListCurveKeys() 01600 Key Time: " | |
lOutputString += lKeyTime.GetTimeString(lTimeString) | |
lOutputString += ".... Key Value: " | |
lOutputString += lKeyValue | |
lOutputString += " (" | |
lOutputString += pProperty.GetEnumValue(lKeyValue) | |
lOutputString += ")" | |
print(lOutputString) | |
def DisplayListCurveDefault(pCurve, pProperty): | |
DisplayCurveDefault(pCurve) | |
#==================================================== | |
#==================================================== | |
#================== DisplayAnimation.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayGenericInfo.py =================== STA | |
#==================================================== | |
#==================================================== | |
from fbx import FbxProperty | |
from fbx import FbxPropertyFlags | |
from fbx import FbxPropertyDouble1 | |
from fbx import FbxPropertyDouble3 | |
from fbx import FbxPropertyBool1 | |
from fbx import FbxPropertyInteger1 | |
from fbx import FbxPropertyString | |
from fbx import FbxPropertyFloat1 | |
from fbx import FbxObject | |
from fbx import eFbxBool | |
from fbx import eFbxDouble | |
from fbx import eFbxDouble4 | |
from fbx import eFbxInt | |
from fbx import eFbxDouble3 | |
from fbx import eFbxFloat | |
from fbx import eFbxString | |
from fbx import FbxCriteria | |
import fbxsip | |
def DisplayGenericInfo(pScene): | |
lRootNode = pScene.GetRootNode() | |
for i in range(lRootNode.GetChildCount()): | |
DisplayNodeGenericInfo(lRootNode.GetChild(i), 0) | |
#Other objects directly connected onto the scene | |
for i in range(pScene.GetSrcObjectCount(FbxCriteria.ObjectType(FbxObject.ClassId))): | |
DisplayProperties(pScene.GetSrcObject(FbxCriteria.ObjectType(FbxObject.ClassId), i)) | |
def DisplayNodeGenericInfo(pNode, pDepth): | |
lString = "" | |
for i in range(pDepth): | |
lString += " " | |
lString += pNode.GetName() | |
lString += "\n" | |
DisplayString(lString) | |
#Display generic info about that Node | |
DisplayProperties(pNode) | |
DisplayString("") | |
for i in range(pNode.GetChildCount()): | |
DisplayNodeGenericInfo(pNode.GetChild(i), pDepth + 1) | |
def DisplayProperties(pObject): | |
DisplayString("Type: %s Name: %s" % (pObject.ClassId.GetFbxFileTypeName(), pObject.GetName())) | |
# Display all the properties | |
lCount = 0 | |
lProperty = pObject.GetFirstProperty() | |
while lProperty.IsValid(): | |
lCount += 1 | |
lProperty = pObject.GetNextProperty(lProperty) | |
lTitleStr = " Property Count: " | |
if lCount == 0: | |
return # there are no properties to display | |
DisplayInt(lTitleStr, lCount) | |
i=0 | |
lProperty = pObject.GetFirstProperty() | |
while lProperty.IsValid(): | |
# exclude user properties | |
DisplayInt(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Property ", i) | |
lString = lProperty.GetLabel() | |
DisplayString(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Display Name: ", lString.Buffer()) | |
lString = lProperty.GetName() | |
DisplayString(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Internal Name: ", lString.Buffer()) | |
lString = lProperty.GetPropertyDataType().GetName() | |
DisplayString(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Type: ", lString) | |
if lProperty.HasMinLimit(): | |
DisplayDouble(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Min Limit: ", lProperty.GetMinLimit()) | |
if lProperty.HasMaxLimit(): | |
DisplayDouble(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Max Limit: ", lProperty.GetMaxLimit()) | |
DisplayBool (" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Is Animatable: ", lProperty.GetFlag(FbxPropertyFlags.eAnimatable)) | |
if lProperty.GetPropertyDataType().GetType() == eFbxBool: | |
lProperty = FbxPropertyBool1(lProperty) | |
DisplayBool(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Default Value: ", lProperty.Get()) | |
elif lProperty.GetPropertyDataType().GetType() == eFbxDouble: | |
lProperty = FbxPropertyDouble1(lProperty) | |
DisplayDouble(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Default Value: ",lProperty.Get()) | |
elif lProperty.GetPropertyDataType().GetType() == eFbxDouble4: | |
lProperty = FbxPropertyDouble4(lProperty) | |
lDefault = lProperty.Get() | |
lBuf = "R=%f, G=%f, B=%f, A=%f" % (lDefault[0], lDefault[1], lDefault[2], lDefault[3]) | |
DisplayString(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Default Value: ", lBuf) | |
elif lProperty.GetPropertyDataType().GetType() == eFbxInt: | |
lProperty = FbxPropertyInteger1(lProperty) | |
DisplayInt(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Default Value: ", lProperty.Get()) | |
elif lProperty.GetPropertyDataType().GetType() == eFbxDouble3: | |
lProperty = FbxPropertyDouble3(lProperty) | |
lDefault = lProperty.Get() | |
lBuf = "X=%f, Y=%f, Z=%f" % (lDefault[0], lDefault[1], lDefault[2]) | |
DisplayString(" Default Value: ", lBuf) | |
#case DTEnum: | |
# DisplayInt(" Default Value: ", lProperty.Get()) | |
# break | |
elif lProperty.GetPropertyDataType().GetType() == eFbxFloat: | |
lProperty = FbxPropertyFloat1(lProperty) | |
DisplayDouble(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Default Value: ", lProperty.Get()) | |
elif lProperty.GetPropertyDataType().GetType() == eFbxString: | |
lProperty = FbxPropertyString(lProperty) | |
lString = lProperty.Get() | |
DisplayString(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Default Value: ", lString.Buffer()) | |
else: | |
DisplayString(" ImportScene00100.py 2014 DisplayGenericInfo () def DisplayProperties() 01800 Default Value: UNIDENTIFIED") | |
i += 1 | |
lProperty = pObject.GetNextProperty(lProperty) | |
#==================================================== | |
#==================================================== | |
#================== DisplayGenericInfo.py =================== END | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== =================== | |
#==================================================== | |
#==================================================== | |
#==================================================== | |
#================== DisplayCommon.py =================== | |
#==================================================== | |
""" | |
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 | |
""" | |
""" | |
import DisplayHierarchy | |
import DisplayMarker | |
import DisplayMesh | |
import DisplayUserProperties | |
import DisplayPivotsAndLimits | |
import DisplaySkeleton | |
import DisplayNurb | |
import DisplayPatch | |
import DisplayCamera | |
import DisplayLight | |
import DisplayLodGroup | |
import DisplayPose | |
import DisplayAnimation | |
import DisplayGenericInfo | |
""" | |
#==================================================== | |
#================== ImportScene.py =================== | |
#==================================================== | |
#===================class Node========================= | |
class ImportScene_00100() : | |
#====================================================================================================== | |
#====================================================================================================== | |
#============= ============================================== | |
#====================================================================================================== | |
#====================================================================================================== | |
#====================================================================================================== | |
def DisplayString(self,pHeader, pValue="" , pSuffix=""): | |
lString = "ImportScene_00100.py ImportScene_00100 Class Method 017 DisplayString() " | |
lString += " pHeader = " | |
lString += pHeader | |
lString += " pValue = " | |
lString += str(pValue) | |
lString += " pSuffix = " | |
lString += pSuffix | |
#print(lString) | |
DebugLog(str(lString)) | |
#==================================================== | |
#================== ImportScene.py =================== | |
#==================================================== | |
def DisplayMetaData(self,pScene): | |
sceneInfo = pScene.GetSceneInfo() | |
if sceneInfo: | |
self.DebugLog("--------------------") | |
self.DebugLog(" Meta-Data ") | |
self.DebugLog("--------------------") | |
self.DebugLog(" 00100 Title : " + str( sceneInfo.mTitle.Buffer () ) ) | |
self.DebugLog(" 00200 Subject : " + str( sceneInfo.mSubject.Buffer () ) ) | |
self.DebugLog(" 00300 Author : " + str( sceneInfo.mAuthor.Buffer () ) ) | |
self.DebugLog(" 00400 Keywords: " + str( sceneInfo.mKeywords.Buffer () ) ) | |
self.DebugLog(" 00500 Revision: " + str( sceneInfo.mRevision.Buffer () ) ) | |
self.DebugLog(" 00600 Comment : " + str( sceneInfo.mComment.Buffer () ) ) | |
thumbnail = sceneInfo.GetSceneThumbnail() | |
if thumbnail: | |
self.DebugLog(" Thumbnail:") | |
if thumbnail.GetDataFormat() == FbxThumbnail.eRGB_24 : | |
self.DebugLog(" Format: RGB") | |
elif thumbnail.GetDataFormat() == FbxThumbnail.eRGBA_32: | |
self.DebugLog(" Format: RGBA") | |
if thumbnail.GetSize() == FbxThumbnail.eNOT_SET: | |
self.DebugLog(" Size: no dimensions specified ("+ str( thumbnail.GetSizeInBytes() ) +" bytes)") | |
elif thumbnail.GetSize() == FbxThumbnail.e64x64: | |
self.DebugLog(" Size: 64 x 64 pixels ("+ str( thumbnail.GetSizeInBytes() ) +" bytes)") | |
elif thumbnail.GetSize() == FbxThumbnail.e128x128: | |
self.DebugLog(" Size: 128 x 128 pixels ("+ str( thumbnail.GetSizeInBytes() ) +" bytes)") | |
def DisplayContent(self,pScene): | |
lNode = pScene.GetRootNode() | |
if lNode: | |
for i in range(lNode.GetChildCount()): | |
self.DisplayNodeContent(lNode.GetChild(i)) | |
def DisplayNodeContent(self,pNode): | |
if pNode.GetNodeAttribute() == None: | |
self.DebugLog("NULL Node Attribute \n") | |
else: | |
lAttributeType = ( pNode.GetNodeAttribute().GetAttributeType() ) | |
if lAttributeType == FbxNodeAttribute.eMarker: | |
self.DisplayMarker(pNode) | |
elif lAttributeType == FbxNodeAttribute.eSkeleton: | |
DisplaySkeleton(pNode) | |
elif lAttributeType == FbxNodeAttribute.eMesh: | |
self.DisplayMesh(pNode) | |
elif lAttributeType == FbxNodeAttribute.eNurbs: | |
self.DisplayNurb(pNode) | |
elif lAttributeType == FbxNodeAttribute.ePatch: | |
self.DisplayPatch(pNode) | |
elif lAttributeType == FbxNodeAttribute.eCamera: | |
self.DisplayCamera(pNode) | |
elif lAttributeType == FbxNodeAttribute.eLight: | |
self.DisplayLight(pNode) | |
DisplayUserProperties(pNode) | |
self.DisplayTarget(pNode) | |
DisplayPivotsAndLimits(pNode) | |
self.DisplayTransformPropagation(pNode) | |
self.DisplayGeometricTransform(pNode) | |
for i in range(pNode.GetChildCount()): | |
self.DisplayNodeContent( pNode.GetChild(i) ) | |
def DisplayTarget(self,pNode): | |
if pNode.GetTarget(): | |
self.DisplayString(" Target Name: ", pNode.GetTarget().GetName()) | |
def DisplayTransformPropagation(self,pNode): | |
self.DebugLog(" Transformation Propagation") | |
# Rotation Space | |
lRotationOrder = pNode.GetRotationOrder(FbxNode.eSourcePivot) | |
self.DebugLog(" Rotation Space:") | |
if lRotationOrder == eEulerXYZ: | |
self.DebugLog("Euler XYZ") | |
elif lRotationOrder == eEulerXZY: | |
self.DebugLog("Euler XZY") | |
elif lRotationOrder == eEulerYZX: | |
self.DebugLog("Euler YZX") | |
elif lRotationOrder == eEulerYXZ: | |
self.DebugLog("Euler YXZ") | |
elif lRotationOrder == eEulerZXY: | |
self.DebugLog("Euler ZXY") | |
elif lRotationOrder == eEulerZYX: | |
self.DebugLog("Euler ZYX") | |
elif lRotationOrder == eSphericXYZ: | |
self.DebugLog("Spheric XYZ") | |
# Use the Rotation space only for the limits | |
# (keep using eEULER_XYZ for the rest) | |
if pNode.GetUseRotationSpaceForLimitOnly(FbxNode.eSourcePivot): | |
self.DebugLog(" Use the Rotation Space for Limit specification only: Yes") | |
else: | |
self.DebugLog(" Use the Rotation Space for Limit specification only: No") | |
# Inherit Type | |
lInheritType = pNode.GetTransformationInheritType() | |
self.DebugLog(" Transformation Inheritance:") | |
if lInheritType == FbxTransform.eInheritRrSs: | |
self.DebugLog("RrSs") | |
elif lInheritType == FbxTransform.eInheritRSrs: | |
self.DebugLog("RSrs") | |
elif lInheritType == FbxTransform.eInheritRrs: | |
self.DebugLog("Rrs") | |
def DisplayGeometricTransform(self,pNode): | |
print(" Geometric Transformations") | |
# Translation | |
lTmpVector = pNode.GetGeometricTranslation(FbxNode.eSourcePivot) | |
self.DebugLog(" Translation: "+ str(lTmpVector[0])+","+str( lTmpVector[1])+","+ str(lTmpVector[2]) ) | |
# Rotation | |
lTmpVector = pNode.GetGeometricRotation(FbxNode.eSourcePivot) | |
#print(" Rotation: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2])) | |
self.DebugLog(" Rotation: "+ str(lTmpVector[0])+","+str( lTmpVector[1])+","+ str(lTmpVector[2]) ) | |
# Scaling | |
lTmpVector = pNode.GetGeometricScaling(FbxNode.eSourcePivot) | |
#print(" Scaling: %f %f %f" % (lTmpVector[0], lTmpVector[1], lTmpVector[2])) | |
self.DebugLog(" Scaling: "+ str(lTmpVector[0])+","+str( lTmpVector[1])+","+ str(lTmpVector[2]) ) | |
#==================================================== | |
#================== ImportScene.py =================== | |
#==================================================== | |
Yen="\\" | |
FileName= "ImportScene_00100__Log.csv" | |
#print("HD FULL PATH =") | |
#HD_FULL_PATH=os.path.abspath(__file__) | |
#print("os.path.abspath(__file__) = " + HD_FULL_PATH) | |
FullPass_DustDataTextFile_TXT= "D:"+Yen+"vs"+Yen+"py"+Yen+FileName | |
def ImportScene_00100(self): | |
print("ImportScene_00100_Start............. filepath = "+str(filepath)) | |
#self.FullPass_DustDataTextFile_TXT=filepath | |
#文字をエスケープする/エスケープを外す ///////////////////////http://lightson.dip.jp/zope/ZWiki/053_e6_96_87_e5_ad_97_e3_82_92_e3_82_a8_e3_82_b9_e3_82_b1_e3_83_bc_e3_83_97_e3_81_99_e3_82_8b_ef_bc_8f_e3_82_a8_e3_82_b9_e3_82_b1_e3_83_bc_e3_83_97_e3_82_92_e5_a4_96_e3_81_99 | |
def escape(self,s, quoted=u'\'"\\', escape=u'\\'): | |
return re.sub(u'[%s]' % re.escape(quoted),lambda mo: escape + mo.group(),s) | |
def unescape(self,s, quoted=u'\'"\\', escape=u'\\'): | |
return re.sub(ur'%s([%s])' % (re.escape(escape), re.escape(quoted)),ur'\1',s) | |
def DebugLog(self,strData): | |
mystr=strData | |
print(mystr) | |
if mystr=="": | |
print("DebugLog (mystr ) is empty....................") | |
else: | |
#mystr=str(mystr)+"," | |
mystr=str(mystr)+"\n" | |
#mystr=mystr+"\n" | |
escapedStrData=self.escape(mystr) | |
self.fileReWrite(self.FullPass_DustDataTextFile_TXT,escapedStrData) | |
#fileReWrite(FullPass_DustDataTextFile_TXT,mystr) | |
#fileWrite(FullPass_DustDataTextFile_TXT,mystr) | |
#fileWrite("C:\Users\akiyaman\AppData\Roaming\Adobe\Common","ABC") | |
#----------------ファイルを作る------------------ | |
def ExportWrite(self,strData): | |
strData_str=str(strData) | |
e_infinity_str_first_to_end_count=strData_str.find("e") | |
new_float_string= strData_str | |
if e_infinity_str_first_to_end_count==-1: | |
new_float_string= strData_str | |
else: | |
new_float_string= strData_str[0:e_infinity_str_first_to_end_count] | |
#new_float_string= strData_str[0:4] | |
self.DebugLog(new_float_string) | |
def fileWrite(self,fullPass,DataStr): | |
print("fileWrite fullPass= "+fullPass) | |
print("fileWrite DataStr= "+DataStr) | |
f = open(fullPass, 'w') # 書き込みモードで開く | |
#str = "This Data is Temp Please Delete" # 書き込む文字列 | |
#f = open('text.txt', 'w') # 書き込みモードで開く | |
#f.write(str) # 引数の文字列をファイルに書き込む | |
f.write(DataStr) # 引数の文字列をファイルに書き込む | |
f.close() # ファイルを閉じる | |
def fileDataZeroReset(self): | |
self.fileWrite(self.FullPass_DustDataTextFile_TXT,"") | |
def fileReWrite(self,fullPass,DataStr): | |
print("fileWrite fullPass= "+fullPass)#/////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
print("fileWrite DataStr= "+DataStr) | |
f = open(fullPass, 'a') # 追記書き込みモードで開く | |
#str = "This Data is Temp Please Delete" # 書き込む文字列 | |
#f = open('text.txt', 'w') # 書き込みモードで開く | |
#f.write(str) # 引数の文字列をファイルに書き込む | |
f.write(DataStr) # 引数の文字列をファイルに書き込む | |
f.close() # ファイルを閉じる | |
def fileWriteTemp(self,fullPass): | |
fileWrite(fullPass,"DustDataTextFile") | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
#//////////////////////////////////// Class Unit Test ///////////////////////////////////////////// | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
def getClassName(self): | |
print( u"className= " + self.__class__.__name__) | |
return self.__class__.__name__ | |
class TxtReaderTrans_Z_00320() : | |
def fileRead(self,filepath): | |
print("088 fileRead() filepath = "+str(filepath)) | |
returnData="" | |
f = open(filepath, 'r') | |
#returnData = f | |
poolStr="" | |
for row in f: | |
print row | |
poolStr=poolStr+row | |
f.close() | |
print("099 fileRead() poolStr = "+poolStr) | |
returnData=str(poolStr) | |
print("101 fileRead() returnData = "+returnData) | |
return returnData | |
def ReadTransFile(self): | |
returnData="" | |
ImportScene_00100_Instance = ImportScene_00100() | |
returnData =self.fileRead(ImportScene_00100_Instance.FullPass_DustDataTextFile_TXT) | |
print("107 ReadSimple() returnData = "+ str(returnData)) | |
return returnData | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
#//////////////////////////////////// Class Unit Test ///////////////////////////////////////////// | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
def getClassName(self): | |
print( u"className= " + self.__class__.__name__) | |
return self.__class__.__name__ | |
ImportScene_00100_Instance = ImportScene_00100() # Class export instance. | |
print(" ImportScene_00100 Class __name__="+__name__) | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
#//////////////////////////////////// Class Unit Test ///////////////////////////////////////////// | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
def DebugLog(DataStr): | |
ImportScene_00100_Instance.DebugLog( str(DataStr) ) | |
def StartMainLine(ImportScene_00100_Instance): | |
print("StartMainLine") | |
ImportScene_00100_Instance.fileDataZeroReset() | |
# Prepare the FBX SDK. | |
#lSdkManager, lScene = InitializeSdkObjects() | |
Yen="\\" | |
IMPORT_FBX_FileName ="walkTest.fbx" | |
IMPORT_FBX_FileName ="walkTest_fbx_Maya_00100_Only_Root_And_C_Pelvis_ASCII_fbx.fbx" | |
FBX_FILE_PATH_AND_NAME_AND_EXT= "D:"+Yen+"vs"+Yen+"py"+Yen+IMPORT_FBX_FileName | |
manager = FbxManager.Create() | |
ios = FbxIOSettings.Create(manager, IOSROOT) | |
manager.SetIOSettings(ios) | |
importer = FbxImporter.Create(manager, "") | |
fbxImportSuccesBool=importer.Initialize(FBX_FILE_PATH_AND_NAME_AND_EXT, -1, manager.GetIOSettings()) | |
#DebugLog("fbxImportSuccesBool=") | |
if not fbxImportSuccesBool: | |
DebugLog("fbxImportSuccesBool==False") | |
print ("==============Failed to load file.==============") | |
return | |
else: | |
DebugLog("fbxImportSuccesBool==True") | |
scene = FbxScene.Create(manager, "MyScene") | |
lScene=scene | |
importer.Import(scene) | |
#========================================================== | |
#importScene.py Timeing | |
#========================================================== | |
ImportScene_00100_Instance.DisplayMetaData(lScene) | |
DebugLog("\n\n---------------------\nGlobal Light Settings\n---------------------\n") | |
DisplayGlobalLightSettings(lScene) | |
DebugLog("\n\n----------------------\nGlobal Camera Settings\n----------------------\n") | |
DisplayGlobalCameraSettings(lScene) | |
DebugLog("\n\n--------------------\nGlobal Time Settings\n--------------------\n") | |
lScene_GetGlobalSettings= lScene.GetGlobalSettings() | |
DebugLog("2859 Frames FPS lScene_GetGlobalSettings = "+ str(lScene_GetGlobalSettings) ) | |
DisplayGlobalTimeSettings(lScene.GetGlobalSettings()) | |
DebugLog("\n\n---------\nHierarchy\n---------\n") | |
DisplayHierarchy(lScene) | |
DebugLog("\n\n------------\nNode Content\n------------\n") | |
ImportScene_00100_Instance.DisplayContent(lScene) | |
DebugLog("\n\n----\nPose\n----\n") | |
DisplayPose(lScene) | |
DebugLog("\n\n---------\nAnimation\n---------\n") | |
DisplayAnimation(lScene) | |
#now display generic information | |
DebugLog("\n\n---------\nGeneric Information\n---------\n") | |
DisplayGenericInfo(lScene) | |
#ImportScene_00100_Instance.ExportWrite("0.111"); | |
#ImportScene_00100_Instance.ExportWrite("0.222"); | |
#ImportScene_00100_Instance.ExportWrite("0.333"); | |
#ImportScene_00100_Instance.ExportWrite("0.444"); | |
""" | |
#============================================================================= | |
print("========================= Write Start==========================") | |
floatList = [1.111, 1.222, 1.333, 1.444, 1.555] | |
floatListLength=len(floatList) | |
for i in range(0, floatListLength): | |
print( str(i) ) | |
print(floatList[i]) | |
floatNum=floatList[i] | |
floatNumstr=str(floatNum) | |
#ImportScene_00100_Instance.ExportWrite("0.111"); | |
ImportScene_00100_Instance.ExportWrite( str(floatNumstr) ); | |
#============================================================================= | |
print("========================= Read Start==========================") | |
ImportScene_00100_Instance2 = TxtReaderTrans_Z_00320() # Class export instance. | |
TransZstrData = ImportScene_00100_Instance2.ReadTransFile() | |
TransZstr=str(TransZstrData) | |
print("TransZstr = _ "+str(TransZstr)+" _ END ") | |
print("========================= add list Start==========================") | |
TransZstrList=TransZstr.split(",") # 「,」を区切り文字としてリストを返す | |
print("TransZstrList = _ "+str(TransZstrList)+" _ END ") | |
TransZstrListLength=len(TransZstrList) | |
print("TransZstrListLength = "+str(TransZstrListLength)) | |
#========================================== | |
#========================================== | |
TransZ_list = [0] | |
#指定のインデックスの要素を削除する | |
TransZ_list.pop(0) | |
#---------------------------------------------- | |
for j in range(0, TransZstrListLength): | |
print( "TransZ Loop "+str(j) ) | |
print(TransZstrList[j]) | |
TransZnumStr=TransZstrList[j] | |
print("TransZnumStr= "+TransZnumStr) | |
if(TransZnumStr == ""): | |
print("TransZ empty string ") | |
else: | |
TransZnumFloat=float(TransZnumStr) | |
TransZ_list.append(TransZnumFloat) | |
#===================TransZ_list debug============================== | |
print("========================= =TransZ_list debug Start==========================") | |
TransZ_listLength=len(TransZ_list) | |
for d in range(0, TransZ_listLength): | |
print( "TransZ_list Loop Debug "+str(d) ) | |
TransZnumFloat_d=TransZ_list[d] | |
TransZnumStr_d = str(TransZnumFloat_d) | |
print("TransZnumStr_d = "+TransZnumStr_d) | |
#DebugLog (u"__name__==self.__class__.__name__ Same!! File Test") | |
#DebugLog (u"=============Simple Single Class Unit Test Start==========") | |
#Instance.ImportScene_00100() #Call Method | |
""" | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
#////////////////////////////////////ImportScene_00100_Instance Class Unit Test ///////////////////////////////////////////// | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
if(__name__ == ImportScene_00100_Instance.getClassName()): | |
print (u"=============Simple Single Class Unit Test Start====Instance.getClassName() = "+ImportScene_00100_Instance.getClassName()+" =====") | |
#StartMainLine(ImportScene_00100_Instance) | |
elif(__name__ == "ImportScene_00100"): | |
print (u"=============Simple Single Class Unit Test Start===== StartMainLine =====") | |
StartMainLine(ImportScene_00100_Instance) | |
#Instance.loadFile(FBX_FILE_PATH_AND_NAME_AND_EXT) | |
elif(__name__ == "__main__"): | |
print (u"=============Simple Single Class Unit Test Start===== __main__ =====") | |
StartMainLine(ImportScene_00100_Instance) | |
else: | |
print (u"__name__!=self.__class__.__name__ Othor File Import") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
included ////////////////////////////////////////////
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