I’ve spend the day skinning characters and banging my head against maxscript and the holes in it.
A while ago I wrote a working skin weights mirror script, where I select a vert, copy it, then select a vert to paste to and it correctly mirrors the bones and weights. However, this is a bit slow, so what I thought was I could select a bunch of verts, where the odd numbered selection was the ‘copy from’ vert, and the even numbers are the ‘paste to’. Then I could loop through the list, copying 1 to 2, 3 to 4, etc.
However, even though the listener can show me my selected vert array, I cannot seem to access this information.
Anyway, I’ve come up with a possible solution, which is a work in progress…I’ll explain it after ranting
Basically, what I want cannot be done – maxscript has holes. The solutions posted on the net, and the suggestions from others are the same as the one I have already – select a vert, then cycle through all the verts in the skin modifier to see if I have got them selected.
This method works for some scripts, but its an ugly hack, since in the maxscript listener it tells me what verts I have selected, so MAX KNOWS! It’s there, in text, on the screen. It’s taunting me.
It’s a brute force search, but this won’t work for my script.
The reason the loop won’t work is that I have to select the verts in order, and store them in array, so I pick the source vert then the target, then another source and another target etc. With this array I copy 1 to 2, 3 to 4, 5 to 6 etc. Using the looping method reorders all the verts.
Now, the vert ids are the same in the skin modifier as they are in the poly/mesh so I thought I’d use those vert selection methods, but guess what – when in skin you can’t use the poly/mesh vert identification methods any more.
Now, my solution to the problem.
I want to be able to mirror whilst the mesh is deforming, so that I can check the mirror has worked.
So, I have 2 buttons in my rollout – Create eMesh and Perform Copy. Create eMesh sticks an edit mesh modifer on the stack above my skin modifier, so I can see all the deformation. I can select my array of pairs of verts here, so thats part one.
I already have working copy and paste functions (with mirror) in my current script, they just take a vert id. The copy function queries the specified vert and extracts all the bone and weighting information. The paste function then applies this information to the specified vert.
So now, after I’ve selected all my weights, I press the ‘Perform Copy’. It stores my vert selection in an array, deletes the mesh modifier and goes back to the skin modifier. Then its just a simple loop – get the information from vert 1, calculate the mirrorbones, paste that to vert number 2. Then 3 to 4, 5 to 6 etc.
But it’d be a lot cleaner if there was just a skinop.getvertselection command.
Technorati Tags: 3d modelling, 3dsmax, bugs, Games Industry, maxscript, Rigging, skin modifier