## 1/8/97

Problems
Problem 1 - Make a scene

```;;; Problem 1-1

;; create a viewer

(define viewer (new-SoXtExaminerViewer))
(-> viewer 'show)

;; create root of scene graph and ref it

(define root (new-SoSeparator))
(-> root 'ref)

;; create nodes for left and right eyes.
;; note that left eye is at the origin

(define eye-mat (new-SoMaterial))
(-> root 'addChild eye-mat)
(-> root 'addChild (new-SoSphere))
(define eye-xform (new-SoTransform))
(-> root 'addChild eye-xform)
(-> (-> eye-xform 'translation) 'setValue 3 0 0)
(-> root 'addChild (new-SoSphere))

;; create nodes for nose

(define nose-mat (new-SoMaterial))
(-> root 'addChild nose-mat)
(define nose-xform (new-SoTransform))
(-> root 'addChild nose-xform)
(-> (-> nose-xform 'translation) 'setValue -1.5 -3 0)
(-> root 'addChild (new-SoCone))

;; create nodes for mouth

(define mouth-mat (new-SoMaterial))
(-> root 'addChild mouth-mat)
(define mouth-xform (new-SoTransform))
(-> (-> mouth-xform 'translation) 'setValue 0 -3 0)
(-> root 'addChild mouth-xform)
(-> root 'addChild (new-SoCube))

;; show the scene graph

(-> viewer 'setSceneGraph root)
```
Problem 2 - Reorganize the scene

```;;; Problem 1-2

;; create viewer and show it

(define viewer (new-SoXtExaminerViewer))
(-> viewer 'show)

;; root of scene graph

(define root (new-SoSeparator))
(-> root 'ref)

;; separator and nodes for left eye

(define left-eye-sep (new-SoSeparator))
(-> root 'addChild left-eye-sep)
(define left-eye-mat (new-SoMaterial))
(-> left-eye-sep 'addChild left-eye-mat)
(define left-eye-xform (new-SoTransform))
(-> left-eye-sep 'addChild left-eye-xform)
(-> left-eye-sep 'addChild (new-SoSphere))

;; separator and nodes for right eye

(define right-eye-sep (new-SoSeparator))
(-> root 'addChild right-eye-sep)
(define right-eye-mat (new-SoMaterial))
(-> right-eye-sep 'addChild right-eye-mat)
(define right-eye-xform (new-SoTransform))
(-> right-eye-sep 'addChild right-eye-xform)
(-> (-> right-eye-xform 'translation) 'setValue 3 0 0)
(-> right-eye-sep 'addChild (new-SoSphere))

;; separator and nodes for nose

(define nose-sep (new-SoSeparator))
(-> root 'addChild nose-sep)
(define nose-mat (new-SoMaterial))
(-> nose-sep 'addChild nose-mat)
(define nose-xform (new-SoTransform))
(-> nose-sep 'addChild nose-xform)
(-> (-> nose-xform 'translation) 'setValue 1.5 -3 0)
(-> nose-sep 'addChild (new-SoCone))

;; separator and nodes for mouth

(define mouth-sep (new-SoSeparator))
(-> root 'addChild mouth-sep)
(define mouth-mat (new-SoMaterial))
(-> mouth-sep 'addChild mouth-mat)
(define mouth-xform (new-SoTransform))
(-> (-> mouth-xform 'translation) 'setValue 1.5 -6 0)
(-> mouth-sep 'addChild mouth-xform)
(-> mouth-sep 'addChild (new-SoCube))

;; show scene graph

(-> viewer 'setSceneGraph root)
```
Problem 3 - Manipulate the scene

```;;; Problem 1-3
;;; Same as 1-2, but with manipulators
;;; attached to all objects.

(define viewer (new-SoXtExaminerViewer))
(-> viewer 'show)

(define root (new-SoSeparator))
(-> root 'ref)

(define left-eye-sep (new-SoSeparator))
(-> root 'addChild left-eye-sep)
(define left-eye-mat (new-SoMaterial))
(-> left-eye-sep 'addChild left-eye-mat)
(define left-eye-xform (new-SoHandleBoxManip))
(-> left-eye-sep 'addChild left-eye-xform)
(-> left-eye-sep 'addChild (new-SoSphere))

(define right-eye-sep (new-SoSeparator))
(-> root 'addChild right-eye-sep)
(define right-eye-mat (new-SoMaterial))
(-> right-eye-sep 'addChild right-eye-mat)
(define right-eye-xform (new-SoHandleBoxManip))
(-> right-eye-sep 'addChild right-eye-xform)
(-> (-> right-eye-xform 'translation) 'setValue 3 0 0)
(-> right-eye-sep 'addChild (new-SoSphere))

(define nose-sep (new-SoSeparator))
(-> root 'addChild nose-sep)
(define nose-mat (new-SoMaterial))
(-> nose-sep 'addChild nose-mat)
(define nose-xform (new-SoHandleBoxManip))
(-> nose-sep 'addChild nose-xform)
(-> (-> nose-xform 'translation) 'setValue 1.5 -3 0)
(-> nose-sep 'addChild (new-SoCone))

(define mouth-sep (new-SoSeparator))
(-> root 'addChild mouth-sep)
(define mouth-mat (new-SoMaterial))
(-> mouth-sep 'addChild mouth-mat)
(define mouth-xform (new-SoHandleBoxManip))
(-> (-> mouth-xform 'translation) 'setValue 1.5 -6 0)
(-> mouth-sep 'addChild mouth-xform)
(-> mouth-sep 'addChild (new-SoCube))

(-> viewer 'setSceneGraph root)
```

Back to the CGW '97 home page

\$Id: index.html,v 1.3 1997/01/02 21:02:28 kbrussel Exp \$