Created
January 20, 2013 20:56
-
-
Save jhoolmans/4581681 to your computer and use it in GitHub Desktop.
Orients all tip joints to world. Alternative to orientTipJointsToParent.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Orient tip joint to world | |
{ | |
proc string[] getChildren(string $nodes[]) | |
{ | |
return `listRelatives -f -c $nodes`; | |
} | |
proc int isTip(string $node) | |
{ | |
if (size(getChildren({$node})) > 0) | |
return 0; | |
else | |
return 1; | |
} | |
proc orientTipJointsToWorld(string $nodes[]) | |
{ | |
for($obj in $nodes) | |
{ | |
string $tips[]; | |
// find tip joint | |
string $children[] = getChildren({$obj}); | |
if (size($children) == 0) | |
$tips[0] = $obj; | |
while(size($children) > 0) | |
{ | |
for($child in $children) | |
{ | |
if(isTip($child) == 1) | |
$tips[size($tips)] = $child; | |
} | |
$children = getChildren($children); | |
} | |
for ($tip in $tips) | |
{ | |
string $parent[] = `listRelatives -f -p $tip`; | |
string $tmpTip[] = `parent -w $tip`; | |
setAttr ($tmpTip[0] + ".jointOrientX") 0; | |
setAttr ($tmpTip[0] + ".jointOrientY") 0; | |
setAttr ($tmpTip[0] + ".jointOrientZ") 0; | |
parent $tmpTip $parent; | |
} | |
select -r $tips; | |
} | |
} | |
string $selection[] = `ls -sl -type joint`; | |
orientTipJointsToWorld($selection); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment