Stanford
University, Fall 2015, CS
448Z: Physically Based Animation and Sound
Assignment
#0: Audiovisual code warm-up using openFrameworks
Due:
Sunday, Oct 4, 2015
Goal: In this preliminary assignment, you
will implement an interactive audiovisual simulation of a
simple particle system in openFrameworks. The goal of this
assignment is to ensure that everyone has basic coding
functionality before we start a nontrivial animation-sound
assignment.
In the following steps, you will implement a dynamic
particle system of N balls. You can use 2D or 3D depending on
your graphics preferences:
- Implement
the basic graphics framework to draw N balls on the
screen, and maintain the position/velocity state of each
spherical object.
- Making
the particles move: Implement a symplectic Euler
integrator which (as discussed in class) updates the
particle velocity using applied forces, then updates the
particle position. You can use random initial velocities
(of a suitably bounded magnitude) to get started. Include
a downward gravitational force.
- Wall-particle
collision detection and response (or "staying inside the
box"): The particles are currently not constrained
to stay inside the computational cell. Implement a scheme
to detect collisions with the four walls, and modify the
velocity to provide simple collision response, using a
(particle-specific) restitution coefficient to attenuate
normal velocity. Be careful how you update your particle
velocity/position or you might find your particles sinking
into the floor.
- Adding
sound: Everytime a ball hits a wall, you should play
a suitable "click" sound to indicate that an impact was
made, with amplitude proportional to the collision impulse
magnitude. Next, to avoid all collisions during a
time-step producing "clicks" at the same time-step-size
dependent instant, you can estimate the time of ball-wall
collision more accurately, and shift the "click" sound in
the sound buffer. As an implementation detail, you
can use a circular sound buffer to additively composite
sounds into, then regularly xetract the next output sound
clip (of suitable "buffer size"). See the documentation on
how to stream sounds from a real-time application. Your
sound should play clearly and without noticeable audio
artifacts.
- Make it
interactive: You can pull particles around by
applying forces to particles near your mouse position. You
can also change, e.g., rotate, the direction of gravity
using keyboard controls to make all the particles move.
For this first warm-up assignment, feel free to ask
questions on Piazza about the openFrameworks software system
if you cannot find answers in the documentation or on the
website.
Submission: Please upload your implementation and a
very brief note about your findings as a zip file to your HW0
entry in Canvas.