Computer Graphics Workshop '97 Problem Set 1

1/6/97

Problems
Notes on using the interpreter

Please see the notes from Lecture 1 for useful information on getting started with the ivyscm interpreter.

Hint: you can get rid of old examiner viewers by double-clicking the "close" button in the upper left corner, or by using the hide message in the same way you use the show message.

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. Other kinds of manipulators include SoTrackballManip, SoTabBoxManip, and SoJackManip.

The point of this problem is to illustrate the ease with which Inventor handles some very hard problems: 3D interaction via mouse clicks is non-trivial. We will see later how to use the output of Inventor's user interface elements to affect the behavior of a program.


Back to the CGW '97 home page

$Id: index.html,v 1.3 1997/01/02 01:49:55 kbrussel Exp $