PDA

View Full Version : Finding Primary Axis of joint


doffer
11-01-2012, 12:18 PM
Hi guys

I'm trying to make a script which will set up some stretchy arm stuff, by scaling the joints. The usual stuff.

But the joints are created by the user, and I need to know which axis to scale in. That is, which axis points down the length of the joint, or what I assume would be the "primary axis".
I looked through the manual, but I couldn't find anything to query.

Anybody knows how to do that? I bet it is simple and right in front of my nose, as usual :D

ericCunha
11-01-2012, 05:14 PM
I had to do this recently and wasn't able to come up with too great of a solution so I ended up just checking a child joint to see which axis had translations (since only the primary axis should). Hope this helps!

string $root[] = `ls -sl`;
string $child[] = `listRelatives -c $root[0]`;
float $trans[] = `xform -q -t $child[0]`;
for ($i=0;$i<3;$i++)
{
if ($i == 0 && $trans[$i] > 0) print "The primary axis is X";
else if ($i == 1 && $trans[$i] > 0) print "The primary axis is Y";
else if ($i == 2 && $trans[$i] > 0) print "The primary axis is Z";
}

floid parkins
11-01-2012, 05:29 PM
Look at the child joints translation channels. Whatever axis has a value that is what you want to scale.

doffer
11-05-2012, 08:44 AM
Ahh of course! :)

Thanks a lot guys. That will do the trick.

CGTalk Moderation
11-05-2012, 08:44 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.