-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrescale.mel
More file actions
44 lines (39 loc) · 1.19 KB
/
rescale.mel
File metadata and controls
44 lines (39 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//v0.1a
// recursive
global proc string[] doRescale(
string $sel,
float $scale[],
float $shear[]
){
// starts from child, get its world scale value
string $ls_chld[1];
float $ws_scale[3];
print {"> " + $sel};
$ls_chld = `listRelatives -c -f -type transform $sel`;
string $items[] = {$sel};
for ($ch in $ls_chld)
$items = stringArrayCatenate(
$items,
doRescale($ch, $scale, $shear));
$ws_scale = `xform -q -ws -s $sel`;
$rescale = {$scale[0]/$ws_scale[0],
$scale[1]/$ws_scale[1],
$scale[2]/$ws_scale[2]};
// scale -pcp $ws_scale[0] $ws_scale[1] $ws_scale[2] $sel;
scale -pcp $rescale[0] $rescale[1] $rescale[2] $sel;
setAttr ($sel + ".sh") $shear[0] $shear[1] $shear[2];
print {": " + $sel};
return $items;
}
global proc rescale(){
// select roots // different groups
string $unscale[];
float $scale[3] = {1, 1, 1};
float $shear[3] = {0, 0, 0};
$lssl = `ls -sl`;
for ($root in $lssl){
$unscale = doRescale($root, $scale, $shear);
for ($un in $unscale)
scale -pcp $scale[0] $scale[1] $scale[2] $un;
}
}