CS148 PP5: AliBaba
Jeremy Slade


Concept
-------

You control a flying magic carpet, pursuing Ali Baba and his 40
thieves across the desert.  The object is to kill all of the thieves,
by lobbing exploding coconuts at them, before they make it to the
safety of their cave.


Controls
--------

Accelerate: W
Decelerate: S
Turn left: A
Turn right: D

Pause: ESC, then click on Quit to exit

Lob coconut: left mouse click


For testing / demo purposes:
- press C to warp to the cave,
- then press SPACE to open the cave to see the cool lighting
  effects.


Project requirements
--------------------


* 3-D animated scene
  o Time-based animation

	Game loop uses glutTimerFunc() for time-based callbacks.  It
	was suggested in the class to use glutIdleFunc(), but that
	causes the program to starve the event queue, so the user
	feels like the program lags.  I set the app to try to hit
	a target frame rate (18fps) instead of just trying to refresh
	as fast as possible.

  o Playable on slow computers

	Run the program with -slow option.  This disables some features
 	such as fog, and reduces the terrain detail.  Works well enough
	on my PII/366 laptop with no hw acceleration (~8fps)

  o Viewing transformation changes

	Camera follows the magic carpet, maintaining a first-person
	perspective.  Notice also that the perspective changes when
	speeding up or slowing down.


* Colored and shaded objects with lighting

  o Multiple light sources

	Uses global ambient light, plus an overhead 'sun' for primary lighting.
	Additional lighting is used for the explosions, and to emit a
	glow from the thieves' cave.


  o At least one light source should move

	The explosion lightings occur at different locations,
	obviously.  Also, the lights used to light the cave move up
	and down as the cave opens and closes.


  o Include ambient, specular, and diffuse lighting

	Use different colors for diffuse, ambient, and specular lightings
	on the explosions, gives a very nice effect


* Texture mapping

  o At least two objects, one a polygonal mesh

	Texturing is current applied to the rock walls, and to the
	carpet.  Text mapping is sort-of applied to the riders / horses,
	but I did not have time to make that look presentable.

	For the rock walls, the texture coords are computed directly.
	The carpet is computed using a 2D mesh evaluator, which does
	both the vertices and tex coords simultaneously.

  o Mipmapping

	Both the carpet and the walls are set up for mipmapping.  It
	is not visible for the carpet, since the distance to the
	carpet is essentially constant.  It is possible to see the
	changing level of detail from mipmapping on the walls,
	however.


* OpenGL picking

	Picking is used to implement the quit/restart menu (brought up by
	pressing ESC).


* Multiple types of objects

	The walls and ground are rendered using GL_QUADS.

	The carpet is created using a 2D mesh evaluator.  The control
	points define a Bezier surface that waves in both the Y and Z
	directions (actually several different frames are constructed
	by evaluating the mesh with different control points that
	oscillate based on sin/cos)

	The thieves are polygonal meshes imported from a modelling
	application (AC3D).  I wrote a perl script (ac3togl.pl) to
	generate OpenGL code from the native AC3D file format.



Platforms
---------

I did the development primarily on linux, but also a bit on XP(with
cygwin).  I have included binaries for both platforms, along with the
necessary *.dll's to run on XP).




Other features
--------------

View-frustum culling is used to limit the ammount of rendering.  This
primarily effects the terrain, which is divided into a quadtree, and
only the leaves of the tree that are in the view frustum get drawn.

I used fog primarily to obscure the far clipping plane, but it gives a
nice effect of flying through a desert sandstorm.

I used alpha blending on the pause menu and on the explosions.

The radar, fps display, score, and reticle are all separate viewports.
Only the main view is a perspective / frustum view, the others are
ortho view.

When the coconuts hit the ground, they explode, and if a thief is hit
it is represented by random particles (blended points).

The thieves navigate on a simple algorithm: they have a goal (the
cave), and the heading w.r.t. that goal is checked periodically (.5
sec).  If not currently heading in that direction, it initiates a turn
to correct the heading.  If a bomb lands near a theif but doesn't kill
it, it will veer off quickly, as though running away.

When the thieves approach the cave, they say 'open sesame' and it
magically appears.  Once all the thieves in the vicinity have escaped
into the cave, it closes again.



Bugs / issues
-------------

Biggest problem left is with the model for the thieves.  If you look
closely, you will see a horse texture mapped onto the simple polygonal
model.  I just ran out of time to make that part look decent.  It is
difficult because a rider on a horse is such a organic thing,
difficult to model it simply and still achieve any sort of realism.
My final approach that I started on was mapping a complex texture onto
a simple polygonal model, and then using glAlphaFunc() to filter the
parts of the model that didn't get a texture applied.  Sounds good in
theory, but I couldn't get it to work so I gave up.

Some problem with the way the texturing is mapped to the ground causes
so overlap between the walls and ground along the edges, and the far
north wall where the cave is doesn't get any texturing...


Just for humor: my two sons (5 & 3) were very fascinated with the
game, anxiously following the development.  One night they were
sitting on my lap actually playing it, when the 5-yr-old puked up all
over my desk, keyboard, red book, laptop, etc (vertigo?)  That was a
bit of a setback :)


