Geometric Operations


Graphics State

Gops are AL procedures which modify the current graphic state.

The graphics state contains a transformation (scale, rotation, translation) and surface attributes (shaders, rendering quality, color, etc).

When any gprim is drawn, it will be drawn using the current graphics state.

For example, if the current graphics state transformation contains a rotation by ninety degrees around the X-axis, and a blue marble shader, and we create a cone, it will be rotated and made of blue marble. In fact, any gprim we create will be rotated and made of blue marble until we change the graphics state.


Blocking Constructs

Blocking Constructs allow Gprims to be grouped together and combined into hierarchies. They determine what is affected by changes in the graphics state.

Blocking Constructs are used like functions, although they can have any number of arguments. The arguments to Blocking Constructs are usually gprims and gops.

World

The primary Blocking Construct is "world". "World" should always be used to group all of the gprims that are to be rendered.

Separator

The other most used Blocking Construct is "separator". "Separator" limits the effect of gops. Changes made to the graphics state with gops called within a separator will not effect gprims outside of that separator. We will see examples, after learning about gops.

Transform Separator

There is also a second form of separator called a "xfm-separator" or transform separator. It is the same as a regular separator except it only limits transform changes to the graphics state. Light and surface attribute changes are not affected.


Graphics Operations

Gops come in two flavors: those that effect transformations, and those that effect surface attributes.

Surface Attribute Gops

Attribute gops such as shaders and rendering options we will discuss later in sections devoted to the topics. The "color" surface attribute gop is very simple, however. It requires a list of three numbers, representing an rgb value. "Color" is used in the transform example below.

Transform Gops

There are three primary gops to control transformations: scale, rotate, and translate. Scale and translate require a single list with three numbers for an argument. Rotate takes a rotation angle in degrees and an axis to rotate around (specified also as a list with three numbers).

There is also a shortcut for scale called "uscale", which just takes one number and uniform scales by that number. So "(uscale .5)" is the same as "(scale '(.5 .5 .5))". When transformation gops are called, they are concatenated to the current transformation, rather than replacing it. (For those concerned with such things, the matrices they produce are premultiplied with the current transformation matrix).

The practical effect of this is that the tranformations are applied to the gprims in the reverse order that the gops were called. So if you wanted to scale, then rotate, then translate a sphere, you would call the gop "translate", then "rotate", then "scale".

Example

Here's a simple example with four red torii, progressivly scaled, rotated, and translated.

  (world
    (color '(1 0 0))

    (torus)

    (translate '(5 0 0))
    (rotate 60 '(1 0 0))
    (uscale 1.25)
    (torus)

    (translate '(5 0 0))
    (rotate 60 '(1 0 0))
    (uscale 1.25)
    (torus)

    (translate '(5 0 0))
    (rotate 60 '(1 0 0))
    (uscale 1.25)
    (torus)
   )


Gprims can be grouped hierarchically by limiting the effect of gops using the "separator" blocking construct. In this simple example, the effect of the gop "color" is limited with separators.
  (world
    (separator
	(color '(1 0 0))
	(sphere)
     )

    (translate '(2 0 0))

    (separator
	(color '(0 1  0))
	(sphere)
     )

    (translate '(2 0 0))

    (separator
	(color '(0 0 1))
	(sphere)
     )
   )


One additional miscellaneous gop that can prove useful is "tessellate".

"Tessellate" controls the degree to which gprims are broken into facets when rendered in the icam. Using "tessellate" will let you trade off interactive performance for rendering quality in the icam.

Here is a sphere that has been tessellated to varying degrees.

  ox --> (tessellate n n)




Return to AL Introduction
mrl