|
global proc addPointsRI()
{
// Get the name of the shape node
string $shapeNode = `rman ctxGetObject`;
// Get the name of the transform node
string $parents[] = `listRelatives -parent $shapeNode`;
string $tformNode = $parents[0];
string $attr;
$attr = `rmanGetAttrName "ap_num"`;
int $ap_num = `getAttr($shapeNode + "." + $attr)`;
$attr = `rmanGetAttrName "ap_dia"`;
float $ap_dia = `getAttr($shapeNode + "." + $attr)`;
$attr = `rmanGetAttrName "ap_noisiness"`;
float $ap_freq = `getAttr($shapeNode + "." + $attr)`;
$attr = `rmanGetAttrName "ap_dist"`;
float $ap_dist = `getAttr($shapeNode + "." + $attr)`;
$attr = `rmanGetAttrName "ap_script"`;
string $ap_script = `getAttr($shapeNode + "." + $attr)`;
string $inputs = $ap_num + " " + $ap_dia + " " + $ap_freq + " " + $ap_dist + " ";
int $num = `particle -q -ct $tformNode`;
print("Number of particles is " + $num + "\n");
// Query the particle positions
for($n = 0; $n < $num; $n++) {
$part = $tformNode + ".pt[" + $n + "]";
$pos = `getParticleAttr -at position $part`;
seed($n);
RiTransformBegin();
RiTranslate($pos[0], $pos[1], $pos[2]);
$angle = rand(-180.0, 180.0);
RiRotate($angle, rand(-1.0, 1.0), rand(-1.0, 1.0), rand(-1.0, 1.0));
// On Linux and MacOSX use "/usr/bin/python " instead of "python "
RiProcedural("RunProgram","python " + $ap_script,
-$ap_dist,$ap_dist,
-$ap_dist,$ap_dist,
-$ap_dist,$ap_dist,
$inputs + $n);
RiTransformEnd();
}
RiAttribute "visibility" "int camera" 0;
}
|