Skin tools question

I’ve finally started working on creating my own skinning tools, as Rob has suggested so many times, but i’ve run into a problem with what i want to do with one of the tools.

My basic idea is a mirror skin weights from one vert (or vert array) to another, but I haven’t been able to come up with a decent way to get the selected verts into a variable.

Currently I have to select the 2 verts, then run a script that gets the number of verts in the mesh,then for every vert check to see if it’s selected. if it is, put it into a variable. from there it’s dead easy to compare the bone names and weights and copy the weights to the correct bones. The problem being that in a model with 4000+ verts that operation takes a bit more time than i’d like.

Is there a way to just select one vert or series of verts, then a target series of verts and get the vert indices without having to check each and every vert in the mesh?

thanks!

-ian

it sounds like you want to put each selected vert into an array. are you using Max or Maya?

I wondered that too. For maya,

ls -sl

would do that (return an array with just the two selected vertices in it).

[QUOTE=I,Davis;9853]Is there a way to just select one vert or series of verts, then a target series of verts and get the vert indices without having to check each and every vert in the mesh?[/QUOTE]

I assume you’re using Max because the skinOps module doesn’t have that ability. IIRC you need to loop like ‘for i in 1 to skinOps.getNumVerts myGeo do ( if skinOps.isVertSelected myGeo i then (append selVerts i))’

Obviously you should have a helper library of skin methods- I think I wrapped almost every single skinOps method into a bioSkinOps method and augmented it with stuff that works. I generally haven’t noticed too bad performance with Max skin scripting interface, relatively- you just have to cache and code pretty aggressively, to make sure you’re not re-evaluating what doesn’t need to be (if you structure your code well you shouldn’t need to).

“it sounds like you want to put each selected vert into an array. are you using Max or Maya?”

I’m using max, and that is exactly what I’d like to do. I know the listener can do it, as it spit out the exact vert number that is selected when the vert is selected. I was just hoping that there was a way to do it with meshOps, polyOps or skinOps. so far I’ve not found one.

Rob, that particular loop is what I’m currently using to find what selection I have. I was just hoping there was a different, faster way to put the selected verts into a variable.

I’m not familiar with how to cache with maxscript, and my code-fu is pretty weak right now, so creating a library of skin methods might be my homework for the next week. I understand the general premises, but the actual methods are beyond me, at the moment.

How do you cache with maxScript anyway? I imagine a cache file somewhere, but then you have to run the script to access that file, read it, and spit back the selection, which seems like it’ll take just as long, if not longer, than a skinOps.isVertSelected loop over the entire mesh. Would you mind pointing me in the right direction?

thanks for the help guys!

-ian

By ‘cache’ I meant just store in a local variable, and pass it around to methods if needed (rather than each method that needs to know selected verts having to calculate it by itself).

And that’s a perfect example of where having your code structured correctly comes into play. Basically, the only stuff that should ever CARE about ‘selected’ or ‘not selected’ is the most high-level calling code. All the actual implementation work should just operate on some vert IDs passed in. I can count on one hand the number of library methods I’ve written that work on a selection- you should always be writing your workhorse methods just operate on whatever is passed to them. Which means you’ll only need to calculate something like what’s selected just once for each command- which is plenty fast, I’ve found.

[QUOTE=Rob Galanakis;9862]‘for i in 1 to skinOps.getNumVerts myGeo do ( if skinOps.isVertSelected myGeo i then (append selVerts i))’[/QUOTE]

A colleague of mine told me to avoid using any “.getNumber*” from skinOps/polyOps/etc in for loops, because they are actually loops themselves and if you need to use that value on another place you won’t need to call a “getNumber” loop again if the value is cached in a variable. The code gets a bit uglier, but it makes sense. Unless you are certain you are going to use it only on one place, of course.

I’m not sure on this one, but isn’t faster to use bitarrays instead of arrays to select vertices? On the quoted example, it could be easily switched to bitarrays with ‘selVertsBitArray[i]=true’ instead of the append.

And lastly, take care when using modPanel.setCurrentObject skinMod. I was going insane yesterday because skinOps.getNumVerts obj.skin was returning another meshe’s vertices that was modPanelled before.