CMPS 161: FINAL PROJECT
by Brian Cooley-Gilliom

physics model of spheres bouncing on terrain --


sphere physics in action

USING SPHERE PHYSICS --

This program is pretty staightforward to use.  The user starts by specifying the adjustable feilds that
    define the physics of the scene.
The controls to the left change the scene.

Phase - changes the phase of the sin wave.

Freq - changes the frequency of the sin wave.  Actually, I think its really the amplitude.

Bounce - changes the bounce coefficient of the sphere.

GridSize - changes the size of the terrain

Squares - changes the size of the individual polygons in the terrain.

Radius - changes the raidius of the sphere.

Sine - turns the sin/cos function on or off.  The user mus press load for the changes to take effect.

Parabola - this function is not yet implemented.

load - the user must press load to initialize the scene and for other changes to take efeect, such as:
                    grid size, squares, phase, frequency, normals, and sin.

play - starts the animation. pressing the button a second time will pause.  If the sphere goes beyond
                    bounderies of the scene, the scene will reload.  if the user presses load while in play mode
                    the scene will still reload and immediately start playing again.

normals - turns the normals of the polygons on and off.  sometimes it is usefull to see the normals, because they determine which way a ball bounces.

View controls include the following:

The top rotate and translate control the camera.  The x, y, adn z controls affect the various axes.

the next two down control the rotation and translation of the sphere.  It is not recommended to adjust the rotate feild for the sphere.

vector controls - The user can set the intial velocity of the sphere.  The velocity chosen is represented by a yellow line that emerges from the sphere.

quit - exits the program.
 

Intention -

    Originally, I had intended to implement behavior physics with many spheres on terrain.  However, I found it quite challenging to even get the
physics for one sphere to work. Collision detection did not work the first way I tried it, which was to check the distance between the sphere and
a point that was generated by the smae mathmatical function as the terrain, using the coordinates of the sphere.  This did not work because I allow the user to
change the "resolution" of the terrain.  The points generated by the method assumed that every point represented by the function also had a corresponding polygon.
Thus,  the sphere would often fall through the terrain or hit invisible objects.

    This lead me to try trilinear interpolation.  This also had its set of problems for me.  Although the sphere bounced off the terrain much better,
it took a long time to actually get the interpolation to actually produce acurate results.

My main problem throughout the program, and still is getting the sphere to bounce off at the right angle.  For the normal vectors, I used the polygonal normal vectors,
Since i needed quick computation on the sun computers.  However, since my quads were not planar, the normal vectors did not always represent the surface of the entire polygon.  If I had to do it again I would certainly start with triangles instead of rectangles.

WHAT I ENDED UP WITH -
    the physics despite my problems ended up looking fairly good.  On a closer look , one can tell the ball doesn't always bounce in the right direction.
 

              Here Are Some More Screenshots:


what the user sees.

adjusting the velocity.