Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fbx import *
- #from samples.ImportScene.DisplayCommon import *
- def DisplayString(pHeader, pValue="" , pSuffix=""):
- lString = pHeader
- lString += str(pValue)
- lString += pSuffix
- print(lString)
- def DisplayBool(pHeader, pValue, pSuffix=""):
- lString = pHeader
- if pValue:
- lString += "true"
- else:
- lString += "false"
- lString += pSuffix
- print(lString)
- def DisplayInt(pHeader, pValue, pSuffix=""):
- lString = pHeader
- lString += str(pValue)
- lString += pSuffix
- print(lString)
- def DisplayDouble(pHeader, pValue, pSuffix=""):
- DebugLog("%s%f%s" % (pHeader, pValue, pSuffix))
- def Display2DVector(pHeader, pValue, pSuffix=""):
- DebugLog("%s%f, %f%s" % (pHeader, pValue[0], pValue[1], pSuffix))
- def Display3DVector(pHeader, pValue, pSuffix=""):
- DebugLog("%s%f, %f, %f%s" % (pHeader, pValue[0], pValue[1], pValue[2], pSuffix))
- def Display4DVector(pHeader, pValue, pSuffix=""):
- DebugLog("%s%f, %f, %f, %f%s" % (pHeader, pValue[0], pValue[1], pValue[2], pValue[3], pSuffix))
- def DisplayColor(pHeader, pValue, pSuffix=""):
- DebugLog("%s%f (red), %f (green), %f (blue)%s" % (pHeader, pValue.mRed, pValue.mGreen, pValue.mBlue, pSuffix))
- #from fbx import *
- #FBX_FILE_PATH_AND_NAME_AND_EXT="D:/work/FBXSDK/fbxsdk00100/Solder_Model_FBX_ASCII_2016_2017_settings_.fbx"
- FBX_FILE_PATH_AND_NAME_AND_EXT="D:/work/FBXSDK/for_yamakawa/SoldierProject/scenes/FBX/Solder_Model_ASCII_2016_2017_motion00200.fbx"
- print(u"00100. fbx_manager=========================================================== ")
- """
- fbx_manager = FbxManager.Create()
- print(u"00200. fbx_scene")
- fbx_scene = FbxScene.Create(fbx_manager, "MyScene")
- print(u"00300. fbx_importer")
- fbx_importer = FbxImporter.Create(fbx_manager, "")
- fbx_importer.Initialize(FBX_FILE_PATH_AND_NAME_AND_EXT)
- fbx_importer.Destroy()
- print(u"end00200. fbx_scene")
- fbx_scene.Destroy()
- print(u"end 00100. fbx_manager")
- fbx_manager.Destroy()
- """
- # -*- coding: utf-8 -*-
- from maya import cmds
- import maya as maya
- import pymel.core as pm
- #import Debug
- #Debug=Debug.Debug
- Yen="\\"
- #Dir_AppDataLocal="\AppData\Local\Temp\Adobe\After Effects"
- #FullPass_AppDataLocal ="C:\Users"+Yen+UserNameStr+Dir_AppDataLocal+Yen+fileNameStr
- FileName="DustDataTextFile.txt"
- FullPass_DustDataTextFile_TXT= "D:\work\FBXSDK\DLLinPy\FBXSDK201701py"+Yen+"fbxproj\ImportScene"+Yen+FileName
- print("FullPass_DustDataTextFile_TXT="+FullPass_DustDataTextFile_TXT)
- def DebugLog(strData):
- mystr=strData
- print(mystr)
- if mystr=="":
- print("DebugLog (mystr ) is empty....................")
- else:
- fileReWrite(FullPass_DustDataTextFile_TXT,mystr)
- #fileWrite(FullPass_DustDataTextFile_TXT,mystr)
- #fileWrite("C:\Users\akiyaman\AppData\Roaming\Adobe\Common","ABC")
- #----------------ファイルを作る------------------
- def fileWrite(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 fileReWrite(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(fullPass):
- fileWrite(fullPass,"DustDataTextFile")
- #===================class Node=========================
- class Node() :
- def __init__(self, name, parent) :
- self.name = name
- self.parent = parent
- self.children = None
- self.type = None
- def addChild(self, child) :
- if not self.children : self.children = list()
- self.children.append(child)
- def getTypeName(fbxNode) :
- nodeAttr = fbxNode.GetNodeAttribute()
- e = nodeAttr.GetAttributeType()
- sType = "Unknown"
- if FbxNodeAttribute.eNull == e : sType = "Null"
- elif FbxNodeAttribute.eMarker == e : sType = "Marker"
- elif FbxNodeAttribute.eSkeleton == e : sType = "Skeleton"
- elif FbxNodeAttribute.eMesh == e : sType = "Mesh"
- elif FbxNodeAttribute.eNurbs == e : sType = "Nurbs"
- elif FbxNodeAttribute.ePatch == e : sType = "Patch"
- elif FbxNodeAttribute.eCamera == e : sType = "Camera"
- elif FbxNodeAttribute.eLight == e : sType = "Light"
- return sType
- def getHierarchy(fbxNode, node) :
- num = fbxNode.GetChildCount()
- DebugLog("getHierarchy(fbxNode= "+str(fbxNode)+", node.name= "+str(node.name)+")")
- if 0 == num : return
- for i in range(num) :
- fbxChild = fbxNode.GetChild(i)
- nodeChild = Node(fbxChild.GetName(), node)
- nodeChild.type = getTypeName(fbxChild)
- node.addChild(nodeChild)
- getHierarchy(fbxChild, nodeChild)
- def printHierarchy(node, padding) :
- print padding + node.name
- if not node.children : return
- for child in node.children : printHierarchy(child, padding+" ")
- def addTreeItem(item, node) :
- if not node.children : return
- for child in node.children :
- i = QTreeWidgetItem()
- i.setText(0, "%s (%s)"%(child.name, child.type))
- item.addChild(i)
- addTreeItem(i, child)
- #===================class Node=========================
- #===================GetMesh =========================
- def GetMesh(node):
- mesh=node.GetMesh();
- DebugLog("mesh== "+str(mesh))
- if mesh ==None:
- DebugLog("mesh==None")
- #===================GetMesh =========================
- #===================GetKeyCurve=========================
- def GetKeyCurve(fbxImporter,pScene):
- print ("===========GetKeyCurve(pScene= "+str(fbxImporter)+" pScene="+str(pScene)+" )===========")
- print ("GetKeyCurve(pScene= "+str(fbxImporter)+" pScene="+str(pScene)+" )")
- #==SDKの1シーンであるFbxScene sceneをルートとして次のようにします:
- #==① アニメーションスタック数取得
- #int nbAnimStacks = pScene->GetSrcObjectCount<FbxAnimStack>()
- print ("----GetKeyCurve( fbxImporter.GetAnimStackCount()= "+str(fbxImporter.GetAnimStackCount())+" -------------------")
- intAnimStacks=0
- intAnimStacks=fbxImporter.GetAnimStackCount()
- print ("----GetKeyCurve------ intAnimStacks= "+str(intAnimStacks)+" -------------------")
- print ("----GetKeyCurve( fbxImporter.GetActiveAnimStackName()= "+str(fbxImporter.GetActiveAnimStackName())+" -------------------")
- #int intAnimStacks = fbxImporter.GetAnimStackCount()
- #print ("nbAnimStacks= "+str(nbAnimStacks))
- #==② アニメーションスタック取得
- #for ( int i = 0; i < nbAnimStacks; i++ )
- #FbxAnimStack* lAnimStack = pScene->GetSrcObject<FbxAnimStack>(i);
- TakeInfoList= [0 for i in range(1)]
- del TakeInfoList[0]
- for i in range(0, intAnimStacks):
- DebugLog("for i="+str(i))
- pTakeInfo=fbxImporter.GetTakeInfo(i);
- DebugLog("for pTakeInfo="+str(pTakeInfo))
- pTakeName = pTakeInfo.mName;
- DebugLog("for pTakeName="+str(pTakeName))
- mImportName = pTakeInfo.mImportName;
- DebugLog("for mImportName="+str(mImportName))
- #fbxAnimStack = fbxImporter.GetAnimStackCount(i)
- #DebugLog("for fbxAnimStack="+str(fbxAnimStack));
- TakeInfoList.append(pTakeInfo);
- TakeInfoListLen=len(TakeInfoList)
- i=0
- DebugLog("TakeInfoListLen= "+str(TakeInfoListLen))
- for i in range(0, TakeInfoListLen):
- strTakeInfoList_i_mName = TakeInfoList[i].mName
- print("strTakeInfoList_i_mName= "+strTakeInfoList_i_mName);
- str_A="strTakeInfoList_i_mName="+strTakeInfoList_i_mName
- #DebugLog(str_A)
- TakeInfo=TakeInfoList[i]
- print ("===========GetAnimationLayer ===========")
- #==③ アニメーションレイヤー数を取得
- #int nbAnimLayers = pAnimStack->GetMemberCount<FbxAnimLayer>();
- DebugLog("TakeInfo="+str(TakeInfo))
- DebugLog("TakeInfo.mName="+str(TakeInfo.mName))
- DebugLog("TakeInfo.mCurrentLayer="+str(TakeInfo.mCurrentLayer))
- if(TakeInfo.mCurrentLayer==-1):
- DebugLog("TakeInfo.mLayerInfoList= AnimLayer is None is This FBX is None Animation File !!!!!!!")
- else:
- DebugLog("TakeInfo.mLayerInfoList="+str(TakeInfo.mLayerInfoList))
- #DebugLog("lAnimStack="+str(lAnimStack.))
- #AnimLayers=
- DisplayAnimation(pScene)
- """
- #==④ アニメーションレイヤーを取得
- for ( int i = 0; i < nbAnimLayers; i++ )
- FbxAnimLayer* pAnimLayer = pAnimStack->GetMember<FbxAnimLayer>(l);
- #==⑤ ノードが持っているアニメーションカーブをアニメーションレイヤーから取得
- FbxAnimCurve* pAnimCurve = pNode->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
- ⑥ カーブ内のキータイムを取得
- int nbKeyCount = pAnimCurve->KeyGetCount();
- for ( int i = 0; i < nbAnimLayers; i++ )
- FbxTime keyTime = pAnimCurve->KeyGetTime( nbKeyCount )
- """
- #===========================引用 D:\work\FBXSDK\FBX\FBX Python SDK\2016.1.1\samples\ImportScene\DisplayAnimation.py
- from fbx import FbxAnimStack
- #from fbx import FbxAnimLayer
- #from fbx import FbxProperty
- #from fbx import FbxNodeAttribute
- def DisplayAnimation(pScene):
- DebugLog("=============================DisplayAnimation.py===DisplayAnimation(pScene = "+ str(pScene)+")==================================")
- DebugLog("FbxAnimStack.ClassId="+str(FbxAnimStack.ClassId))
- pFbxAnimStackClassID=FbxAnimStack.ClassId
- DebugLog("pFbxAnimStackClassID="+str(pFbxAnimStackClassID))
- pFbxCriteriaFbxAnimStackClassID=FbxCriteria.ObjectType(FbxAnimStack.ClassId)
- DebugLog("pFbxCriteriaFbxAnimStackClassID="+str(pFbxCriteriaFbxAnimStackClassID))
- #pFbxCriteriaFbxAnimStackClassID=
- #loopCount=pScene.GetSrcObjectCount(pFbxAnimStackClassID)
- intSceneAllObjCount=pScene.GetSrcObjectCount(pFbxCriteriaFbxAnimStackClassID)
- DebugLog("intSceneAllObjCount="+str(intSceneAllObjCount))
- #for i in range(pScene.GetSrcObjectCount(FbxAnimStack.ClassId)):
- for i in range(intSceneAllObjCount):
- DebugLog("DisplayAnimation i="+str(i))
- lAnimStack = pScene.GetSrcObject(pFbxCriteriaFbxAnimStackClassID, i)
- DebugLog("lAnimStack ="+str(lAnimStack))
- lOutputString = "Animation Stack Name: "
- lOutputString += lAnimStack.GetName()
- lOutputString += "\n"
- print(lOutputString)
- DisplayAnimationStack(lAnimStack, pScene.GetRootNode(), True)
- """
- for i in range(pScene.GetSrcObjectCount(FbxAnimStack.ClassId)):
- lAnimStack = pScene.GetSrcObject(FbxAnimStack.ClassId, i)
- lOutputString = "Animation Stack Name: "
- lOutputString += lAnimStack.GetName()
- lOutputString += "\n"
- print(lOutputString)
- DisplayAnimationStack(lAnimStack, pScene.GetRootNode(), False)
- """
- def DisplayAnimationStack(pAnimStack, pNode, isSwitcher):
- DebugLog("============DisplayAnimationStack======================")
- pFbxCriteria_FbxAnimLayer=FbxCriteria.ObjectType(FbxAnimLayer.ClassId)
- DebugLog("pFbxCriteria_FbxAnimLayer="+str(pFbxCriteria_FbxAnimLayer))
- nbAnimLayers = pAnimStack.GetSrcObjectCount(pFbxCriteria_FbxAnimLayer)
- lOutputString = "Animation stack contains "
- lOutputString += str(nbAnimLayers)
- lOutputString += " Animation Layer(s)"
- print(lOutputString)
- for l in range(nbAnimLayers):
- lAnimLayer = pAnimStack.GetSrcObject(pFbxCriteria_FbxAnimLayer, 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)
- #DisplayCurve
- #DisplayCurveKeys(pCurve)
- pDisplayCurveKeys=DisplayCurveKeys
- DebugLog(" ?????? pDisplayCurveKeys= "+str(pDisplayCurveKeys))
- #DebugLog(" ?????? pDisplayCurveKeys= "+str(DisplayCurveKeys))
- #DisplayChannels(pNode, pAnimLayer, DisplayCurveKeys, DisplayListCurveKeys, isSwitcher)
- #print
- for lModelCount in range(pNode.GetChildCount()):
- DebugLog("lModelCount loop= "+str(lModelCount))
- DisplayAnimationLayer(pAnimLayer, pNode.GetChild(lModelCount), isSwitcher)
- def DisplayChannels(pNode, pAnimLayer, DisplayCurve, DisplayListCurve, isSwitcher):
- DebugLog("DisplayChannels(pNode ="+str(pNode)+", pAnimLayer="+str(pAnimLayer)+", DisplayCurve="+str(DisplayCurve)+", DisplayListCurve="+str(DisplayListCurve)+", isSwitcher="+str(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:
- DebugLog(" TX")
- DisplayCurve(lAnimCurve)
- lAnimCurve = pNode.LclTranslation.GetCurve(pAnimLayer, KFCURVENODE_T_Y)
- if lAnimCurve:
- DebugLog(" TY")
- DisplayCurve(lAnimCurve)
- lAnimCurve = pNode.LclTranslation.GetCurve(pAnimLayer, KFCURVENODE_T_Z)
- if lAnimCurve:
- DebugLog(" TZ")
- DisplayCurve(lAnimCurve)
- lAnimCurve = pNode.LclRotation.GetCurve(pAnimLayer, KFCURVENODE_R_X)
- if lAnimCurve:
- DebugLog(" RX")
- DisplayCurve(lAnimCurve)
- lAnimCurve = pNode.LclRotation.GetCurve(pAnimLayer, KFCURVENODE_R_Y)
- if lAnimCurve:
- DebugLog(" RY")
- DisplayCurve(lAnimCurve)
- lAnimCurve = pNode.LclRotation.GetCurve(pAnimLayer, KFCURVENODE_R_Z)
- if lAnimCurve:
- DebugLog(" RZ")
- DisplayCurve(lAnimCurve)
- lAnimCurve = pNode.LclScaling.GetCurve(pAnimLayer, KFCURVENODE_S_X)
- if lAnimCurve:
- DebugLog(" SX")
- DisplayCurve(lAnimCurve)
- lAnimCurve = pNode.LclScaling.GetCurve(pAnimLayer, KFCURVENODE_S_Y)
- if lAnimCurve:
- DebugLog(" SY")
- DisplayCurve(lAnimCurve)
- lAnimCurve = pNode.LclScaling.GetCurve(pAnimLayer, KFCURVENODE_S_Z)
- if lAnimCurve:
- DebugLog(" SZ")
- 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:
- DebugLog(" Red")
- DisplayCurve(lAnimCurve)
- lAnimCurve = lNodeAttribute.Color.GetCurve(pAnimLayer, KFCURVENODE_COLOR_GREEN)
- if lAnimCurve:
- DebugLog(" Green")
- DisplayCurve(lAnimCurve)
- lAnimCurve = lNodeAttribute.Color.GetCurve(pAnimLayer, KFCURVENODE_COLOR_BLUE)
- if lAnimCurve:
- DebugLog(" Blue")
- DisplayCurve(lAnimCurve)
- # Display curves specific to a light.
- light = pNode.GetLight()
- if light:
- lAnimCurve = light.Intensity.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Intensity")
- DisplayCurve(lAnimCurve)
- lAnimCurve = light.OuterAngle.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Cone Angle")
- DisplayCurve(lAnimCurve)
- lAnimCurve = light.Fog.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Fog")
- DisplayCurve(lAnimCurve)
- # Display curves specific to a camera.
- camera = pNode.GetCamera()
- if camera:
- lAnimCurve = camera.FieldOfView.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Field of View")
- DisplayCurve(lAnimCurve)
- lAnimCurve = camera.FieldOfViewX.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Field of View X")
- DisplayCurve(lAnimCurve)
- lAnimCurve = camera.FieldOfViewY.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Field of View Y")
- DisplayCurve(lAnimCurve)
- lAnimCurve = camera.OpticalCenterX.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Optical Center X")
- DisplayCurve(lAnimCurve)
- lAnimCurve = camera.OpticalCenterY.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Optical Center Y")
- DisplayCurve(lAnimCurve)
- lAnimCurve = camera.Roll.GetCurve(pAnimLayer)
- if lAnimCurve:
- DebugLog(" Roll")
- 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:
- DebugLog(" Shape %s" % lChannelName)
- DisplayCurve(lAnimCurve)
- """
- # Display curves specific to properties
- lProperty = pNode.GetFirstProperty()
- GoWhileLoop=lProperty.IsValid()
- DebugLog("lProperty.IsValid()==GoWhileLoop=="+str(GoWhileLoop))
- while GoWhileLoop:
- #DebugLog("GO While Loop")
- #"""
- 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 = " 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 = " 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(" Component ", lComponentName1)
- DisplayCurve(lAnimCurve)
- for c in range(lCurveNode.GetCurveCount(1)):
- lAnimCurve = lCurveNode.GetCurve(1, c)
- if lAnimCurve:
- DisplayString(" Component ", lComponentName2)
- DisplayCurve(lAnimCurve)
- for c in range(lCurveNode.GetCurveCount(2)):
- lAnimCurve = lCurveNode.GetCurve(2, c)
- if lAnimCurve:
- DisplayString(" Component ", lComponentName3)
- DisplayCurve(lAnimCurve)
- elif lDataType.GetType() == eFbxEnum:
- lMessage = " 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)
- GoWhileLoop=lProperty.IsValid()
- #while Loop END Indent.
- 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)
- lKeyTimeStr=lKeyTime.GetTimeString(lTimeString)
- #FbxProperty
- #lKeyValueStr=pProperty.GetEnumValue(lKeyValue)
- lOutputString = " Key Time: "
- #lOutputString += lKeyTime.GetTimeString(lTimeString)
- lOutputString += str(KeyTimeStr)
- lOutputString += ".... Key Value: "
- lOutputString += str(lKeyValueStr)
- 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 DisplayCurveKeys_pProperty(pCurve,pProperty):
- 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)
- lKeyTimeStr=lKeyTime.GetTimeString(lTimeString)
- #FbxProperty
- lKeyValueStr=pProperty.GetEnumValue(lKeyValue)
- lOutputString = " Key Time: "
- #lOutputString += lKeyTime.GetTimeString(lTimeString)
- lOutputString += str(KeyTimeStr)
- lOutputString += ".... Key Value: "
- lOutputString += str(lKeyValueStr)
- 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 = " Default Value: "
- lOutputString += pCurve.GetValue()
- print(lOutputString)
- def DisplayListCurveKeys(pCurve, pProperty):
- print ("===606=============DisplayListCurveKeys(pCurve"+str(pCurve)+", pProperty="+str(pProperty)+")=================")
- lKeyCount = pCurve.KeyGetCount()
- print ("===608=============lKeyCount="+str(lKeyCount)+"=================")
- for lCount in range(lKeyCount):
- lOutputString = " Key Time: "
- lKeyValue = int(pCurve.KeyGetValue(lCount))
- lKeyTime = pCurve.KeyGetTime(lCount)
- #lKeyTimeString
- #lKeyValue = static_cast<int>(pCurve.KeyGetValue(lCount))
- lOutputString = " Key Time: "
- #lOutputString += str(lKeyTime.GetTimeString(lTimeString))
- lOutputString += str(lKeyTime)
- lOutputString += ".... Key Value: "
- lOutputString +=str( lKeyValue)
- lOutputString += " ("
- lOutputString += str(pProperty.GetEnumValue(lKeyValue))
- lOutputString += ")"
- print(lOutputString)
- def DisplayListCurveDefault(pCurve, pProperty):
- DisplayCurveDefault(pCurve)
- #===========================引用 D:\work\FBXSDK\FBX\FBX Python SDK\2016.1.1\samples\ImportScene\DisplayAnimation.py
- #===================GetKeyCurve=========================
- class FBXData() :
- def DebugLog(strData):
- mystr=strData
- print(mystr)
- def FBXData(self):
- print ("==========================FBXData()=========================================")
- def loadFile(self, filename) :
- self.filename = filename
- self.root = None
- self.load()
- def load(self) :
- print ("loading ... self.filename= "+self.filename)
- #print "loading : %s"%self.filename
- manager = FbxManager.Create()
- ios = FbxIOSettings.Create(manager, IOSROOT)
- manager.SetIOSettings(ios)
- importer = FbxImporter.Create(manager, "")
- fbxImportSuccesBool=importer.Initialize(self.filename, -1, manager.GetIOSettings())
- DebugLog("fbxImportSuccesBool="+str(fbxImportSuccesBool))
- if not fbxImportSuccesBool:
- print ("==============Failed to load file.=============="+self.filename)
- return
- scene = FbxScene.Create(manager, "MyScene")
- importer.Import(scene)
- #importer.Initialize()
- fbxRoot = scene.GetRootNode()
- self.root = Node(fbxRoot.GetName(), None)
- getHierarchy(fbxRoot, self.root)
- #GetMesh(self.root)
- GetKeyCurve(importer,scene)
- print ("==============Succeeded to load file.========="+self.filename)
- print ("==============Destroy All=========")
- importer.Destroy()
- manager.Destroy()
- #//////////////////////////////////////////////////////////////////////////////////////////////////
- #//////////////////////////////////// Class Unit Test /////////////////////////////////////////////
- #//////////////////////////////////////////////////////////////////////////////////////////////////
- def getClassName(self):
- DebugLog( u"className= " + self.__class__.__name__)
- return self.__class__.__name__
- Instance = FBXData() # Class export instance.
- DebugLog(" FBXData Class __name__="+__name__)
- if(__name__ == Instance.getClassName()):
- fileWrite(FullPass_DustDataTextFile_TXT,"none...")
- DebugLog (u"__name__==self.__class__.__name__ Same!! File Test")
- DebugLog (u"=============Simple Single Class Unit Test Start==========")
- Instance.FBXData() #Call Method
- Instance.loadFile("Solder_Model_FBX_ASCII_2016_2017_settings_.fbx")
- elif(__name__ == "fbxsdk00450class"):
- DebugLog (u"=============Simple Single Class Unit Test Start=====fbxsdk00300class=====")
- Instance.FBXData() #Call Method
- Instance.loadFile(FBX_FILE_PATH_AND_NAME_AND_EXT)
- else:
- DebugLog (u"__name__!=self.__class__.__name__ Othor File Import")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement