Comp 175 Final Project

I’ve always been intrigued by fractal geometry, and basically anything that can be created algorithmically. The creation of 3D fractals seemed like a natural fit, and since my focus is in HCI, I decided to play with the user input as well. Both of these decisions opened up interesting complications.

Originally, the plan was to deal with a fractal that expands from a central point, exploding off a face of the previous iteration. However, after a proof of concept, this seemed less than optimal since the user could only focus on one arm of the fractal at a time. At that point, I decided to switch to reductive fractals, starting with the 3D version of the Sierpinski Triangle.  Since time allowed, I also added in a 3D version of the Box Fractal.

Very early on, it became obvious that the GLUT implementation for user input was a spectacular failure.  It seems as if it’s polled rather than interrupt-driven, and the polling interval is awful for realtime interactions, in particular with the mouse.  After tinkering and doing some research, SDL was continually referenced as a standard and reliable library.  Getting it to compile properly under a terminal in OSX was a little quirky, but once all the kinks were worked out it performed (almost) flawlessly.

I decided to run the program in a tight loop, and this makes the user input very dependent on the frame rate.  This is the cause of the “almost” in the prior paragraph.  It results in some jerky movement at high levels of recursion, and can result in lost inputs on occasion.  It is, without question, leaps and bounds above the standard GLUT options, but it still isn’t quite perfect.  I debated rate limiting it so there is a consistent frame rate, but as it is, gross repositioning is fast and easy when the recursion level is low.  However, if I were continuing the project, smoothing out the input is one of the first places I would start.

Since the performance is inconsistent, I decided to run with a bounding box style collision detection.  It’s a little hackish, but it’s quite cheap.  This seemed to be quite important at the higher levels of recursion.  In a bounding box setup, boxes are drawn at the extremities of an object and collisions are based off those faces (which align with the XYZ planes), and camera movement is refused if it would be placed inside one of the boxes.  I decided not to implement it on the Sierpinski version because the box drawn around the tetrahedron would severely limit movement inside the fractal.  With the box fractal the bounding box lines up exactly on the cubes, so this wasn’t an issue.  Though functional, this is another place that I would make adjustments if I were continuing it further.

The camera controls of the program follow the standard first-person shooter controls:  WASD for movement (forward, left strafe, backwards, right strafe) and the mouse for looking.  Note that it is standard view, with mouse movement up adjusting the view up.

The fractal controls are fairly basic.  “-” switches to the Sierpinski fractal, and “=” switches to the box fractal.  When viewing a fractal, the number keys control the level of recursion.  Note that the maximum recursion for the Sierpinski fractal is 6, and the maximum recursion for the box fractal is 4.  They are controlled independently, so setting one recursion level will not affect the other fractal at all.

Screenshots:

Code and Instructions:

Since OpenGL and SDL are cross platform, building this on something other than OSX 10.5.8 should hopefully require minimal changes.  However, that has not been tested.

Assuming 10.5.8 with the proper frameworks installed, building and running it should be as simple as “tar xzvf project.tar.gz”, “make”, “./project”.

Download Project

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*