Rib
Introduction to Modeling



Listing 1


Display "jack" "framebuffer" "rgb"
Projection "perspective" "fov" 40
Format 320 240 1
  
Translate 0 0 3
Rotate 0  1 0 0 
Rotate 90  0 1 0
Scale 1 1 -1
  
WorldBegin
    TransformBegin
        Cylinder 0.05 -0.5 0.5 360
        Translate 0 0 -0.5
        Sphere 0.15 -0.15 0.15 360
        Translate 0 0  1
        Sphere 0.15 -0.15 0.15 360
    TransformEnd
WorldEnd

Objects used in a 3D scene are normally modeled with software such as Maya and Houdini. However, simple objects and scenes can be implemented by directly scripting them in a rib file. Although writing a rib file with a text editor can be somewhat confusing a great deal can be learned about coordinate systems, the grouping mechanisms of RenderMan and about the role that a variety of attributes play in the process of rendering a scene. It is highly recommended that anyone intending to fully exploit the benefits of using RenderMan with applications such as Maya and Houdini should devout time to crafting rib files with a text editor. This tutorial outlines the process of modeling the "jack" shown in figure 1. It also shows how the "jack" can be rotated so that it rests on a horizontal surface - figure 2.




Figure 1 - (see listing 2)


Figure 2


The first thing to notice about the "jack" is that it can be created by duplicating two copies of the bar, shown in figure 3.



Figure 3 (see listing 1)



Inserting color coded coordinate axes using the Rman Tools->Utilities manu.


The duplicates will be identical except for the rotations required to align them with the 'Y' and the 'X' axis. Copying and pasting the transform block from listing 1 and adding the necessay 90 degree rotations results in the sequence of rib statements shown in listing 2. The rib statements were saved as an archive rib file, also known as a pre-baked rib. Note the archive file does not contain camera information, nor does it contain the statements WorldBegin or WorldEnd. Unless an archive contains light sources, as a result of "baking" a lighting rig, the contents of the file are generally "sandwiched" between AttributeBegin and AttributeEnd.


Listing 2 - jack.rib (archive or pre-baked rib file)


AttributeBegin
    TransformBegin
        Attribute "identifier" "name" ["jack_z_axis"]
        Cylinder 0.05 -0.5 0.5 360
        Translate 0 0 -0.5
        Sphere 0.15 -0.15 0.15 360
        Translate 0 0  1
        Sphere 0.15 -0.15 0.15 360
    TransformEnd
    TransformBegin
        Attribute "identifier" "name" ["jack_y_axis"]
        Rotate 90 1 0 0 # Rotation around the x-axis
        Cylinder 0.05 -0.5 0.5 360
        Translate 0 0 -0.5
        Sphere 0.15 -0.15 0.15 360
        Translate 0 0  1
        Sphere 0.15 -0.15 0.15 360
    TransformEnd
    TransformBegin
        Attribute "identifier" "name" ["jack_x_axis"]
        Rotate 90 0 1 0 # Rotation around the y-axis
        Cylinder 0.05 -0.5 0.5 360
        Translate 0 0 -0.5
        Sphere 0.15 -0.15 0.15 360
        Translate 0 0  1
        Sphere 0.15 -0.15 0.15 360
    TransformEnd
AttributeEnd

Referencing the pre-baked rib file with ReadArchive substantially reduces the code contained within the beauty pass rib - listing 3.


Listing 3


Option "searchpath" "archive" "PATH_TO_ARCHIVE_RIBS"
  
Display "jack" "framebuffer" "rgb"
Projection "perspective" "fov" 40
Format 250 250 1
  
Translate 0 0 3.5
Rotate -30  1 0 0 
Rotate  45  0 1 0
Scale 1 1 -1
  
WorldBegin
    ReadArchive "jack.rib"
WorldEnd


Orienting the Jack

The images shown below illustrate the effect of applying the following transformations to the archive. Remember the transformations are applied in reverse order.

    Translate 0 0.15 0  # 4th transformation
    Rotate 54.73 1 0 0  # 3rd transformation
    Rotate 45    0 1 0  # 2nd transformation
    Translate 0 0.5 0   # 1st transformation    
    ReadArchive "jack.rib"


Starting Position


1 - Translate 0 0.5 0


2 - Rotate 45 0 1 0


3 - Rotate 54.73 1 0 0


4 - Translate 0 0.15 0


Final Position




© 2002- Malcolm Kesson. All rights reserved.