neonoodle
04-24-2006, 08:42 PM
Hi everyone, I'm having a problem automating the creation of hair collision sphere constraints. I have a bunch of poly spheres that I parent constrained to my character, and I want to create collision sphere constraints based off those spheres and connect the attributes so that the collision spheres follow along with the poly spheres. I have this script to do it:
string $hairCurves[] = `listRelatives -children ($hairSystem + "OutputCurves")`;
string $hairConstraints[] = {};
for($obj in $collisionSpheres) {
select $hairCurves;
createHairConstraint 5;
string $hairConstraint[] = `pickWalk -d up`;
connectAttr -f ($obj + ".translate") ($hairConstraint[0] + ".translate");
connectAttr -f ($obj + ".rotate") ($hairConstraint[0] + ".rotate");
connectAttr -f ($obj + ".scale") ($hairConstraint[0] + ".scale");
$hairConstraint[0] = `rename $hairConstraint[0] ($hairSystem + $obj + "Collision")`;
$hairConstraints[`size($hairConstraints)`] = $hairConstraint[0];
}
The thing is, if I select one sphere to make a collision sphere out of, it works fine and creates the sphere, but if I select multiple spheres, it creates the collision spheres but the dynamic simulation stops working. If I select single spheres manually and run the script, I could create as many of these as I want and the simulation continues to work, but it doesn't for multiple spheres. Why would that be, since in the script I have it set up to operate on individual spheres anyway.
Any help will be appreciated.
string $hairCurves[] = `listRelatives -children ($hairSystem + "OutputCurves")`;
string $hairConstraints[] = {};
for($obj in $collisionSpheres) {
select $hairCurves;
createHairConstraint 5;
string $hairConstraint[] = `pickWalk -d up`;
connectAttr -f ($obj + ".translate") ($hairConstraint[0] + ".translate");
connectAttr -f ($obj + ".rotate") ($hairConstraint[0] + ".rotate");
connectAttr -f ($obj + ".scale") ($hairConstraint[0] + ".scale");
$hairConstraint[0] = `rename $hairConstraint[0] ($hairSystem + $obj + "Collision")`;
$hairConstraints[`size($hairConstraints)`] = $hairConstraint[0];
}
The thing is, if I select one sphere to make a collision sphere out of, it works fine and creates the sphere, but if I select multiple spheres, it creates the collision spheres but the dynamic simulation stops working. If I select single spheres manually and run the script, I could create as many of these as I want and the simulation continues to work, but it doesn't for multiple spheres. Why would that be, since in the script I have it set up to operate on individual spheres anyway.
Any help will be appreciated.
