Scripting 从骨骼名称或MaxScript中的皮肤索引列表获取骨骼ID
我有一个骨骼名称(例如,Scripting 从骨骼名称或MaxScript中的皮肤索引列表获取骨骼ID,scripting,3dsmax,maxscript,Scripting,3dsmax,Maxscript,我有一个骨骼名称(例如,Bone002),我想获取它的骨骼ID(不是皮肤列表中的索引,而是所需的ID,例如,skinOps.SetVertexWeights) 我知道反向操作是这样的: skinMod = $.modifiers[#skin] boneListIndex = (skinOps.GetVertexWeightBoneID skinMod v w) local boneName = skinOps.GetBoneNameByListID skinMod boneListIndex 0
Bone002
),我想获取它的骨骼ID(不是皮肤列表中的索引,而是所需的ID,例如,skinOps.SetVertexWeights
)
我知道反向操作是这样的:
skinMod = $.modifiers[#skin]
boneListIndex = (skinOps.GetVertexWeightBoneID skinMod v w)
local boneName = skinOps.GetBoneNameByListID skinMod boneListIndex 0
但是如何获得boneID呢?我已经有了boneListIndex
和boneName
我假设所有骨骼都有唯一的名称。您使用的是什么版本的3dsMax?我记得这里的文档相当混乱。在本例中,Bone_ID和vertex_Bone_integer是可互换的-我刚刚在一个简单的网格上进行了测试,SkinOps.GetVertexWeightBoneID和SkinOps.SetVertexWeights使用相同的骨骼索引 如果要按名称定位,则需要按名称匹配索引。使用骨骼名称创建一个数组:
boneNames = for i=1 to (skinOps.GetNumberBones skinMod) collect (skinOps.GetBoneName skinMod i 0)
然后,您可以使用自己喜欢的搜索方法检索索引,一个简单的findItem在这里工作得很好:
boneIndex = findItem boneNames "Bone002"
请记住,skinOps.GetBoneName函数有点缺陷;最后一个参数用于确定是否返回实际节点或其名称-无论设置如何,只返回名称字符串。这意味着,如果蒙皮中有两块同名的骨骼,则必须找到一种巧妙的方法来获取相应的节点