Hi all!
I am developing this in MEL, but the issue should be the same for both languages, any help is very welcome!
I have many skinned meshes for a single character, and I need to turn those into a single one.
My process was extrapolated from a script I found around (that I am not sure who posted, sry about that), but it was meant to make a "skin wrap" > create independent skinning without direct dependencies to source object, I made it work for several objects into a single one.
so my workflow atm is:
- manually select the source objects, duplicate, combine, delete history > clean single object
- select again the source objects, then select my "target" single object
- run the script below which asigns a new skinning that unifies all the bones used in all the individual objects
- select again the source objects, select my target, go to rigginMenu/skin/copy skin weights
and it works. perfectly. one to one weighting on every vertex.
my problem:
if I add the code for the weight copy that shoots up in the log:
copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint;
the result is all the weights are gobbled up, pretty much as if i had not run anything.
if I go and open the copy skin weights details and click "apply", it will also give a result that looks as if i had not done anything (no error prompted)
again, if I just manually click on the "copy skin weights" button, it will work perfectly.. but i want to do this process in tons of animated items.. and any change on the source objects will also mean having to do it again.. so any step that can be avoided will mean a lot of time in the end..
well... if anybody can shoot some light on this, would be much appreciated!
Martin
my code atm, commented the area that should work but.. doesnt.
// select all source objects > add target object to selection > run
proc CopySkinFromMultipleObjects (){
string $joints[];
string $sel[] = `ls -sl`;
string $targetObject = $sel[(size($sel)-1)];
print ("target: "+ $targetObject + "\n\n");
for ($i = 0; $i<size($sel)-1; $i++)
{
string $cluster = `findRelatedSkinCluster $sel[$i]`;
string $newJoints[] = `listConnections -s 1 -d 0 ($cluster + ".matrix")`;
appendStringArray $joints $newJoints (size($newJoints));
}
stringArrayRemoveDuplicates $joints;
for ($j=0; $j < size($joints); $j++){
//print ($joints[$j]+"\n");
}
select -r $targetObject;
select -add $joints;
SmoothBindSkin -tsb -ta;
/*
select -r $sel;
copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint;
select -r $targetObject;
doBakeNonDefHistory( 1, {"prePost" });
*/
}
CopySkinFromMultipleObjects ();