//STEP 5-2:
//Create subsphere
string $sub_figure = $obj + "_sub_figure";
int $isSphere = false;
createSubFigure($obj, $sub_figure, $isSphere);
//PROC: Main method to create sub object.
global proc createSubFigure(string $mainObj, string $sub_figure, int $isSphere){
string $object = $mainObj + "_sub_obj";
string $sub_obj1 = $mainObj + "_sub_obj1";
string $sub_obj2 = $mainObj + "_sub_obj2";
string $sub_obj3 = $mainObj + "_sub_obj3";
string $cmdFirst = $object + ".f[112:223]";
string $cmdSecond = $object + ".f[240:255]";
vector $temp = getFaceCenter($mainObj, 0);
float $radius = getRadius($mainObj, 0, $temp) - 0.5;
polySphere -r $radius -sx 16 -sy 16 -ax 0 1 0 -tx 1 -ch 1 -n $object;
select -r $cmdFirst $cmdSecond;
delete;
ssph_coverVertex($object, $sub_obj1);
ssph_coverEdge($object, $sub_obj2);
string $cmdThird = $object + ".f[48:111]";
select -r $cmdThird;
delete;
ssph_coverRestFaces($object, $sub_obj3, $isSphere);
delete $object;
select -r $sub_obj1;
select -tgl $sub_obj2;
select -tgl $sub_obj3;
group -n $sub_figure;
}
//PROC: Cover the top part of vertex with spheres
global proc ssph_coverVertex(string $obj, string $sub_obj1){
int $a;
string $mash1[];
for($a=64; $a<128; $a++){
string $cmd = $obj + ".vtx[" + $a + "]";
vector $vector = `pointPosition -w $cmd`;
float $radius = `rand 0.1 0.15`;
string $name[] = `polySphere -r $radius`;
move ($vector.x) ($vector.y) ($vector.z);
$mash1[$a] = $name[0];
}
select -r $mash1[64];
for($a=65; $a<128; $a++){
select -tgl $mash1[$a];
}
string $grpName = $sub_obj1;
group -n $grpName;
}