26.01.2015 Views

The RenderMan Interface - Paul Bourke

The RenderMan Interface - Paul Bourke

The RenderMan Interface - Paul Bourke

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>The</strong> helper program generates geometry on-the-fly in response to procedural primitive<br />

requests in the RIB stream. Each generated procedural primitive is described<br />

by a request to the helper program, in the form of an ASCII datablock that describes<br />

the primitive to be generated. This datablock can be anything that is meaningful and<br />

adequate to the helper program, such as a sequence of a few floating-point numbers,<br />

a filename, or a snippet of code in an interpreted modeling language. In addition, the<br />

renderer supplies the detail size of the primitive’s bounding box, so that the generating<br />

program can decide what to generate based on how large the object will appear<br />

on-screen.<br />

<strong>The</strong> generation program reads the request datablocks on its standard input stream<br />

and emits RIB commands on its standard output stream. <strong>The</strong>se RIB streams are read<br />

into the renderer as though they were read from a file (as with ReadArchive) and<br />

may include any standard <strong>RenderMan</strong> attributes and primitives (including procedural<br />

primitive calls to itself or other helper programs). As long as any procedural<br />

primitives exist in the rendering database that require the same helper program for<br />

processing, the socket connection to the program will remain open. This means that<br />

the program should be written with a loop that accepts any number of requests and<br />

generates a RIB “snippet” for each one.<br />

RIB BINDING<br />

Procedural ”ReadProgram” [programname datablock] [boundingbox]<br />

<strong>The</strong> argument list is an array of two strings. <strong>The</strong> first element is the name of the helper<br />

program to execute and may include command line options. <strong>The</strong> second element is<br />

the generation-request data block. It is an ASCII printable string that is meaningful<br />

to the helper program and describes the children to be generated. Notice that the<br />

data block is a quoted ASCII string in the RIB file, so if it is a complex description<br />

that contains quote marks or other special characters, these must be escaped in the<br />

standard way. (Similar to C, using backslash metacharacters like \” and \n.) <strong>The</strong><br />

boundingbox is an array of six floating-point numbers, which is xmin, xmax, ymin,<br />

ymax, zmin, zmax in the current object space.<br />

EXAMPLE<br />

RtString args[] = { ”perl gencan.pl”, ”” };<br />

RtBound mybound = { -1, 1, -1, 1, 0, 6 };<br />

RiProcedural ((RtPointer)args, mybound, RiProcRunProgram, RiProcFree);<br />

Procedural ”RunProgram” [ ”perl gencan.pl” ”” ] [ -1 1 -1 1 0 6 ]<br />

<strong>The</strong> example above presumes that you have a Perl script called gencan.pl that will<br />

generate RIB for a model and write that RIB to its standard output stream.<br />

SEE ALSO<br />

RiProcedural, RiProcRunProgram, RiProcDynamicLoad<br />

RiProcDynamicLoad ( RtPointer data, RtFloat detail )<br />

90

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!