Next: Remote Display, Previous: Geomview.m, Up: Mathematica

### 9.3 Using Mathematica to generate RenderMan files

In addition to the `WriteOOGL` and `Geomview` commands described above, the package `OOGL.m` also defines the command `WriteRIB` which writes a 3D graphics objeto to a RenderMan RIB file: `WriteRIB[`file`,` graphics`]` writes graphics to file file. RenderMan is a commercial rendering system available from Pixar, Inc., which can produce extremely high quality images.

         In[1] := <<OOGL.m

         In[2] := <<Graphics/Polyhedra.m

         In[3] := Graphics3D[Cube[]]

         Out[3] := -Graphics3D-

         In[4] := WriteRIB["cube.rib", %3]

         Out[4] := -Graphics3D-

This generates the file `math.ri`b. This is a ready-to-render RIB file da given objeto geométrico, using a default câmera position, lighting, and the “plastic” shader. In a shell janela, type `render cube.ri`b to generate the image file `mma.tiff`. Of course, you need to have RenderMan installed for this to work. A shortcut to render from inside Mathematica is `WriteRIB["!render", foo]`.

`WriteRI`b works by first converting the Mathematica graphics objeto to OOGL format using `WriteOOGL` and then calls an external program `oogl2ri`b to convert OOGL to RIB format. The oogl2rib program takes several options which you can specify in a sequência de caracteres as an optional terceiro argumento to `WriteRI`b. The default option sequência de caracteres is `" -n mma.tiff "`, which indicates that the RIB file should generate a rendered TIFF file named `mma.tiff`. A particularly useful option is `-g`, which tells oogl2rib to convert only the objeto geométrico into a RIB fragment. You can insert that fragment into a full RIB file of your own making with câmera positions and shaders of your choice, to harness the full power of RenderMan.

The full usage of oogl2rib is:

         oogl2rib [-n name] [-B r,g,b] [-w width] [-h height] [-fgb] [infile] [outfile]

By default it reads from stdin and writes to stdout. Either infile ou outfile may be `-`, which means use stdin/stdout. The options are:

`-n` name
  Use name for the name do rendered TIFF file (default "geom.tiff") ou framebuffer janela (default "geom.rib").
`-B` r`,`g`,``b`
  Use background color (r,g,b). Each component ranges from 0 to 1. Default: none.
`-w` width`-h` height
  Rendered frame will be width by height pixels.
`-f`
  RIB file renders to on-screen framebuffer instead of TIFF file.
`-g`
  Output only the objeto geométrico in RIB format.
`-b`
  Output only a Quick Renderman clip objeto. Ignores -nBwhf.