Computer Science 112
The Art & Science of Computer Graphics

Spring 2016, The College of Saint Rose

Studio/Lab 9: Shared Model Contribution
Due: 11:59 PM, Monday, April 18, 2016

In this short "mini-lab" exercise that you can do any time over the next couple weeks, you will create a shared model in Ambrosia to contribute to a class shared model repository.

A Shared Model

You have created some very interesting models so far this semester, and we will use shared models to allow you 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.

Our first experience with shared models was to build our marble models. Now, you will be creating a shared model of one or more of the other objects you have created this semester.

Please read back over the motivations for and description of how shared models are created on the marbles lab description before proceeding.

Procedure

Here is the process you should follow to create and publish your shared model.

  1. Select one of your favorite objects developed for a lab so far. You are also welcome to develop something brand new, but that is certainly not required. The instructions here will assume you are using a previous model. As an example, I am using the key object from class: On the Wiki: Key, Downloadable file: Key.py
  2. Make a copy of the model file that includes the items you wish to include in your shared model. Give it a file name that includes your name or initials or some other way to identify it as yours. Pseudonyms are fine. In my case, copied Key.py to JTerescoKey.py.
  3. Next, optionally rename the objects whose names will be exported by your shared model to include your name or initials or some other indentifying prefix. I renamed key to JTKey, silverMat to JTSilverMat, and goldMat to JTGoldMat.
  4. List those names you are exporting at the top of your file in the "__all__" list. Here's mine:
    __all__ = ( 'JTKey', 'JTSilverMat', 'JTGoldMat' )
    

    Important note: there are two "_" characters before and two after the word "all" in the above line.

  5. Remove everything from the shared model file except those items needed for your construction of the objects you are exporting from your shared model. In my case, I kept everything up to and including the definition of the JTKey and the two materials. At this point, if you run your model ("python3 JTerescoKey.py") you should not see any errors, but no image should be generated.
  6. Next, you'll need some code to test out your shared model and to generate one or more images you'll use on your shared model's wiki page. There are two options here, either is perfectly acceptable.
    Separate Model File
    This is the approach we used for the marbles and stained glass windows. Create a separate model file that imports your shared model. In my case, since I have three names to import, I bring them all in with this line:
    from JTerescoKey import *
    

    Alternately, you might import a single name as we did when importing your marbles and windows.

    This file should show off your shared model object or objects in a simple setting, or just sitting in space.

    Then, as with the marbles and stained glass windows, you would run that second model file to generate images, and your shared model file will be imported when needed.

    Protected main Clause
    This second option takes advantage of some Python functionality we do not cover specifically this semester. Instead of putting your code to create the simple scene showing off your shared model in a separate file, that code would be placed, all indented by 4 spaces, after the line:
    if __name__ == '__main__':
    

    Again, there are two "_" characters before and two after the words "name" and"main" in the above line.

    What this does is allows us to run our shared model file as we normally would:

    python3 JTerescoKey.py
    

    to generate our image. However, when the file is used by including an import statement in some other model file, the code inside the indented if statement will not be executed. So the scene is not modified and no images are generated.

  7. Create a new wiki page (not just a new section of your existing wiki page) for your shared model. To do this, you can enter the name of the page you want in the search box from any page on the wiki site. I entered "Jim's Ambrosia Key". Since that page does not exist, you should see a red link that will allow you to create the page. Choose this, and create a page, much like mine for the key. If you created a shared model of a particle accelerator, and your name is Peter Venkman, you might name your page "Peter Venkman's Particle Accelerator". As always, pseudonyms are fine.

    Your page should meet these requirements:

  8. Email your model file to complete the submission.

    After submission, I will upload your model to the course web site, and will add a link to the shared model's wiki page so others can gather your model's code if they wish to use your model.

Bonus Opportunity: Additional Shared Models

You may contribute up to 5 additional shared models to earn up to 5 bonus points each. These models could include objects you have developed or are developing for labs or your final project, or you could develop brand new ones just for this purpose. To earn the full 5 bonus points, your submission must meet all of the requirements for shared models as described in this document. Please clearly indicate that your submission is a bonus shared model submission in the subject of your email. While the required shared model is due by 11:59 PM, Monday, April 18, 2016, bonus shared models will be accepted for credit through the end of the semester.

Using Shared Models

To use a classmate's shared model, simply download the model code (the .py file) into the folder where you're working and add the appropriate import statement. 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.

Grading

This assignment is worth 15 points, which are distributed as follows:

> FeatureValueScore
Shared model code properly defined 5
Code organization and style 2
Model documentation 2
Image(s) and model description on new wiki page 5
Emailed model code to be placed on site 1
Total 15