Computer Graphics Workshop '96 Problem Set 1

1/8/96

Problems
Hints for easier working

We offer the following suggestions to make working with the Scheme interpreter and saving your work easier:

Notes on the interpreter

Because the Scheme interpreter, ivyscm, can crash if you have a bug in your Scheme program, we strongly suggest you put the following into your ~/.cshrc.mine dotfile on Athena:
limit coredumpsize 0
This will prevent the interpreter from trying to dump large amounts of debugging information into your home directory (or elsewhere).

If you have an error in your Scheme program, you will probably get an error message. If this happens your Inventor windows will stop updating. To fix this, just type a number (i.e. 4) into the interpreter; this will evaluate properly, and you can then look back and fix the line of code which caused the interpreter to fail.

Problem 1 - Make a scene

In this problem you will make a simple scene graph of a face. The objects in this graph will be, in order:

root (SoSeparator)
eye material (SoMaterial)
left eye (SoSphere)
eye transformation (SoTransform)
right eye (SoSphere)
nose material (SoMaterial)
nose transformation (SoTransform)
nose (SoCone)
mouth material (SoMaterial)
mouth transformation (SoTransform)
mouth (SoCube)

Construct each of the objects and add it to the root node, as shown in today's lecture. Don't forget to ref your root node! Once you have created all the objects, create a viewer and set its scene graph to be the root node. You should now see a cube on the screen, assuming you have not modified any of the transforms.

Now modify, in order, the eye, nose, and mouth transformations to create the face. You will be using the translation field of the SoTransform node, as shown in lecture. Remember that the positive X axis is to the right, the positive Y axis is up, and the positive Z axis is out of the screen. (You should not need to change the Z translations of any of the objects.)

Note that all of the objects after the transformation you are modifying follow along when you change that transformation. For example, once you have created the face, increase the eye translation, and note that the nose and mouth move along with the right eye.

This happens because transformations are cumulative; each transformation modifies the current transformation matrix, which defines the relationship between the world coordinate system and the objects' coordinate systems.

Problem 2 - Reorganize the scene

Now we will reorganize the scene graph to remove the interdependencies between objects. Create a scene graph with the following topology:

root (SoSeparator)
left eye separator (SoSeparator)
left eye material (SoMaterial)
left eye transformation (SoTransform)
left eye (SoSphere)
right eye separator (SoSeparator)
right eye material (SoMaterial)
right eye transformation (SoTransform)
right eye (SoSphere)
nose separator (SoSeparator)
nose material (SoMaterial)
nose transformation (SoTransform)
nose (SoCone)
mouth separator (SoSeparator)
mouth material (SoMaterial)
mouth transformation (SoTransform)
mouth (SoCube)

An SoSeparator node has two important properties: it can group nodes together under it, and it separates nodes in the following manner: no node under a separator can affect any node above and to the right of it. That is, a transformation node under a separator node will not affect any objects following that separator in the scene graph.

This new topology allows each object to be moved about independently of the others. Modify the transformations to recreate the shape of the face.

Problem 3 - Manipulate the scene

At this point you should have a buffer named something like "ps1-2.scm" which has code looking something like the following:
;; ... code above this ...
(define right-eye-sep (new-SoSeparator))
(-> root 'addChild right-eye-sep)
(define right-eye-transform (new-SoTransform))
(-> right-eye-sep 'addChild right-eye-transform)
(-> (-> right-eye-transform 'translation) 'setValue 3 0 0)
:; ... code below this ...
Now replace all instances of the word "SoTransform" with the word "SoHandleBoxManip"; that is, the line
(define right-eye-transform (new-SoTransform))
would become
(define right-eye-transform (new-SoHandleBoxManip))
Reload the code into the Scheme interpreter and view the resulting scene graph. Each object should have a box surrounding it; click on the arrow button on the upper right side of the examiner viewer, and then click and drag on one of the boxes; note that the objects translate to follow your mouse. Manipulators are subclasses of SoTransform; they are special objects that know how to detect mouse button presses and respond to clicking and dragging.

Back to the CGW '96 home page

$Id: index.html,v 1.1 1996/01/02 21:56:42 kbrussel Exp kbrussel $