FBX SDK - 从角色的 ENodeId 获取 FbxNode
FBX SDK - Get the FbxNode from an ENodeId of a Character
是否可以从枚举 ENodeId 中获取关联的 FbxNode
?
例如,如果我想从 Character::eLeftHand
获取 FbxNode
我尝试使用 Character::GetCharacterLink(ENodeId, FbxCharacterLink)
然后通过调用 FbxCharacterLink::mNode
从 FbxCharacterLink
中提取 FbxNode
然而这个函数returns对于大多数ENodeIds都是False,所以没有FbxCharacterLink
被创建。
character = myScene.GetCharacter(0)
lefthand = character.eLeftHand
lefthand_node = FbxCharacterLink()
character.GetCharacterLink(lefthand, lefthand_node) # False
lefthand_node = lefthand_node.mNode
当我在 Motionbuilder 中使用 Python 和 Pyfbxsdk
编写脚本时,这非常简单,无论骨架对象如何命名,我都可以获得它的 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))
是否可以从枚举 ENodeId 中获取关联的 FbxNode
?
例如,如果我想从 Character::eLeftHand
我尝试使用 Character::GetCharacterLink(ENodeId, FbxCharacterLink)
然后通过调用 FbxCharacterLink::mNode
FbxCharacterLink
中提取 FbxNode
然而这个函数returns对于大多数ENodeIds都是False,所以没有FbxCharacterLink
被创建。
character = myScene.GetCharacter(0)
lefthand = character.eLeftHand
lefthand_node = FbxCharacterLink()
character.GetCharacterLink(lefthand, lefthand_node) # False
lefthand_node = lefthand_node.mNode
当我在 Motionbuilder 中使用 Python 和 Pyfbxsdk
编写脚本时,这非常简单,无论骨架对象如何命名,我都可以获得它的 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))