How to create random cubes , this we can use in many ways for environments in minutes
proc createRandomCubes(){
string $cube[],$cubes[];
int $signalp,$signala;
float $randX,$randZ,$alpha,$point1[],$point2[];
$radius=1.5;
$randX=rand(-12,12);
$randZ=rand(-12,12);
$cube=`polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
for($i=0;$i<50;$i++){
$randX=rand(-12,12);
$randZ=rand(-12,12);
$cubes=`ls -tr "pCube*"`;
$alpha =1;//signal to decide the new position is outside alpha map ///////
$signalp=1;//signal to decide the new position is outside everybodys boundry..////
for($j=0;$j
$point1=`xform -q -t $cubes[$j]`;
$point2[0]=$randX;
$point2[1]=0;
$point2[2]=$randZ;
if(distanceBetween($point1,$point2)<$radius){
float $u = `getAttr pPlane1Follicle5050.parameterU`;
float $v = `getAttr pPlane1Follicle5050.parameterV`;
float $alpha[] = `colorAtPoint -o A -u $u -v $v map01`;
if ($alpha[0]==1){
$alpha[0]=0;
$signalp=0;
}
}
}//end $j
if($signalp==1){
$cube=`polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
move -a $randX 0 $randZ $cube;
}
}
}
proc float distanceBetween(float $point1[],float $point2[]){
$a=(($point1[0]-$point2[0])*($point1[0]-$point2[0]))+(($point1[1]-$point2[1])*($point1[1]-$point2[1]))+(($point1[2]-$point2[2])*($point1[2]-$point2[2]));
$b=`sqrt $a`;
return $b;
}
createRandomCubes;
No comments:
Post a Comment