Skip to content

Instantly share code, notes, and snippets.

@jhoolmans
Created January 20, 2013 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhoolmans/4581681 to your computer and use it in GitHub Desktop.
Save jhoolmans/4581681 to your computer and use it in GitHub Desktop.
Orients all tip joints to world. Alternative to orientTipJointsToParent.
// 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