PDA

View Full Version : scaled parents, what is the final scale of a child?


alredha
04-01-2006, 09:32 AM
hi everybody!

i've got a couple of questions about commands in mel,
- how can i have the absolute scale of a grouped object? i mean if the root is scaled up 5 X and its child scaled up 2 X, so the the child of the child would logically have 10 X! it's the case if i parent it back to world! but let's say we don't know the hierarchical position of the object, is there a command or tag for Xform to know the "final Scale" of an object? or should i go across its ascending and multiply thier scales? so! if i use the second solution, what is the command for it?

tciny
04-01-2006, 10:35 AM
You can query the worldMatrix for an object. But theres translation/rotation/scaling/shearing in it and you cant just pick out the scaling factor.
What you could do is (doesnt work if you use shearing): is take a point 0,0,0 and multiply it with the matrix and then do the same for, lets say 1,1,1. Then measure the distance between the two and see by what factor it changed. But then again, that of course only works for uniform scaling (all axes having the same scale factor).

So if you want an accurate solution you'll propably have to iterate over the hierarchy, querying the scale attributes and multiplying them as you go.

alredha
04-01-2006, 03:10 PM
So if you want an accurate solution you'll propably have to iterate over the hierarchy, querying the scale attributes and multiplying them as you go.

yes, i think that's the only way to have the result! but do you know the appropriate command to go across an object's ascending?

tciny
04-01-2006, 03:51 PM
Keep in mind: If you rotate an object and the axes then align differently your result wont consider that...

global proc vector getZehScaling( string $objectname )
{
vector $curScale, $totalScale;
string $foo[];
$totalScale = <<1,1,1>>;
while( $objectname != "" )
{
$curScale = `getAttr ($objectname+".scale")`;
$totalScale = <<$totalScale.x*$curScale.x, $totalScale.y*$curScale.y, $totalScale.z*$curScale.z >>;
$foo = `listRelatives -parent $objectname`;
$objectname = $foo[0];
}
return $totalScale;
}

polyCube; scale -a 2 2 3;
polyCube; scale -a 5 1 5; parent -r pCube2 pCube1;
polyCube; scale -a 0.2 4 0.2; parent -r pCube3 pCube2;
getZehScaling( "pCube3" );

You can call getZehScaling with any given object name and it'll return the scaling. This only causes problems when you're having multiple DAG hierarchies because of instancing. In that case the solution for the first path will be returned.

CGTalk Moderation
04-01-2006, 03:51 PM
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.