Etape 5

Utiliser le script suivant pour trouver pour chaque feuille le joint le plus proche et la "parenter"

string $command,$list_loc[] = `ls -sl`;

float $position_leaf[3],$position_trunk[3],$dist,$distance_small;

int $l,$j,$joint_sup,$plus_petit_id,$exist=1,$max_leaf = size($list_loc);

vector $toto;

for ($l = 0 ; $l < $max_leaf ; ++$l)

{

$command = "$position_leaf = `xform -q -ws -t leaf__"+$l+"`"; eval $command;

$distance_small=1e900000;

for ($j = 0 ; $exist != 0 ; ++$j)

{

$command = "$position_trunk = `xform -q -ws -t trunk_"+$j+"`"; eval $command;

$toto = <<$position_leaf[0]-$position_trunk[0] , $position_leaf[1]-$position_trunk[1] , $position_leaf[2]-$position_trunk[2] >>;

$dist = mag ($toto);

if ( $dist < $distance_small)

{

$distance_small = $dist; $plus_petit_id = $j;

}

$joint_sup = $j +1 ;

select -cl ;

$command = "$exist = `joint -ex trunk_"+$joint_sup+"`"; eval $command;

}

$exist = 1;

$command = "select -r leaf__"+$l ; eval $command;

$command = "select -tgl trunk_"+$plus_petit_id; eval $command;

parent;

}