Surface Specification

provides a number of ways to define surfaces and to bind these surfaces to objects. The most straight-forward method of surface specification is to simply list the surface properties to be used. Alternatively, one may associate a name with a given surface. This name may subsequently be used to refer to that surface.


\begin{defkey}{surface}{{\em name\/} $<${\em Surface Definition}$>$}
Associate the given collection of surface attributes with the
given name.
\end{defkey}

The binding of a collection of surface properties to a given object is accomplished in a bottom-up manner; the surface that ``closest'' in the modeling tree to the primitive being rendered is the one that is used to give the primitive its appearance.

An object that has no surface bound to it is assigned a default surface that gives the appearance of white plastic.

The most direct way to bind a surface to a primitive is to specify the surface when the the primitive instantiated. This is accomplished by inserting a list of surface attributes or a surface name after the primitive's type keyword and before the actual primitive data.

    /*
     * A red 'mud' colored sphere reseting on a
     * white sphere. To the right is a sphere with
     * default surface attributes.
     */
    surface mud ambient .03 0. 0.  diffuse .7 .3 0.
    sphere  ambient .05 .05 .05 diffuse .7 .7 .7   1. 0 0 0
    sphere mud  1. 0 0 2
    sphere 1. 1.5 0 0

Here, we define a red surface named ``mud''. We then instantiate a sphere, which has a diffuse white surface bound to it. The next line instantiates a sphere with the defined ``mud'' surface bound to it. The last line instantiates a sphere with no surface bound to it; it is assigned the default surface by .

The applysurf keyword may be used to set the default surface characteristics for the aggregate object currently being defined.


\begin{defkey}{applysurf}{$<${\em Surface Specification}$>$}
The specified surfa...
...f this keyword is limited to the aggregate currently
being defined.
\end{defkey}

    /*
     * Mirrored ball and cylinder sitting on 'default' plane.
     */
    surface mirror ambient .01 .01 .01
            diffuse .05 .05 .05
            specular .8 .8 .8 specpow 20  reflect 0.95
    plane 0 0 0  0 0 1
    applysurf mirror
    sphere 1 0 0 0
    cylinder 1  3 0 0  3 0 3

For convenience, the name cursurf may be used to refer to the current default surface.

The utility of bottom-up binding of surfaces lies in the fact that one may be as adamant or as noncommittal about surface binding as one sees fit when defining objects. For example, one could define a king chess piece consisting of triangles that have no surface bound to them, save for the cross on top, which has a gold-colored surface associated with it. One may then instantiate the king twice, once applying a black surface, and once applying a white surface. The result: a black king and a white king, each adorned with a golden cross.

    surface white ...
    surface black ...
    surface gold  ...
    ...
    define cross
            box x y z  x y z
            ...
    defend
    define king
            triangle x y z  x y z  x y z
            ...
            object gold cross
    defend

    object white king translate 1. 0 0
    object black king