Vivek - Technical Artist
Emiting Fluids from Particles
just make this three things (fluid container,particle emitor )
float $pointinfo[] ; int $voxinfo[] ;
$cout = `particle -q -ct particle1`;
for($i=0;$i<$cout;$i++)
{
$pointinfo=`pointPosition -w ("particle1.pt["+$i+"]")`;
$voxinfo = `fluidVoxelInfo -v $pointinfo[0] $pointinfo[1] $pointinfo[2] fluid1`;
if(($voxinfo[0]>0) &&($voxinfo[1]>0)&&($voxinfo[2]>0)&&($voxinfo[0]<24) &&($voxinfo[1]<24)&&($voxinfo[2]<24) )
{setFluidAttr -at density -fv 1.0 -xi $voxinfo[0] -yi $voxinfo[1] -zi $voxinfo[2] fluid1;}}
Random cubes
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;
tank chain
How to create chain in maya for a tank
proc Cmaker(){
if ( `window -exists CMaker` ) {
deleteUI CMaker;
}
$win=`window -t "Chain Maker" -w 258 -h 118 CMaker `;
columnLayout c1;
rowLayout -p c1 -nc 2 -w 250 -cw2 125 125 r1;
button -w 125 -p r1 -l "Sel Curve" -c selCurve slcurv;
button -w 125 -p r1 -l "Sel Chain Hook" -c selObj slhook;
intSliderGrp -l "Copies" -min 10 -max 1000 -fmn 10 -fmx 1000 -p c1 -v 10 -field true -cw3 50 40 10 numC;
button -w 250 -h 40 -p c1 -l "Create Chain" -c DupAlign;
showWindow CMaker;
}
proc selCurve(){
$sel=`ls -sl`;
$shp=`listRelatives -s $sel[0]`;
if((`nodeType $shp[0]`)==("nurbsCurve")){
button -e -l $sel[0] -w 125 slcurv;
}else{
warning "Selected Object is not a curve";
}}
proc selObj(){
$sel=`ls -sl`;
if(size($sel)>0){
button -e -l $sel[0] -w 125 slhook;}else{warning "please something atleast for godsake !!";}
}
proc DupAlign(){
string $curv;
float $offset,$ncopiess,$pos[];
string $obj,$dup[],$joint;
$ncopiess=`intSliderGrp -q -v numC`;
$curv=`button -q -l slcurv`;
$obj=`button -q -l slhook`;
$offset=1/$ncopiess;
select -d;
for($i=0;$i<$ncopiess;$i++){
$pos=`pointOnCurve -pr ($i*$offset) -p $curv`;
$joint=`joint -p $pos[0] $pos[1] $pos[2]`;
$dup=`duplicate -ilf $obj`;
move -a $pos[0] $pos[1] $pos[2] $dup[0];
parent $dup[0] $joint;
}
//ikHandle -sol ikSplineSolver -ccv false;
}
Cmaker;
Creating a wave
Creating a wave in one clilck by making own interface
//interface
if (`window -ex waveInterface`) {deleteUI -window waveInterface;}
window -title "My First Wave" -w 450 -h 300 waveInterface;
columnLayout;
floatSliderGrp -l "Width" -f 1 -min 5 -max 100.0 -fmn 5.0 -fmx 20.0 -v 10 waveWidth;
floatSliderGrp -l "Height" -f 1 -min 5 -max 100.0 -fmn 5.0 -fmx 20.0 -v 10 waveHeight;
floatSliderGrp -l "Frequency" -f 1 -min 0 -max 3.0 -fmn 0 -fmx 1.0 -v 1 waveFreq;
floatSliderGrp -l "Magnitude" -f 1 -min 0 -max 0.5 -fmn 0 -fmx 0.5 -v 0.05 -pre 2 -ss 0.01 waveMag;
floatSliderGrp -l "Conserve" -f 1 -min 0 -max 1 -fmn 0.9 -fmx 1.0 -v 0.95 -pre 2 -ss 0.01 waveConsv;
button -l "Create Wave !!" -w 450 -bgc 0.7 0.8 0.6 -c myWave;
showWindow waveInterface;
//----------------------------------------
proc myWave(){
//declaration
string $pPlane[],$softParticle[],$turb[];
float $widthW,$heightW,$freq,$mag,$conserveW;
//initialize
//----------------------------------------
$widthW=`floatSliderGrp -q -v waveWidth`;
$heightW=`floatSliderGrp -q -v waveHeight`;
$freq=`floatSliderGrp -q -v waveFreq`;
$mag=`floatSliderGrp -q -v waveMag`;
$conserveW=`floatSliderGrp -q -v waveConsv`;
//----------------------------------------
//operation
$pPlane=`polyPlane -w 1 -h 1 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1`;
setAttr ($pPlane[1]+".width") $widthW;
setAttr ($pPlane[1]+".height") $heightW;
setAttr ($pPlane[1]+".subdivisionsWidth") 30;
setAttr ($pPlane[1]+".subdivisionsHeight") 30;
$softParticle=`soft -c `;
select -r $softParticle[0];
$turb=`turbulence -pos 0 0 0 -m $mag -att 0 -f $freq -phaseX 0 -phaseY 0 -phaseZ 0 -noiseLevel 0 -noiseRatio 0.707 -mxd -1 -vsh none -vex 0 -vof 0 0 0 -vsw 360 -tsr 0.5 `;
connectDynamic -f $turb[0] $softParticle[0];
expression -s ($turb[0]+".phaseZ=time;") -o $turb[0] -ae 1 -uc all ;
setAttr ($turb[0]+".magnitude") .05;
select -r $softParticle[0];
particle -e -c $conserveW $softParticle[0];
select -r $pPlane[0] $turb[0];
group -n "myWave";}
How to find the tringles in your mesh for modification
int $numFacee[],$vtxNum;
string $vtxInfoo[],$vtxArr[],$objF,$sel[];
$sel=`ls -sl`;
$numFacee=`polyEvaluate -f $sel[0]`;
select -cl ;
for($i=0;$i<$numFacee[0];$i++){
$objF=$sel[0]+".f["+$i+"]";
$vtxInfoo=`polyInfo -fv $objF`;
$vtxArr=stringToStringArray($vtxInfoo[0]," ");
$vtxNum=size($vtxArr)-3;
if($vtxNum==3){
select -tgl $objF;
}
}