Homework Assignments and Answers to

Foundation of 3D Graphics Programming
Using JOGL and Java3D

Chen, Jim X., Wegman, Edward J.
2006, 310 p. 173 illus., 34 in colour., Hardcover
ISBN: 1-84628-185-7

Copyright @ Springer Verlag 2006

Setting up programming | Sample programs


1. Chapter 1

Review Questions
A(a1,a2,a3) and B(b1,b2,b3) are two vectors; please calculate the following:
a. b. c. d. e. q between A and B
Please fill in the blanks between the two sides to connect the closest relations:
a. frame buffer ( ) 1. animation
b. double-buffering ( ) 2. pixmap for display
c. event ( ) 3. user input
d. graphics library ( ) 4. distance between pixels
e. scan-conversion ( ) 5. description of an object
f. resolution ( ) 6. basic graphics functions
g. 3D model ( ) 7. drawing
What is provided by the Animator class in JOGL?
a. calling reshape() b. implementing interface functions
c. calling display() repetitively d. transforming the objects
Which of the following is a graphics model?
a. a picture on the paper b. a pixmap in the frame buffer
c. a data structure in the memory d. an image on the display
What's the difference between bitmap fonts and outline fonts?
a. Outline fonts are represented as 3D models b. They have different sizes
c. Bitmap fonts are represented as 3D models d. They have different colors
What are provided by the JOGL's GLUT class?
a. bitmap and stroke font methods b. antialiasing
c. calling reshape() or display() d. handling display area
The Cohen-Sutherland line-clipping algorithm works as follows: (a) At a clipping edge, if both end points are on the clipping window side, they are accepted. If both end points are not, they are rejected; (b) if not accepted or rejected, the line is divided into two segments at the clipping edge; (c) repeat (a) and (b) for the segment that is not rejected on the other three clipping edges. For an arbitrary line, what is the maximum number of comparisons and intersection calculations?

Comparisons ; Intersections .
The Sutherland-Hodgman's polygon-clipping algorithm works as follows: we walk around the polygon boundary to generated a new clipped polygon represented by a list of vertices. For each boundary edge, (a) At a clipping edge, if both end points are on the clipping window side, they are accepted. If both end points are not, they are rejected. If accepted, the vertices are in the new polygon. If rejected, they are discarded; (b) if non-trivial, the intersection on the clipping edge is a generated vertex in the new polygon replacing the vertex outside; (c) repeat (a) and (b) until all of the polygon's edges are considered; (d) repeat (a), (b), and (c) for the other three clipping edges to have a final clipped polygon. For a triangle, what is the maximum number of comparisons and intersection calculations?

Maximum ; Minimum .
Supersampling is to achieve antialiasing by
a. increasing sampling rate b. decreasing the sampling rate
c. using OpenGL antialiasing function d. calculating the areas of overlap
In the antialiased line algorithm, D is the distance from the center of the current pixel to the center of the line. Given D, please calculate the distances from NE and X pixels (DX and DNE).
In the antialiased line algorithm, d is the decision factor for choosing East or Northeast, and D is the distance from the center of the current pixel to the center of the line. Given the line starting (0,0) as in the figure, please calculate d and D for the dark pixel.
d = D =
In drawing a filled circle in the book, we start with 4 triangles. Please calculate if we subdivide n times, how many triangles we will have in the final circle.

Programming Assignments
Draw a point that moves slowly along a circle. You may want to draw a circle first, and a point that moves on the circle with a different color.
Draw a point that bounces slowly in a square or circle.
Draw a star in a circle that rotates, as shown on the right. You can only use glBegin(GL_POINTS) to draw the star.
Write down "Bitmap" using Glut bitmap font function and "Stroke" using Glut stroke font function in the center of the display.
With the star rotating in the circle, implement the clipping of a window as shown on the right.
Implement an antialiasing line algorithm that works with the background that has a texture. The method is to blend the background color with the foreground color. You can get the current pixel color in the frame buffer using glGet() with GL_CURRENT_RASTER_COLOR.
Implement a triangle filling algorithm for J1_3_Triangle class that draws a randomly generated triangle. Here you can only use glBegin(GL_POINTS) to draw the triangle.
Draw (and animate) the star with antialiasing and clipping. Add a filled circle inside the star using the subdivision method discussed in this chapter. You should use your own triangle filling algorithm. Also, clipping can be trickily done by checking the point to be drawn against the clipping window.

 


Copyright @ 2006 by Prof. Jim X. Chen, Department of Computer Science, George mason University