CSE 681 - Winter 2011

Homework #1
due Monday, Jan. 10
submit on or before 11:59:59pm on Monday


INTRODUCTION

This is to get you started early on code you going to have to write at some point anyway. This should not be a difficult exercise. If you have problems writing this code, then you should see me about what classes you should be taking.

You are to write two programs. One simply outputs a valid .ppm file and the other will read in and parse a test file. See below for details.


SUBMIT

These programs will be graded under UNIX. Use the submit command to electronically submit your files. You can do

man submit
to learn more about the submit commands. It's important to note that anytime you submit an assignment it completely wipes out ALL the files that were previously submitted for that assignment - so you can't incrementally submit as assignment. This also means you can, and should, test out the submit command by trying it.

If you program in C, your submit should look something like this (the files can appear in any order):

submit c681aa hw1 ppm.c parser.c makefile
In C++, your submission might look something like this:
submit c681aa hw1 ppm.cpp parser.cpp makefile


MAKEFILE

You have to submit a makefile that the grader can use to compile the programs. You can do a man make to learn more about the make command, but it's probably better to look online for information or just use the information from the CSE681 web pages.

Here is a sample makefile that you can use. You can modify this makefile for subsequent assignments.

make ppm
ppm

make parser
parser <input filename>


NAMING CONVENTIONS

DO NOT USE YOUR OWN NAMING CONVENTIONS FOR EXECUTABLE FILE. The grader can automate some of the compiling and executing of programs if you adhere to the naming conventions in the lab and homework specifications. You will lose points if you deviate from these and subsequently slow down the grading process.


OBJECTIVE

The objectives reason for this homework assignment are to:

  1. make sure everyone has the requisite programming skills for the class
  2. get you started on some of the more general-purpose code that needs go into your lab assignment
  3. make sure you know how to submit programs (and to make sure submit is set up properly and is working)
  4. make sure you can use a simple makefile


ASSIGNMENT: PROGRAMMING UTILITIES

  1. OUTPUT PPM FILE
    This code will be part of all the lab assignments.
    Write a small test program to make sure you understand how to write out ppm files. Portable pixmap format (ppm) is a very simple color image file format. We will be outputting images in this format in all the labs throughout the quarter. You program should write out a ppm file, such as the sample PPM image above, to a file called output.ppm. Under UNIX, use convert to convert it to a .jpg format, then display to view it. So the grader should be able to do the following under UNIX:
    make ppm
    ppm
    convert output.ppm output.jpg
    display.jpg
    

  2. SCENE FILE PARSER
    This code will go right into Lab 2. Also, the code that parses the transformation commands will be used in an upcoming homework assignment.

    Write a parser for an input text scene description file (see format below), reading in values and setting variables in a scene description data structure. Print out the output filename and the number of spheres.

    Data Structure

    Set up data structures for the following items. The variables in the data structures are the ones that are in the input file (see below).

    Simple Scene File Format

    Commands

    # <comment_ws>
    
    sphere <r> <g> <b> <t_s> <kd> <ks> <n_i> <kr>  <gl> <kt> <f>  <tr>
    
    camera <x> <y> <z> <cx> <cy> <cz> <angle> <aspect> <hither> <yon> <tilt> <xres_i> <yres_i>
    light <x>  <y>  <z> <i>  <f>
    ambient <a>
    background <r> <g> <b>
    output <filename_s>
    
    identity
    rotate [x|y|z] <angle>
    translate <tx> <ty> <tz>
    scale <sx> <sy> <sz>
    

    Sample Scene Files

    1. sample 1
    2. sample 2