Notifications
Clear all
[Closed] Vertices of a Bone
Sep 15, 2009 10:38 am
I have a simple question. How do I get access to the Vertices, that are influenced by a Bone (in a standart Biped-Skin-setting) with the help of maxscript? My “solution” does not work properly, more precisely to many Vertices are selected.
What I have done so far:
- I create an array of all the bones
- for every bone I loop over ALL vertices
- for every vertex, I find the bones, which affect the specified vertex
- loop over those Bones and find their names (with the help of the systemBoneNumber)
- if the name is the same as my “outer loop bone”, append the Vertex in an array
for i=1 to boneNameArray.count do
(
for j = 1 to (skinOps.GetNumberVertices skinMod) do
(
for k = 1 to (skinOps.GetVertexWeightCount skinMod j) do
(
boneID = (skinOps.GetVertexWeightBoneID skinMod j k)
boneName = (skinOps.GetBoneName skinMod boneID 1)
if (boneNameArray[i] == boneName) then
(
appendIfUnique vertexArrayAllBones[i] j
)
)
)
)
Has anyone an idea, why this code could select more vertices, than are actually influenced by the bone? Is there a more simple solution?
Thanks in advise,
Daniel
2 Replies
Sep 15, 2009 10:38 am
here is a function how to get verts by skin bone id:
fn getVertsByBone boneID: sk: =
(
if sk == unsupplied do sk = modpanel.getCurrentObject()
if iskindof sk Skin do
(
vlist = #{}
if boneID == unsupplied do boneID = skinops.getSelectedBone sk
for k=1 to (skinops.getNumberVertices sk) do
(
for b=1 to (skinops.getVertexWeightCount sk k) while not vlist[k]
where boneID == (skinops.getVertexWeightBoneID sk k b) do append vlist k
)
vlist
)
)
Sep 15, 2009 10:38 am
Thank you very much denisT for the fast reply. It seems that my code did the right thing in a not so elegant way… I learnt a lot from your code, especially working with optional function parameters and bitArrays.
Kind regards,
Daniel