Computer Science 110
The Art & Science of Computer Graphics

Mount Holyoke College
Spring 2008


Lab 6: Programmed Replication
Due: 11:00 AM, Monday, April 7, 2008


For the next two weeks, you are to develop your most complex scene so far. Using the programming techniques we have discussed and will discuss in class, you can develop a scene with replicated components.

Shared Model Repository

The first part of this lab assignment is to contribute one or more models for a shared class model repository. You have created some very interesting models over the first half of the semester, and I would like you to be able to use each others' models as building blocks for the scenes you will be developing for the last few labs and for your final projects. To do this, take your favorite object or objects that you've developed for any previous lab models and put each into a form that will make it easy for your classmates to use.

As an example, here is my modification of the PacMan object put into a format that will make it more easily usable by everyone:

; Mead shared object file -- a Pac Man
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
;
; When developing code to be shared, it is especially important
; to document it well.  The first thing we'll do here is
; to describe the things defined in this shared module.
;
; This module defines a Pac Man object, named pacMan.  It is
; a sphere with a notch cut out, made of yellowPlaster
; material.  The Pac Man occupies the same space as the
; standard sphere - 100x100x100, centered at the origin.
;
; Now, on to the definition.
;
; We define the name of the module first -- this is the
; name of the definitions you intend to provide
(module PacMan mzscheme
  ; inside this "module" definition, we first require
  ; the same things we would normally require in our
  ; Mead models
  (require (lib "Defs.ss" "Mead"))
  
  ; But now we also have to say which names defined in this
  ; module will be visible to users of the module.
  ; Other names defined inside the model are private to the
  ; module and can collide with names in other parts
  ; of the model that uses this module without any trouble.
  ; In this case, we only provide the definition of the Pac Man
  (provide pacMan)
  
  ; we now define our Pac Man as usual.
  ; Pac Man is a circle with a triangular mouth opening, so we
  ; will make him a sphere with a wedge cut out for his mouth
  (object pacMan Difference
          (add sphere yellowPlaster)
          (add cube
               (compose
                (zRot 45)
                ; we don't want his mouth too far open, so
                ; scale down in the y dimension
                (scale 1 .7 1)
                ; the width of the cube along the x-axis is now
                ; 100*sqrt(2), so we translate by half of that
                (translate (* 50 (sqrt 2)) 0 0)
                )
               )
          )
  ; We need to close our module definition.  Notice that we
  ; don't add anything to the scene or shoot any images
  ; with the camera.  That would be the responsibility of
  ; users of our module
  )

This particular shared model is named PacMan.scm. To use it in your model:

Follow the example above to create at least one shared model to contribute to the class collection.

Good documentation is essential if others are going to be able to use your shared model in their models. Clearly specify the default locations and dimensions of your objects. Specify if they come equipped with a material property or if the user should specify a Material. And take pride in your work: put your name in a prominent position in the comment at the top of your file.

To contribute a model to the shared repository:

  1. Create a new Wiki page that describes your shared model. Include an image, perhaps captured with an IsometricCamera to provide useful views. Add your page to the "Shared Models" category.
  2. E-mail your shared model file to jteresco@mtholyoke.eduso it can be copied into the shared model repository, located in /home/jteresco/shared/cs110/shared_models on the Clapp 202 Linux systems.

If you would like to create a shortcut in your home folder to the shared model repository, open a terminal window and issue this command:

ln -s ~jteresco/shared/cs110/shared_models

When you use a classmate's shared model in one of your models, be sure to give proper credit, both as a comment in your model file and as part of your image description on your wiki entry.

Everyone should contribute at least one model by Friday, March 28, 2008, for 10 lab points. You may (and are encouraged to) contribute additional shared models at any time.

Replicated Objects

The main lab task is to develop a scene that demonstrates some of the programming techniques we have seen that help manage replicated objects. You may model any scene you wish, but it should have at least one component replicated, with its instances added using one of the programming techniques from our class discussion.

Start by defining the objects that you will use in your scene, whether replicated or single instances. You can work on these even before we have seen all of the replication techniques in class. You may also wish to peruse the shared model repository as it takes shape over the first week of this assignment.

As the models become more complex, good code organization and documentation becomes essential. Use constants to define sizes and locations. Continue to develop objects hierarchically. Use plenty of comments.

When you have completed your scene, submit it as usual by uploading one or more generated images to your wiki page with a brief description of your model and how it was constructed, and e-mail your model file (or files) to jteresco@mtholyoke.edu.

Your submission will be graded out of 30 points. Grading criteria include the appropriate usage of the programming techniques to achieve replication, the use of good coding practices (using constants, developing objects hierarchically, etc.), the quality and completeness of documentation (comments), your wiki image(s) and description, and artistic merit of the generated scene.

Caution: as your models become more complex, rendering times will increase. Please plan ahead! You might consider using a lower image quality when developing your models, increasing it only when you wish to generate final images.