是否可以从枚举ENodeId中获取关联的FbxNode
例如,如果我想从Character::eLeftHand获取FbxNode

我尝试使用Character::GetCharacterLink(ENodeId, FbxCharacterLink)然后只需通过调用FbxCharacterLinkFbxCharacterLink::mNode中提取FbxNode

但是,对于大多数ENodeIds,此函数返回False,因此不会创建FbxCharacterLink

character = myScene.GetCharacter(0)
lefthand = character.eLeftHand
lefthand_node = FbxCharacterLink()
character.GetCharacterLink(lefthand, lefthand_node) # False
lefthand_node = lefthand_node.mNode

当我使用Python和Pyfbxsdk在Motionbuilder中编写脚本时,这非常容易,无论如何命名骨架对象,我都可以获取它的FBXObject
m = character.GetModel(self.BodyNodeObject[o])

BodyNodeObject生成与
def BodyNodes(self):
    for i in dir(FBBodyNodeId):
        if i[0] == 'k':
            try:
                self.BodyNodeObject[BodyNodesId[i]] = getattr(FBBodyNodeId, i)
            except:
                pass
BodyNodesId仅仅是字典
BodyNodesId = OrderedDict({
        'kFBChestNodeId':'Spine1',
        'kFBHeadNodeId':'Head',
        'kFBHipsNodeId':'Hips',
        'kFBLeftAnkleNodeId':'LeftFoot',
        'kFBLeftCollarNodeId':'LeftShoulder',
        'kFBLeftElbowNodeId':'LeftForeArm',
        ...
})

最佳答案

这对我有用

from fbx import *

for i in range(myscene.GetCharacterCount()):
    character = myscene.GetCharacter(i)
    node = character.eHips
    link = FbxCharacterLink()
    while (character.GetCharacterLink(node, link)):
        print node, link.mNode.GetName()
        node = character.ENodeId(int(node+1))

08-17 03:34