2010 October 3 / |j|d|a|v|i|s|@|c|a|r|l|e|t|o|n|.|e|d|u
Carleton College CS 201, Prof. Joshua R. Davis
As we've discussed in class, a graphical program typically consists of many graphical objects connected together in something like a tree. For example, a graphical user interface is constructed as a tree of views and controls. The content of a virtual world may also be organized as a tree, which is called the scene tree. (Actually, scene graph is a more common term, but that will have to wait until later in the course.)
For example, a simple scene might consist of an open field containing a dog chasing an automobile. The dog consists of a torso connected to a head, four limbs, and a tail. The head consists of the skull, a snout, a nose, two eyeballs, and two ears. Each limb consists of an upper limb, a lower limb, and a paw. So the dog is a tree of body parts:
dog torso head skull snout nose left eye right eye left ear right ear left fore leg upper leg rest of leg lower leg paw right fore leg upper leg rest of leg lower leg paw left hind leg upper leg rest of leg lower leg paw right hind leg upper leg rest of leg lower leg paw tail |
Photograph by Smallbones, via Wikipedia. |
A nearly perfect facsimile! Texture taken from dog at left. |
This isn't even a very detailed dog; the torso, head, tail, and paws could be further articulated; it could really use a neck. In any event, the dog is a tree of objects. Similarly, the car can be broken down into a chassis with four wheels hanging off it. If we want the doors to open or the steering wheel to turn, then those could be further articulated. So the car is a tree of objects. The field is also a tree of objects. In fact, the entire scene is a tree with three subtrees; hence the term scene tree.
scene dog subtree car subtree field subtree
Now here's the important and tricky part. In a scene tree, each object's position and orientation is specified relative to its parent. In the dog model, the whole dog is centered on the center of its torso; the torso, head, tail, and limbs are positioned relative to that point. But the individual parts of the head are not positioned relative to that point; they are specified relative to the center of the dog's head. Similarly, the dog's lower left fore leg is positioned relative to its left fore leg. These "local coordinate systems" are depicted in the first image below.
When you rotate or translate the dog's head, all parts of the head automatically move with it; this is depicted in the second and third images above. If for example the ears weren't positioned relative to the head, then you'd be able to move the head and leave the ears behind, floating in space, which is revolting (see Blue Velvet). In short, the structure of the computer code reflects the structure of the scene being depicted; this makes the code more intuitive.
The purpose of this assignment is to practice with trees and to do something creative. Specifically, you will write a graphical program based on one or two scene trees. You are required to work with an assigned partner. Your work is due Thursday at 4:59 PM.
It's easiest to do this assignment on a CS lab machine, because all of the Python modules you need are already installed. If you really want to do the assignment on your own computer, then talk to me — but be prepared for a long and difficult installation process.
Once you're at a CS lab machine or another computer with everything installed, download the current version of the Bopagopa graphics library from my web page. That is, save the Bopagopa ZIP file to your computer, and then double-click it to unzip it. Examine the tutorials
directory inside Bopagopa. These are tutorials, not demos; they are meant to be informative rather than exciting. I recommend that you work through all of the 2D tutorials (a-h). For each one, execute the program, read the code, and execute the program again. Many of the programs let you, the user, interact with the objects by clicking on them, dragging them, or pressing keys. Make sure you play around some. If you like, continue on to the 3D tutorials (i-o).
The scene tree idea is realized in Bopagopa quite simply. Every Bopagopa window has a 2D scene tree and a 3D scene tree. The leaves of these scene trees are Body2D
s and Body3D
s. The branch nodes of the scene trees are Group2D
s and Group3D
s. The branch nodes don't do any drawing themselves; when they are told to draw, they simply pass the message on to their children. Only at the leaves does actual drawing happen.
This assignment is open-ended. You are required to make a graphical program (2D, 3D, or both) using Bopagopa that meets these criteria.
You should write a readme.txt
file (in plain text, using TextWrangler) that explains your program's features and how to use your program. The grader will read this before grading your program.
You're going to submit your work electronically. In your hand-in folder, make a folder scenetrees
. Put all of your files — your program, your readme.txt
, all necessary image files, etc. — inside the scenetrees
folder. Do not submit the Bopagopa files; the grader already has those. Here are the grading criteria.