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.
These programs will be graded under UNIX. Use the submit command to electronically submit your files. You can do
man submitto 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 makefileIn C++, your submission might look something like this:
submit c681aa hw1 ppm.cpp parser.cpp 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>
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.
The objectives reason for this homework assignment are to:
make ppm ppm convert output.ppm output.jpg display.jpg
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
'_i' : integer '_s' : non-whitespace string '_ws': any text, including whitespace, terminated by the end of line
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