CISC440 S2021 HW3

From class_wiki
Revision as of 05:09, 6 April 2021 by Cer (talk | contribs) (Created page with "''Due Thursday, April 15'' ==Description== This assignment is intended to acquaint you with flocking-type particle systems and physics simulation using the [http://bulletph...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Due Thursday, April 15

Description

This assignment is intended to acquaint you with flocking-type particle systems and physics simulation using the Bullet library. You are given template code (bullet_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
  • '7': Textured .obj model (DRAW_MODE_OBJ). Orientations are all identical in the template code. Choose model from "cube", "suzanne", or "banana" via command-line flag (e.g. "bullet_creatures banana")
  • '8': Two orthogonal "arrowhead" polygons pointing in the direction of travel (DRAW_MODE_POLY). This is the default
  • '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. This draw mode does not update properly in physics mode (see below)

Pressing the 'p' key toggles "physics" mode. In the template code, odd-numbered presses cause the flocking to stop and all of the boids to fall under the influence of gravity until they hit the bottom of the box. Even-numbered presses remove the gravitational force and allow flocking to resume.

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 such that it can clearly be distinguished from the flockers. This can be as simple as copying flocker drawing code and changing the color scheme (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) [2 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 [3 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.
  • Modify Bullet_Utils.cpp so that:
    • The velocity of each flocker is transferred to the corresponding rigid body when switching to physics mode [2 points]
    • A pair of the vertical sides of the box become obstacles like the ground [2 points]

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

  • Modify copy_flocker_states_to_graphics_objects() and copy_graphics_objects_to_flocker_states() in Bullet_Utils.cpp so that 3-D orientation information is properly transferred back and forth between the graphics side and the physics side of the simulation. This means that in DRAW_MODE_OBJ your models should be drawn at different orientations [2 points]
  • 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]. The cylinder should drawn with solid polygons (not wireframe) in a striped or checkerboard pattern with colors that contrast with the boids.
  • Add the cylinder as an obstacle in the physics mode, so that it can be collided with. [2 points]

This is worth 5 points. The apparent total possible of 18 will be multiplied by 2/3 to make 12 the maximum possible.

Install instructions

The download will unzip to a directory called bullet_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 bullet_creatures directory.

On Ubuntu, this meant modifying CMakeLists.txt and running cmake .. one time from the build directory. Then make bullet_creatures and launch-bullet_creatures.sh should work. Here is a link to the modified CMakeLists.txt -- let me know if you are still confused about what changes to make.

Submission instructions

Submit a zipped version of your modified bullet_creatures directory. Clean it up before submission -- it should only contain .cpp, .hh, and shader files.