Question 1:
ECE59500 Computer Graphics Assignment 3
Write a program to perform a scan line polygon filling algorithm. Fill the following polygon with the implemented fill algorithm.
1. 2.
Use the key SPACE to control the filling pixel by pixel, or Implement the pixel fill procedure with animation.
4
11
10
9
8
7
6
5
4
3
2
1
0
1
2
03
0 12345678910111213
Question 2:
Use bunny as the model, calculate each polygon normal by averaging the vertices¡¯ normal. Assume all polygons are planar and vertices are ordered in a counterclockwise order when viewing the polygons from the outside.
Construct an interactive program that allows you to position one or more light sources and to alter material properties. Write an OpenGL program to perform the following tasks:
1. Use mouse to control the number of light sources you would like to add in the scene. Right-
clicking increases the number of light sources by 1 and left-clicking decreases the number of light sources by 1. The minimum number of light sources is 1 and the maximum number is 5. (It is your choice of the light type and location.)
2. Use the keys ¡®M¡¯, ¡®P¡¯, and ¡®C¡¯ to select materials of Metals, Plastic, and Carbon correspondingly.
Question 3:
Write a program that allows the user to draw a B-Spline curve. Implement a way of directly getting the number and locations of control points (e.g. the user types the input into the windows console), then draw the uniform cubic B-spline polynomial curve determined by the control points that were entered.
Extra credits (20 points):
Write a program that allows the user to draw and modify, a B-Spline curve. There should be
a “B-Spline” menu item. When the user selects “B-Spline”, he/she should be allowed to input any number of control points with the mouse. Each click of the left-hand mouse button provides a new control point, which should be drawn as a small rectangle on the screen. A click of the right mouse button should then cause the program to draw the uniform cubic B-spline polynomial curve determined by the control points that were entered.
After the B-Spline is drawn, the program should enter a mode in which it permits the user to use the left-hand mouse button to adjust the curve by moving any of its control points. Pressing the left-hand mouse button over a control point selects that point. While the button is down, the user moves the mouse to the new position of the control point. Releasing the left-hand button should cause the control point’s rectangle to be repositioned at the new cursor location and the B-Spline curve to be redrawn. (The old control point and curve should, of course, disappear.) The user should be able to perform this readjustment of the curve as many times as desired with any of the control points. A click of the right-hand mouse button should permit the user to go back to the menu to choose another option.
Extra Credit (20 points):
Add a “Translate” menu item–Choosing this menu item should enable the user to translate the B- Spline curve in the drawing area. Subsequently the user should be permitted to click somewhere in the drawing area. The point selected will be the new location of the first (P0) control point of the B-Spline curve. The program will then move P0 to the selected location and all the other control points will then be translated by an equal amount. Finally the curve will be redrawn according to the new locations of the control points.
“Scale” or “Rotate” menu items should enable the user to change the size or orientation of the B- Spline curve. Selecting either of these two menu items should allow the user to click on some point in the drawing area. The curve should then be scaled with respect to that point or rotated about that point by a fixed amount. The details of how this is done are up to you. Try to make it as intuitive and user friendly as possible. (You may want to use “Scale Up”, “Scale Down”, “Rotate Clockwise”, and “Rotate Counter Clockwise” menu items here.)
“Extend”–Each time this menu item is selected, the program should allow the user to input one or more new control points (with the mouse) that will be used to attach new B-Spline curve segments to the end of the previous B-Spline curve, thus extending it.
Notes: Provide source code listings, with documentation explaining what your code does.