// Generated by Cutter v6.5.5 at 5:33:39 on the 8.22.2013.
// Pre Shape Mel Script
//
global proc readGeoBrickmapRI()
{
// Get the name of the shape node
string $shapeNode = `rman ctxGetObject`;
string $parents[] = `listRelatives -parent $shapeNode`;
string $tformNode = $parents[0];
  
// The node may hava a number in its name that we can use 
// to set the random number generator
int    $nodeNumber = `match "[0-9]+" $shapeNode`;    
if($nodeNumber != "") {
    seed(int($nodeNumber));
    }
  
string $attr;
$attr = `rmanGetAttrName "rgbm_path"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
string $rgbm_path = `getAttr $attr`;
  
$attr = `rmanGetAttrName "rgbm_ignore"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
int $rgbm_ignore = `getAttr $attr`;
  
$attr = `rmanGetAttrName "rgbm_use_defaultsurface"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
int $rgbm_use_defaultsurface = `getAttr $attr`;
  
$attr = `rmanGetAttrName "rgbm_trace_visibility"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
int $rgbm_trace_visibility = `getAttr $attr`;
  
$attr = `rmanGetAttrName "rgbm_kcs"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
float $rgbm_kcs = `getAttr $attr`;
  
$attr = `rmanGetAttrName "rgbm_kos"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
float $rgbm_kos = `getAttr $attr`;
  
$attr = `rmanGetAttrName "rgbm_prev_shading"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
float $rgbm_prev_shading = `getAttr $attr`;
  
if($rgbm_use_defaultsurface) {
    print("Using the default brickmap shader.\n");
    RiSurface("defaultbrick", "float KCs", $rgbm_kcs, "float KOs", $rgbm_kos);
    }
else
    print("Ignoring the default brickmap shader.\n");
    
if($rgbm_ignore)
    return;
        
if($rgbm_prev_shading > 0) {
    RiIfBegin("$user:pass_class == 'Preview'");
    RiShadingRate($rgbm_prev_shading);
    RiIfEnd();
    }
RiAttribute("visibility", "int trace", $rgbm_trace_visibility);
RiAttribute("visibility", "int specular", 1);
RiGeometry("brickmap", "string filename", $rgbm_path);
  
// "switch off" the proxy
RiAttribute "visibility" "int camera" 0;
RiAttribute "visibility" "int transmission" 0;
RiAttribute "visibility" "int trace" 0;
}