Programming Assignment 1

Due Monday, September 26 before midnight

This programming assignment is meant to acquaint you with scan conversion algorithms. You write two functions, which you compile and link with a main program that is provided. The resulting program will draw lines and triangles.

Get Some Files

Some basic functions and the sketch tool's main program are provided for you. So, before you begin programming, you will need to download source files. These source files are: By copying the above files, you have almost everything you'll need to build your own line sketch program. You are expected to complete the sketch program by providing two missing functions using the code templates. There are comments in the two template files that will help guide you in writing your own subroutines. 

You will also need appropriate files to compile and link your program.  A copy of the Microsoft .Net solution setup is provided here:

Run the Example Sketch Tool

A working example is available:

PC-windows

Run the example working sketch tool to see how your program should work.

The user interface to the program is provided through mouse buttons and keyboard keys:

The Code You Write

You are expected to write two new functions based on the templates provided in the files line.c and triangle.c:
  1. Write a line rendering function that uses the DDA algorithm to draw lines, with smooth color interpolation.  Note: You must use DDA.  You cannot use Bresenham's algorithm,  nor the mid-point algorithm, etc.  You are welcome to adapt the DDA algorithm shown on page 95 in the textbook.
  2. Write a triangle fill function that fills scanlines within the triangle.  Your function should provide at least flat shading of triangles: fill each triangle with the color given for its first vertex. Note: You must use the DDA in your triangle draw and fill algorithms. You cannot use the polygon scan fill algorithm given in the textbook.

Extra Credit (Required for CS680 Students)

For extra credit, change your triangle fill to allow smooth shaded area fill, given vertex colors.  To see what is meant by this, take a look at the working example sketch tool. Hitting the S key toggles smooth shading on and off.

Test Cases

A number of test cases are provided. To toggle between the triangle test cases, press the T key. To toggle between the line test cases, press the L key.  You can preview these test cases in the working example sketch tool, and compare the results with those of your own implementation.

Demo

Part of your grade for this programming assignment will be based on your giving a short demo (5 minutes) in the CS computer cluster. You will be expected to talk about how your program works, and we will see how well your program performs on the aforementioned test cases, an perhaps some additional, surprise test examples. Demos will be scheduled during the lab section meetings, after the due date.   You will be asked to sign up for a demo slot on a signup sheet that will be circulated in class before the assignment due date.
 

Source Code Submission

Your program's source files are to be submitted electronically. Use the gsubmit program on the CS cluster.  At present, gsubmit is only available on csa.bu.edu and the Sun workstations in the CS lab. This probably means that you will need to telnet to csa.bu.edu to submit your program for grading.

The code you submit should conform with the program assignment guidelines.

Grading (Out of 100 points)

CS480
 

Working line drawing, with vertex color interpolation
40 points
Working solid fill of triangles, all orientations 40 points
Programming style  20 points
Smooth, interpolated triangle fill 10 extra credit points

CS680

Working line drawing, with vertex color interpolation
35 points
Working solid fill of triangles, all orientations 25 points
Smooth, interpolated triangle fill 20 points
Programming style  20 points

Additional Extra Credit CS480 and CS680


Texture mapped triangle fill, all orientations, all cases 10 points

Late Assignment Policy

Late programming projects and problem sets will be levied a late penalty of 10% per day (up to three days). After three days, no credit will be given.

Collaboration/Academic Honesty

All course participants must adhere to the CAS Academic Conduct Code. All instances of academic dishonesty will be reported to the academic conduct committee.

Stan Sclaroff 

Created:  September 12, 2005