In this assignment, you will implement two techniques for computer animation: keyframe animation of articulated characters, and physics-based simulation of mass-spring systems. Use the code provided at https://git.iitd.ac.in/col781-2302/a4 to display the computed animation.

There are three required tasks and three optional tasks. Students
working in pairs are required to do all three required tasks
**and** at least one of the three optional tasks. For
students working in pairs, the optional tasks are not necessary but can
give up to 10% extra marks.

Design an articulated character composed of several bones connected with hinge joints. Attach one or more fixed meshes to each bone, each of which is translated rigidly by the bone’s transformation. Animate the character’s motion by keyframing the hinge angles.

- Each bone may be specified by a pointer to its parent bone, the position (in the parent bone’s coordinate system) where it is attached, and the rotation axis of the joint. The character’s pose is then determined by the root bone’s translation vector and rotation quaternion, and the hinge angles of all joints.
- Try to make your character have a realistic skeleton hierarchy with a reasonable number of bones and joints. Submissions with 3 or fewer bones, or with a hierarchy depth of 1 (e.g. everything being a child of the root), will definitely lose marks.
- Design the character’s motion by manually specifying the pose at various keyframes, and interpolate them using Catmull-Rom splines. Work out the correct derivative formula for keyframes that are not equally spaced in time, instead of the simpler formula given in class. Show the animated motion of your character using at least 5 keyframes.
**Optional task:**Implement inverse kinematics, so that your character can be animated by directly specifying the positions of the end effectors.- Let the root bone’s translation and rotation still be set by keyframing, and only compute the hinge angles through IK. Note that if you want to be able to achieve an arbitrary 3D position, you will need at least 3 joints with different axes between the root and the end effector.
- Refer to Bill Baxter’s slides which explain several methods to solve the IK problem, or the FABRIK algorithm which is more recent. Choose any technique and implement it.
- Demonstrate your implementation by showing an example of a motion that would be hard to achieve by manually specifying joint angles, e.g. a character’s hand moving in a perfect circle.

Implement a mass-spring system for simulating a single sheet of cloth. To do this, you will create a collection of particles in a grid layout, connected to nearby particles with springs. Also add a gravity force acting on all the particles, and allow some particles to be labeled as “fixed” in space so that they never move. Perform time stepping using the semi-implicit Euler scheme.

- The spring constant of shear springs should be less than that of the structural springs, and that of bending springs should be much less. For each type of spring, the damping constant should be much less than the spring constant.
- You may evaluate the damping forces using the current particle velocities, i.e. \(\mathbf f(\mathbf x^n,\mathbf v^n)\) instead of \(\mathbf f(\mathbf x^n,\mathbf v^{n+1})\), so that you don’t have to solve a system of equations to do time stepping.
- Your implementation should be generic enough that you are able to simulate sheets of different sizes (physical length and width), different resolutions (number of particles), and different material properties (mass density and stiffness).
- Demonstrate your implementation by simulating a 1m × 1m sheet of cloth, initially horizontal with two adjacent corners fixed, swinging down and then back and forth under gravity. Tune the simulation parameters so that the motion looks somewhat realistic, although it may be a bit stretchy.
**Optional task:**Replace the structural springs with inextensible constraints, and use position-based dynamics to simulate them. Since the shear and bending springs are much weaker, you can still evaluate their contribution explicitly as before. Only use constraint projections for the structural edges.- You will need to do multiple iterations of the PBD loop to ensure that all constraints are close to satisfied. Tune the iteration count to get a cloth that does not significantly stretch.
- Refer to the original paper by Müller et al. (2006) for more details.
- Demonstrate your implementation using the same cloth from the previous task, showing that the cloth appears nearly inextensible when using constraints.

Modify your simulation to handle collisions of particles with moving obstacles. You may use discrete collision detection, i.e. you only need to check for collisions at the end of the time step. Also, you only need to test the particles of the mass-spring system; you are not required to handle the case where an edge or face of the cloth is intersecting the obstacle but all particles are outside.

- Your implementation should support collisions with spheres and infinite planes. Spheres may further have a time-varying transformation applied to them. Assume constant linear and angular velocities specified by the user.
- For collision response, include normal forces with user-specified
*ε*, frictional forces with user-specified*μ*, and position correction to move particles out of the obstacle. Note that the velocity response should depend not on the absolute velocity of the particle, but on the*relative*velocity between it and the obstacle at the point of contact! - Include the obstacles as well in the displayed scene. You may wish to draw the spheres slightly smaller (or equivalently, check collisions with a slightly larger shape) so that penetrating edges and faces are not too noticeable. For infinite planes, just draw a large finite square.
- Demonstrate your implementation on a scene with a ground plane and one or more spheres. At least one of the spheres should be moving, and the cloth should collide with all of them and with the ground.
**Optional task:**Right now, your cloth will happily pass through itself and get tangled, because we are not testing for self-collisions. Fully robust self-collision handling is very hard, but we can do an OK job just by handling inter-particle collisions: make sure the distance between all*non-adjacent*particles is at least Δ*x*, the rest length of the structural edges. This way a particle is unlikely to sneak through the gap between adjacent particles.- To speed up inter-particle collision detection, use a uniform grid
of size Δ
*x*(see lecture 20). Since we only care about particles at distance Δ*x*or less, you only need to check the 3×3×3 adjacent cells for each particle. - Treat the distance between nearby particles as a constraint, and apply a projection impulse to both their positions and velocities in the usual way.
- Set up a simulation where significant self-collisions occur, e.g. when an initially vertical sheet of cloth drops on the ground, and show results with and without self-collisions.

- To speed up inter-particle collision detection, use a uniform grid
of size Δ

**Extra optional task:**Put all three parts of the assignment together by draping a cloth on top of a keyframed character!- This task is optional for everyone, regardless of whether they are working individually or in pairs, and does not count as one of the three optional tasks that students working in pairs are required to do. It is worth up to 10% extra marks.
- You may need to add support for more collision shapes to represent the limbs of the character. Instead of testing with the exact limb geometry, use an easy-to-query approximation such as a box or a “capsule”.
- You’ll have to compute the instantaneous linear and angular velocity of the colliding limb based on the joint angles and their time derivatives.
- To keep things simple, the cloth can just be something like a shawl or a poncho (a square with a neck hole cut in the middle; here’s a famous example).

Submit your assignment on Moodle before midnight on the due date. Your submission should be a zip file that contains your entire source code for the assignment, not including any binary object files or executables. The zip file should also contain a PDF report that includes:

- one or more representative frames of each of the demonstration animations,
- discussion of any implementation choices or unusual features of your program,
- explanation of any required components you could not implement, and what problems you faced in doing them.

You should also record videos of your demonstration animations, as mentioned on Moodle. These are likely to be too big to upload to the Moodle assignment submission system, so please upload them somewhere else (like the institute’s Owncloud or Sharepoint, Google Drive, or even YouTube), make them world-readable, and include links to them in the PDF report.

Separately, each of you working in groups will *individually*
submit a short response in a separate form regarding how much you and
your groupmate(s) contributed to the work in this assignment.