CISC440 S2016 HW2

From class_wiki
Revision as of 11:21, 18 January 2017 by Cer (talk | contribs) (Created page with "''Due Friday, March 18 at midnight'' (template code was posted at 12:10 am)<br> ==Description== This assignment is intended to acquaint you with 3-D drawing and animation in...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Due Friday, March 18 at midnight (template code was posted at 12:10 am)

Description

This assignment is intended to acquaint you with 3-D drawing and animation in OpenGL, as well as flocking-type particle systems. You are given template code (creatures.zip -- see instructions below) which simulates a simple system of creatures in a 3-D box. A base class Creature defines a generic boid with no specific behaviors, and the class Flocker is derived from it which instantiates Reynolds' flocking rules. When a creature leaves the box it is "wrapped" to the other side.

Keyboard shortcuts for camera control:

  • 'a'/'d': Change longitude of "orbital" perspective outside the box
  • 'w'/'s': Change latitude of orbital camera view
  • 'z'/'c': Zoom in/out
  • 'x': Return to default camera view

Drawing modes for rendering each flocker:

  • Space bar: Pause/unpause simulation
  • '8': Two orthogonal "arrowhead" polygons pointing in the direction of travel (DRAW_MODE_POLY)
  • '9': Just X, Y, and Z axes of the local "frame" of the creature (DRAW_MODE_AXES)
  • '0': A colored point at the creature's current position, as well as a fading history of recent positions (DRAW_MODE_HISTORY). The color indicates the current mix of the different behavioral forces on the creature's motion, with the red channel proportional to separation force, green proportional to alignment, and blue to cohesion.

Your job is to make several modifications and additions to the code, detailed below.

Required elements

  • In the empty Predator class also derived from Creature:
    • Fill in its draw() function with some primitives that make a complex, multi-colored 3-D shape which distinguishes it from flockers and show which direction it is going. (For this and the next item you will also have to make changes in main.cpp to construct ONE Predator object, draw it, and update it) [4 points].
    • Fill in its update() function (and make any other necessary modifications to member variables and the constructor) so that it chases flockers based on a hunger_force [4 points]
  • Modify the Flocker class so that it has a fear_force that makes it flee from Predators, with high priority, when they get close enough [3 points]. This does not necessarily need to be pure avoidance---there could be a different (e.g. zigzag) motion mode that is activated.
  • Add a keyboard shortcut 'f' (and supporting code changes) which allow the user to switch the camera view from orbital to an "over-the-shoulder" FPS-type view that moves with the Predator [4 points]. Hitting 'f' again should return the camera view to orbital.

Please include a README with your submission that briefly explains your approach to the Predator drawing and hunger_force, as well as the Flocker fear_force.

Graduate students only

  • Incorporate the loadOBJ() code from OpenGL tutorial #7 and use it to render Flockers with one kind of object (loaded once at start-up) when key '7' (DRAW_MODE_OBJ) is chosen. Ignore texture information -- just use a single color for the whole object or random colors for each vertex/triangle. Be careful to choose an .obj model that is not too complex for your machine's hardware -- here are some relatively simple ones [3 points]. Here is an improved version of the tutorial's loadOBJ() function that can handle a few more models (e.g., the teapot) from the page just mentioned.
  • Draw a vertical cylinder of radius 1 in the center of the box (it should go from floor to ceiling of the box). Make changes to both Flocker and Predator (1) spawning so that none are born inside the cylinder, and (2) motion behaviors to avoid this cylinder smoothly while still exhibiting their other natural behaviors [2 points]

This is worth 5 points. The apparent total possible of 20 will be multiplied by 0.75 to make 15 the maximum possible.

Install instructions

The download will unzip to a directory called creatures. This directory should be placed in the OpenGL tutorials hierarchy at the same level as the other tutorial and playground directories. To compile the code in it, you will need to target the creatures directory.

On Ubuntu, this meant modifying CMakeLists.txt and running cmake .. one time from the build directory. Then make creatures and launch-creatures.sh should work. Here is a link to the modified CMakeLists.txt -- let me know if it does not work for you.

On Piazza, please post what you need to do for XCode and Visual Studio if it is non-trivial.