//Daniele Tosti - studiolito@3dtreat.com //Tested with Maya 3.01 //Change at will and let me know if you have any suggestions. // // //Run this to set the radiusPP of your particles depending on the distance from the camera. // //1-Make sure you replace correctly the name of the particle in your scene in the $partCloudName string. //2-You can fine tune the radius limits through the $NewRadiusPP float. //Just remember that LINSTEP returns a floating point value between zero and one representing //what percentage of the distance between the first and second arguments is represented by the third argument. //The second argument is farthest distance between the particles and your camera. proc RPPCD () { string $partCloudName = "particle1"; int $partSize = `particle -count -q $partCloudName`; print ($partSize+" "); int $partID; for ($partID = 0; $partID < $partSize; $partID++) { print ($partID+" "); float $partPos[3] = `particle -attribute position -id $partID -q $partCloudName`; string $distNNode = `createNode distanceBetween`; setAttr distanceBetween1.point1 ($partPos[0]) ($partPos[1]) ($partPos[2]); connectAttr -f persp.translate distanceBetween1.point2; float $DistFromCamera = `getAttr distanceBetween1.distance`; float $NewRadiusPP = 5*(1.75+linstep (0,130,$DistFromCamera)); select -cl; select ($partCloudName+".pt["+$partID+"]"); setParticleAttr -at radiusPP -fv $NewRadiusPP; print ("distance " + $DistFromCamera); print (" linstep " + $NewRadiusPP + "\n "); delete $distNNode; } }