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

Saturday, March 9, 2013

HW6 - Frame Buffers

I altered MISapplet to reinitialize values if the animation window changes size. In my java programs I store my own pixel values at a set resolution so I can stretch the animation window without breaking the code or increasing computation. I also store my own array because short of overriding computeImage, you can not nicely alter the pix[] array. To aid my computations I added the method set(int,int,int,int,int,int,int,int,Matrix) in Matrix.java to copy the contents from a part of one matrix into a part of another.


Fun With MISapplet 

  • spacebar ] : change exponent (toggle between bulb and brot)

MISapplet - Mandelbulb

This is my first MISapplet that animates the Mandelbulb and Mandelbrot set. It takes about 2 minutes to generate 600x600 resolution so instead I read the image from a file (URL) of precomputed values. Reading from the URL shouldn't take more than a couple seconds. If you are compiling and running directly from your computer, you may need to change java permissions to read from a URL. The zip download below includes a file called applet.policy that does this. When executing the appletviewer command, add the flag

-J-Djava.security.policy=applet.policy

The code lets you either read the image from a URL, read the image from a local txt file, or generate the image. The latter two are commented out. The txt files are available for download separately.



Backward Triangles

  • arrow keys ] : x,y rotation speed
  • wasd ]  : x,y in-place rotation speed
  • [ / ] : stop rotation
  • spacebar ] : reset screen

MISapplet - Triangulation

If a triangle is facing forwards I fill it in. If one is facing backwards I only draw the edges.


___________________________________________________________________________________

Wednesday, March 6, 2013

HW 5 - Geometrical Hierarchicy


  • arrow keys ] : x,y translation
  • / ]  : toggle rotation
  • click ] : add a new layer to the tree
  • space ] : reset screen
Applet


I have a lot of added methods so here is the documentation for Matrix, Transform, and Geometry objects.


___________________________________________________________________________________
HW5 Package
HW5_szymczak.java
Matrix.java
Transform.java
Geometry.java