[Closed] Simpler method of skinning?
Oh wise ones :wise: , I hope you can answer this question for me:
Currently, to skin a cylinder to a bone I do this:
select Cylinder01
modPanel.addModToSelection (Skin ()) ui:on
skinOps.addBone $.modifiers[#Skin] Bone01 1
I’m not sure why though – I think a combination of watching the Listener and decoding the Help files. Anyway, I usually have about 11 bones and 11 objects to skin to the bones, and this creates a real bottleneck in the code when executing – without skinning the code is finished running before you can even blink; with skinning, it takes a few seconds!!
Anyone know of a neater way to skin to bones?
Again. apologies if this is a completely easy question – if it is, can anyone suggest a better way to search for the answer?
Cheers
Tim
I wasn’t thinking easier, just a simpler method – it seems strange you have to call the rollout first then do the operations, as this seems to slow down execution of the code.
I was thinking something like:
Skin Object01 Bone01
Maybe I’m wishing too much…!!
okay Tim, i think you might be missing the point somewhere.
once you remove the code where you add the modifier, you’re looking at the command
skinOps.addbone <Skin> <bone_node> <update_integer>
compared to your –
skin <skin> <bone_node>
not really a lot in it, is there?
your notation denotes a function call in max, and skinops is actualy a structure of functions written to expose aspects of the skin modifer. This has been done for you so you dont have to write the code yourself. so, on reflection, its not really a lot is it?
anyway, you will find that your slowdown is due to you passing 1 for the update integer , which triggers a complete redraw as each bone is added. if you passed 0 for this variable you would update once at the end, when it has added all the bones.
Three lines isn’t much at all, but is three times as long as I think it need be – why open the rollout before applying the skin modifier? Anyway, not to worry – I get now that it can’t be done any other way!!
I tried changing the integer from 1 to 0 as you suggest, but to no avail – still executes at the same speed. Perhaps it’s the way I loop it, which I’ll show below.
But first, I must emphasise: of course, writing three lines of code is nothing, and a rig building script which takes 2 seconds to run is peanuts when compared with the amount of time it would have taken to build manually, but I just want the script to go faster and faster, and after having id’d the bottleneck I was just wondering if there was a better/simpler/faster method of achieving the same process – obviously not 🙁 !!
Anyway, here’s the loop:
for i = 1 to arrB.count - 1 do
(
select arrC[i]
modPanel.addModToSelection (Skin ()) ui:on
skinOps.addBone $.modifiers[#Skin] arrB[i] 0
)
Where arrC is the array of cylinders and arrB the array of bones I have – I doubt it’s the loop?
Cheers for your help so far!!
Tim
tim,
your loop currently adds a skin modifer with one bone specified, for each bone in your arrB array. You only need to add the mod once – the bone adding is what you are automating in the loop. adjusting your code to this should work –
select arrC[i]
modPanel.addModToSelection (Skin ()) ui:on
for i = 1 to arrB.count-1 do skinOps.addBone $.modifiers[#Skin] arrB[i] 0
this runs in the blink of an eye
I haven’t tried it yet, but are you sure that’ll work?
select arrC
[i]modPanel.addModToSelection (Skin ()) ui:on[/i]
[i]for i = 1 to arrB.count-1 do skinOps.addBone $.modifiers[#Skin] arrB[i] 0[/i]
[i]
[/i]
The first line, for instance, selects an undefined member of arrC (i hasn’t been defined, has it?)
What my loop does is select cylinder 1 and skin it to bone 1, then loops to selecting cylinder 2 and skinning it to bone 2. Wouldn’t your loop skin cylinder arrC[i] (if arrC[i] was defined, of course) to each bone in turn?
I need:
Cyl 1 to skin to Bone 1
Cyl 2 to skin to Bone 2
Cyl 3 to skin to Bone 3
and so on…
Wouldn’t yours:
Cyl 1 to skin to Bone 1
Cyl 1 to skin to Bone 2
Cyl 1 to skin to Bone 3
and so on…
??Apologies if I’ve missed something basic here!!
Cheers for helping,
Tim
The first line, for instance, selects an undefined member of arrC (i hasn’t been defined, has it?)
Hi Tim,
my bad, that’s a typo when i copied and pasted from your post. that should just be the mesh node you are skinning.
my code was to illustrate if you are skinning one mesh to multiple bones. since you didn’t post the code or at the start, I had to assume that this was what you were attempting. as such, your code should work, assuming you have one more bone than objects to skin. you could run it inside with redraw off to speed it up over multiple objects. in your case, the update integer wont make any difference as you’re adding one bone to each and then ending.
so is arrB an array of a bone chain, or of individual bones? since you are skinning a single bone to a single node, all verts will be weighted to a value of 1, leading me to ask why you dont just link it to the bone? :)
arrB is an array of a bone chain – so will linking each Cyl behave in exactly the same manner as if skinning it? I thought it didn’t…