Sunday, March 31, 2013

HW7 - Normal Shading


In my Geometry class, I added a Matrix normals and a method compute_normals to store and compute the normals at each vertex, respectively. I added a few helper methods in my Matrix class, namely add, subtract, and cross_product. Shading is all done within the HW7_szymczak.java file -- explained within the comments.

I explicitly typed the normals for spheres, rectangular prisms, and 2D shapes. In the applet, the difference in color (eg. between the sphere and klein bottle) is due to the polarity of the face directions and is dependent on how the parameterizations are defined; Notice how the inside of the klein bottle is shaded similarly to the sphere. This is easily rectified by multiplying the normals by -1 for the incongruously colored shapes. I left the applet uncorrected for visual effect.

The object of the game is to use the paddle to block the balls from passing below the bottom edge of the screen. The game is initially paused.

  • spacebar ] : pause/unpause the game
  • [ left/right ] : move the paddle
  • [ / ] : increase size of balls
  • [ . ] : decrease size of balls
Applet
If you make the balls really big (hold down '/'), then you may notice that the shading isn't perfectly smooth. Unshaded lines plague the shapes, creating a scratchy look. There is something wrong with my fillTriangle method; I must be neglecting to fill in a line of pixels (off by one error). This was not an issue in HW6 -- but I completely revamped the code and I have yet to find the problem. 
PROBLEM FIXED** XR (as defined in the class notes) gets truncated when you cast it as an int. So you have to shade pixels from XL to XR+1.
___________________________________________________________________________________
Package
HW7_szymczak.java
Geometry.java

No comments:

Post a Comment