home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 August / chip_08_2000.iso / aktualnosci / shareware / Rhinoceros / rh11eval_20000320.exe / %MAINDIR% / RIB / show_xyz.sl < prev    next >
Encoding:
Text File  |  2000-06-08  |  891 b   |  36 lines

  1. /* Copyrighted Pixar 1989 */
  2. /* From the RenderMan Companion p.347 */
  3. /* Listing 16.13  Shader mapping shader-space coordinates to colors */
  4.  
  5. /*
  6.  * show_xyz(): Color a surface point according to its xyz coordinates
  7.  *     within a bounding box.
  8.  */
  9. surface
  10. show_xyz (
  11.     float    xmin = -1,
  12.             ymin = -1,
  13.             zmin = -1,
  14.             xmax = 1,
  15.             ymax = 1,
  16.             zmax = 1)
  17. {
  18.     uniform point scale, zero;
  19.     point objP, cubeP;
  20.     
  21.     /* Check for zero scale components. */
  22.     if (xmax == xmin || ymax == ymin || zmax == zmin) {
  23.         printf ("bad bounding box %f %f %f %f %f %f in show_xyz()",
  24.          xmin, xmax, ymin, ymax, zmin, zmax);
  25.     }
  26.     else {
  27.         scale = point (1 / (xmax - xmin), 1 / (ymax - ymin), 
  28.          1 / (zmax - zmin));
  29.         zero = point (xmin, ymin, zmin);
  30.         
  31.         objP = transform ("shader", P);
  32.         cubeP = (objP - zero) * scale;
  33.         Ci = color (xcomp (cubeP), ycomp(cubeP), zcomp(cubeP) );
  34.     }
  35. }
  36.