是否可以从枚举ENodeId中获取关联的FbxNode
?
例如,如果我想从Character::eLeftHand
获取FbxNode
我尝试使用Character::GetCharacterLink(ENodeId, FbxCharacterLink)
然后只需通过调用FbxCharacterLink
从FbxCharacterLink::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))