CS 5643 Assignment #2: Position-based Dynamics
Professor: Doug
James
Due date: Friday Mar 28, 2014 (midnight)
![From [Muller et al. 2006]](posBasedDyn.jpg)
In this second assignment, you will implement a particle system
based on position based dynamics. You system will support a similar
position-level constraint-based relaxation approach to dynamic
modeling. The core system should support cloth simulation, and you
can extend it to add additional functionality of your choosing.
Groups: Work on your own, or in a group of at most two
people. Additional work is expected from a group submission, such as
a more elaborate creative artifact or modeled phenomena. PhD
students are encouraged to work alone, and pursue a more challenging
creative artifact.
Starter Code: This project has starter
code (available to registered students through CMS), primarily to augment
the cs5643.particles
package to represent triangle meshes for cloth modeling, loading of OBJ triangle meshes, and to
support OpenGL rendering. Several triangle mesh examples are
provided to help you get started. In this assignment, you will
modify this package as needed.
Software
Dependencies: The starter code will compile and
run using JDK 1.5 or later. In addition to Java, the starter
code also uses two other libraries that you need to install/get:
- JOGL and OpenGL: The base
program renders particle systems using JOGL (Java bindings
for OpenGL). You should download and install the
appropriate version on your system. Although you
can complete this assignment without writing any OpenGL, you
can find more information on OpenGL or JOGL, some random
introductory starting points are:
- Vecmath: 2D point and
vector primitives are used from the Java3D vecmath library.
You can download the full Java3D from here,
but you just need the
vecmath.jar library
(from here).
- Installation: To compile/run
Java will need the jars {gluegen-rt.jar, jogl-all.jar,
vecmath.jar}. To run the program make sure that the
directory containing the JOGL binaries is in your PATH (or -Djava.library.path=./dlls/).
For example, in Windows you will need to have {gluegen-rt.dll,
jogl.dll, jogl_awt.dll, jogl_cg.dll} accessible.
- Detailed
instructions on setting up JOGL that may be helpful are here.
Starter code tips:
-
The starter code are a set of triangle mesh
related classes already in the cs5643.particles package. They
can be dropped into the A1 particles starter code (or combined
your SPH fluid simulator).
Do I have to use the starter code?
Can I program in C++? etc.: The starter code is
provided to make your job easier, however you are not required
to use it. Feel free to implement your assignment in any
language or programming environment that you want (C++,
processing, python, etc.). However you are still expected to
implement the assignment steps listed below, and answer the
questions. You may not use extensive libraries for particle
systems or simulation since you are expected to implement the
functionality from scratch (that's the point and the fun of it).
However, please feel free to use any third-party graphics or 3D
rendering software that you want.
Assignment Steps:
- Getting started: Start by familiarizing yourself with
the starter code, and modify it to support the position-based
dynamics time-stepping scheme, as described in the PBD paper.
- Representing constraints: You should implement a
Constraint class or interface to represent equality and
inequality Constraints, and their associated stiffness value.
Design your representation so that it can support what you need
to do in later steps.
- Particle-plane collision constraints: To keep the
particles from passing through the floor, or leaving the
container, you need to implement position-based collision
response with the computational cell boundaries. For now, modify
the inner position-correction iteration so that the particle
position are kept from leaving the box when bouncing around
under the influence of gravity. You can implement each using a
general particle-plane inequality constraint (with strength
k=1), and then later reuse it for other plane constraints.
- Cloth constraints: Following section 4 of [PBD],
implement the core constraints and constraint gradients needed
for (1) edge-based stretching constraints, and then (2) bending
constraints. Formulae for evaluating nontrivial gradients are
available in the paper's Appendix. You should represent
each piece of cloth in your simulation using a Cloth Object,
with associated simulation parameters and constraints. Cloth
vertex/particle mass should be computed using the density of the
cloth, rho, times 1/3 of the sum of the surrounding triangle
areas. Implement the position updates associated with
stretch and bend constraints, using iterative Gauss-Seidel
updates. Make sure to support multiple constraint passes per
time-step for best results.
- Damping: Implement the "rigid damping" approximation
(described in section 3.5) to shed energy from individual cloth
objects. While you could just implement a simple damping force,
such as f = -c*v, or a velocity-scaling filter (e.g., "v *=
0.9999"), these trivial models produce an "underwater" damping
effect, whereas the "rigid damping" model does not damp
rigid-body motion.
- Interaction constraints: Implement a position-level
mouse constraint to allow you to pull on cloth vertices. Your
simulation should remain stable during the interaction. You will
need to need to support particle picking, by finding the
particle closest to your mouse position. This can be implemented
in many ways, but probably the easiest is to determine the line
associated with your mouse position/ray, and then scan all
particles to find the particle closest to that line using 3D
geometry. The mouse particle goal position can be determined by
mouse position changes in the parallel view plane.
- Attachment constraints: Pin constraints should be
implemented, so that vertices can be fixed in space and/or
attached to other moving objects. This can be achieved using
position-level updates, and by setting the particle inverse mass
value, w, to zero, i.e., giving it infinite mass. You should
provide an example with cloth suspended in space, e.g., a
rectangular piece of cloth hanging from two corners.
- Balloon constraints: To simulate closed objects with
air inside, such as a inflatable ball, implement the "cloth
balloon" constraint (see section 4.4).
After you get the basic simulator working, you should try adding
something unique to your submission:
- Animate something: Use your simulator to implement at
least one nontrivial animation scenario. You can use the OBJ
mesh loader to load a variety of meshes that you can either
build, or download (e.g., from TurboSquid), to help you build an
interesting scenario. Setting initial positions and velocities
of your objects, can be used to create interesting setups, e.g.,
crash scenarios, running objects through gears, etc.
- Collisions with rigid obstacles can be approximated
using local vertex-plane constraints as described in the paper.
In order to detect collisions for purposes of generating
time-step-specific constraints, you should use a spatial
acceleration data structure, such as a bounding volume hierarchy
(BVH) or (uniform) spatial subdivision. Robust collision
responses with rigid obstacles will enable you to implement
challenging scenarios (such as the example shown in Figure
1). Alternately, collisions with volumetric rigid
obstacles can be implemented robustly if you can tell if a
vertex is inside or outside the object, since then you can then
detect and "push" vertices to the surface during the constraint
projection phase. Implicit function definitions (such as for a
sphere), or signed distance fields, can be useful
representations for volumetric objects.
- Cloth self-collisions can be approximated as described
in the paper. However, these can be more complicated to get
working properly, and are not a required part of the project.
Only implement self-collision constraints last, after you have
finished other parts of the assignment and still want an extra
challenge.
- Just add water: If you are feeling ambitious, you can
combine your cloth simulator with the previous Particle Based
Fluids implementation from assignment #1, which is also in the cs5643.particles
package. You will need to implement fluid-cloth particle
collisions to ensure that fluid particles do not pass through
the cloth, and that contact-based momentum is transferred
between cloth and fluid particles.
- Interactive modification of simulation parameters (such
as constraint "stiffness," or cloth density, gravity, etc.) can
be implemented using GUI sliders, etc., and can enable fun
interactions.
Hand-in using CMS:
- A brief written document (in txt or PDF) that details what you
did, your findings, and who you discussed the assignment with,
etc.
- Include comparisons or analysis/results demonstrating the
behavior of your implementation.
- Citation:
- Include the names of everyone that you discussed the
assignment with.
- Include citations of external resources (books, webpages,
etc.) that you used in your R&D.
- Documented software implementation derived from the Java
starter code, or based on an analogous framework in another
language, e.g., C++.
- Your creative simulation artifacts, videos, images,
etc.
- We will run your software to evaluate your implementation,
and/or ask you to provide a demo. However including
videos that demonstrate the requested features, and
interesting behavior are strongly encouraged.
- If you are working with a partner, be sure to form a
two-person group, and submit your zip file as a group.
- Regarding requests for extensions because "I have another
deadline on that day" or "I think I may have to use the bathroom
at midnight": Please start early, and budget your time to do the
many things you need to do. The deadline is not when you do your
work, it's when you should be done by.
- Late days will be granted at a default 5%/day penalty. Please
plan ahead to minimize unnecessary deductions.
Start early. Ask questions. Have
fun!!!
On collaboration and academic
integrity: You
are allowed to collaborate on the assignments to the extent of
formulating ideas as a group, and derivation of physical equations.
However, you must conduct your programming and write up completely
on your own (or with your partner), and understand what you are
writing.Please also list the names
of everyone that you discussed the assignment with. (You are
expected to maintain the utmost level of academic integrity in the
course. Any violation of the code of academic integrity will be
penalized severely.)
References:
- M. M�ller, B. Heidelberger, M. Hennix, J. Ratcliff, Position Based
Dynamics, Proceedings
of Virtual Reality Interactions and Physical Simulations
(VRIPhys), pp 71-80, Madrid, November 6-7 2006, Best Paper
Award, PDF, (video), (slides)
- Jos Stam, Nucleus:
Towards a Unified Dynamics Solver for Computer Graphics,
2009 Conference Proceedings: IEEE International Conference on
Computer-Aided Design and Computer Graphics, pp. 1-11, 2009. (related talk)
- T. Jakobsen, Advanced
Character Physics, Game Developer Conference, 2001.