Home Coding, Scripting, Shaders

Autodesk 3DS Max: Get vertex indices from connected bone in skin modifier?

polycounter lvl 6
Offline / Send Message
MrQuetch polycounter lvl 6
Hello.

I've been looking around for an answer to my problem. Although, I have found similar problems, I have not found ones with the right answers for my specific needs. What I would like to do, is get vertex indices from a connected bone in a skin modifier. All I need to check is if the vertex weight is equal to one ( connected to this bone ) or equal to zero ( not connected to this bone ). Also, is there a way I can print a hierarchy of the bones like a tree in a text file? I think that would be helpful in seeing if the right vertex indices are "connected" to the right bones.

Any help is greatly appreciated. Thank you.

Replies

  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    I'm not a skin expert but this will return all verts which are just using a particular bone

    <div>(</div>-- collect all the vert only influenced by a particular bone&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; fn CollectAllVertsOnlyInfluencedByBone skin_mod bone_index =<br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; num_verts = skinOps.GetNumberVertices skin_mod;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for v = 1 to num_verts&nbsp; where skinOps.GetVertexWeightCount skin_mod v == 1 and <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; skinOps.GetVertexWeightBoneID skin_mod v 1 == bone_index collect v;<br>&nbsp;&nbsp;&nbsp; )&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; select $Cylinder01;<br>&nbsp;&nbsp;&nbsp; setCommandPanelTaskMode mode:#modify; -- need to be selected and in modify<br>&nbsp;&nbsp;&nbsp; skin_mod = $Cylinder01.modifiers[#Skin];&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; verts_connected_to_bone = CollectAllVertsOnlyInfluencedByBone skin_mod 2 as bitarray;<br>)<br>

  • MrQuetch
    Options
    Offline / Send Message
    MrQuetch polycounter lvl 6
    Klunk said:
    I'm not a skin expert but this will return all verts which are just using a particular bone

    <div>(</div>-- collect all the vert only influenced by a particular bone&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; fn CollectAllVertsOnlyInfluencedByBone skin_mod bone_index =<br>&nbsp;&nbsp;&nbsp; (<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; num_verts = skinOps.GetNumberVertices skin_mod;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for v = 1 to num_verts&nbsp; where skinOps.GetVertexWeightCount skin_mod v == 1 and <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; skinOps.GetVertexWeightBoneID skin_mod v 1 == bone_index collect v;<br>&nbsp;&nbsp;&nbsp; )&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; select $Cylinder01;<br>&nbsp;&nbsp;&nbsp; setCommandPanelTaskMode mode:#modify; -- need to be selected and in modify<br>&nbsp;&nbsp;&nbsp; skin_mod = $Cylinder01.modifiers[#Skin];&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; verts_connected_to_bone = CollectAllVertsOnlyInfluencedByBone skin_mod 2 as bitarray;<br>)<br>

    Hi, Klunk.

    Thank you for the code. So, it appears to be working right now. I also edited the code to create a new script to write out the contents of the vertices connected to the bone. However, it's only printing it out the short version of an array - with three periods separating the first element from the last. Is there a way I can print out each bone name, and the vertices on that bone?

    Here's how the code looks now - with my two additions:

    (-- collect all the vert only influenced by a particular bone  
        
        fn CollectAllVertsOnlyInfluencedByBone skin_mod bone_index =
        (
            num_verts = skinOps.GetNumberVertices skin_mod;
            for v = 1 to num_verts  where skinOps.GetVertexWeightCount skin_mod v == 1 and 
                skinOps.GetVertexWeightBoneID skin_mod v 1 == bone_index collect v;
        )    
    	
        fStream = newScript()
    	
        select $Cylinder01;
        setCommandPanelTaskMode mode:#modify; -- need to be selected and in modify
        skin_mod = $Cylinder01.modifiers[#Skin];    
        verts_connected_to_bone = CollectAllVertsOnlyInfluencedByBone skin_mod 2 as bitarray;
    	
    	format "% \n" (verts_connected_to_bone) to:fStream
    )

    Edit: I figured out that the second parameter of your bone function is what bone is being referenced. You wouldn't happen to know anything about printing a sort of tree of what bones are connected to which, would you?

    Edit2: Is it possible get get any vertices that aren't applied directly to the skin, but are still present in the model itself?
Sign In or Register to comment.