CS430 Homework Assignment 3
Programming Problem:
1. In this assignment you will read polygons from the input file. The
polygons will be clipped to and drawn inside the viewport. They will
be drawn as filled polygons.
2. Modify your HW2 program to:
- Read a file containing an arbitrary number of polygons.
- Perform polygon filling (scan line algorithm, no flood filling).
- Write your pixel buffer to standard out in PBM format.
The description of the PBM format can be found
here.
- Define the resolution of your output image to be 501 x 501.
- All the command-line options
implemented in HW1 should be supported,
plus the following which implement viewport mapping. You should be
able to process any subset of the options in any arbitrary order.
- [-j] The next argument is an integer lower bound in the x dimension
of the viewport window (0)
- [-k] The next argument is an integer lower bound in the y dimension
of the viewport window (0)
- [-o] The next argument is an integer upper bound in the x dimension
of the viewport window (200)
- [-p] The next argument is an integer upper bound in the y dimension
of the viewport window (200)
- The viewport coordinate system origin is in the lower left corner
of your image. The X direction is to the right, and the Y direction is up.
- You may assume that the viewport parameters are greater than or equal to zero, and less then or equal to 500.
- Clipping should occur along the outer boundaries of the world
window using the Sutherland-Hodgman algorithm from HW2.
- Map the clipped geometry inside the world window into the
viewport and scan-fill it there.
- Your new program should be named CG_hw3.
- Steps in assignment
- Read in polygons
- Apply 2D transformations to them in world coordinates
- Clip polygons to world window
- Apply world-to-viewport transformation to the clipped polygons' vertices
- (You can also apply the w-t-v transformation before clipping.
You would then clip the transformed polygons to the viewport window)
- Round polygon vertices to integers
- Scan fill transformed polygons into software frame buffer
- Write frame buffer to PBM file
- You can test your program with hw3.ps.
- If you are having problems with dangling edges from the
concave shape or a with the overlapping edge in the "0",
this file has broken
the "S" into three separate polygons and the "0" into two separate
polygons.
- The default option set for this assignment is equivalent
to this command line.
./CG_hw3 -f hw3_split.ps -a 0 -b 0 -c 250 -d 250 -j 0
-k 0 -o 200 -p 200 -s 1.0 -m 0 -n 0 -r 0 > out.pbm
- If the tester enters ./CG_hw3 > hw3_a.pbm
, the results should be the same as from the command line above, and
produce the following image.
PLEASE NOTE THAT THE BORDER IS NOT PART
OF THE OUTPUT IMAGE. IT HAS BEEN PLACED AROUND THE IMAGE TO HIGHLIGHT THE
POSITION OF THE VIEWPORT WITHIN THE WINDOW.
- Input/Output Example:
i. Input:
./CG_hw3 -f hw3_split.ps -a 0 -b 0 -c 500 -d 500 -j 0 -k 0 -o 500 -p 500 -s 1.0 -m 0 -n 0 -r
0 > hw3_b.pbm
ii. Output:
- Input/Output Example:
i. Input:
i. Input:
./CG_hw3 -f hw3_split.ps -a 50 -b 0 -c 325 -d 500 -j 0 -k 110 -o 480 -p 410 -s 1 -m 0 -n 0 -r 0 > hw3_c.pbm
ii. Output:
- Input/Output Example:
i. Input:
./CG_hw3 -f hw3_split.ps -a 10 -b 10 -c 550 -d 400 -j 10 -k 10 -o 500 -p 400 -s 1.2 -m 6 -n 25 -r 8 > hw3_d.pbm
ii. Output:
- Input/Output Example:
i. Input:
./CG_hw3 -b 62 -c 500 -d 479 -r 75 -j 139 -o 404 -p 461 -s .85 -m 300 > hw3_e.pbm
ii. Output:
- Input/Output Example:
i. Input:
./CG_hw3 -a 275 -b 81 -c 550 -d 502 -r -37 -j 123 -k 217 -o 373 -p 467 > hw3_f.pbm
ii. Output:
- Input/Output Example:
i. Input:
./CG_hw3 -d 301 -c 435 -b 170 -a -100 -r -23 > hw3_g.pbm
ii. Output:
- Input/Output Example:
i. Input:
./CG_hw3 -a -135 -b -53 -c 633 -d 842 -m -23 -j 101 -p 415 -s 3.6 > hw3_h.pbm
ii. Output:
3. Grading Scheme
- Previous features : 2 points
- Clipping operations
- Transformations
- Windowing
- Input file reading : 1 point
- Viewport mapping: 2 points
- Polygon filling : 5 points
4. Submission Guidelines:
- Assignments must be submitted via Bb Learn.
- README file: explain the features of
your program, language and OS used, compiler or interpreter used,
name of file containing main(), and how to compile/link your program.
Text files only. Word and PDF documents will NOT be accepted.
- All source code. Your code must compile and run
on tux (Linux).
- You may program in any language you like as long it can produce
a usable executable named CG_hw3 on tux.
- Your program will be run by the TA. Please do
NOT submit any image files, Visual C++ project files, or anything not requested
in this section. Your program must run on tux without the
installation of "special" libraries.
- Makefile: have the default
rule compile your program.
- If you are using a language that doesn't produce an executable file,
e.g. python, then be sure to include a script called CG_hw3 that
accepts arguments and prints PBM to standard out.
- Points will be deducted if submission guidelines are not followed.
- Further details about Bb Learn
- You can reach Bb Learn through DrexelOne.
- Choose Computer Graphics among your list of courses. There is an "assignments" link in
the left frame which will give you the list of assignments in the right frame.
- Click on the assignment you wish to submit.
- Find your file and click Upload button.
- Hit Submit button. DO NOT FORGET TO HIT THE SUBMIT BUTTON AFTER YOU UPLOAD ALL YOUR FILES.
NOTE: Your source code for all programming assignments will be run through
a plagiarism detection system. This program uses compiler techniques which
are invariant of syntax and style. If you are sharing code with other classmates,
you will get caught. Please refer to the student
handbook for actions that will be taken.
Last modified on October 18, 2021.