Yarn Animation
Winter 2011 CMPS 161 Final Project
by April Grow and Julie Rej
(agrow & jrej)
Downloadables
Description

Our project animates yarn using a mix of procedural animation and physics animation. We were unable to meet our goals of collision detection and yarn-yarn or yarn-hook interaction. However, in lieu of those goals, we created other yarn-based animations using customizeable sine-wave based functions on a curve that can be drawn using bezier, bspline, or catmull-rom curve blending. We focused our efforts on the animation portion of the assignment and are pleased with the progress we were able to accomplish, even if it was not directly the same as our initial proposal.

Controls

There are a lot of them

// Activating Xbox Controller
m - Toggles whether the Xbox or Keyboard is used to move the control points
*****For debugging purposes with the Xbox controller

// Curve Selection:
1 - Use B-Spline to create curvepoints
2 - Use Nth degree Bezier curve to create curvepoints
3 - Use Catmull-Rom to create curvepoints

// Control Points
+/= - Increments forward along the yarn's control points.
***** If physics is on, it changes the pivot point.
***** If physics is off, it changes the control point the user can move.
***** XNA recognizes each of these keys as a single press. Shift doesn't matter.
-/_ - Decrements backward along the yarn's control points.
***** If physics is on, it changes the pivot point.
***** If physics is off, it changes the control point the user can move.
***** XNA recognizes each of these keys as a single press. Shift does not matter.
w - Move the selected control point up (Positive Y)
a - Move the selected control point left (Negative X or Z depending on the camera view)
s - Move the selected control point down (Negative Y)
d - Move the selected control point right (Positive X or Z depending on the camera view)
Space - Adds a new control point to the list
Backspace - Deletes a control point from the end of the list (if possible)

// Physics
q - Toggles influence of physics forces on/off

// Yarn Animation
f - Turns off all sine wave influence on the curve. Freezes the yarn in position if it is moving.
v - Turns on sine wave influence in the X and Y only (2D)
c - Turns on sine wave influence in the X, Y, and Z (3D)
y/t - Increases/decreases the Amplitude of the sine wave
h/g - Increases/decreases the wavelength of the sine wave. Will eventually cycle back around on itself.
n/b - Increases/decreases the rate/speed at which the sine wave goes up and down.

// Orientation
r Resets the curve points to a roughly equally spaced zig-zag pattern.
***** Useful if physics or user movement of the control points makes them unwieldly.

// Camera
Up arrow - Pans camera up
Down arrow - Pans camera down
Right arrow - Pans camera right
Left arrow - Pans camera left
Right shift - Zooms camera in
Left shift - Zooms camera out
Enter - Toggles between front and side view

The Curve

The yarn is modeled using three different curves as part of our experiment to find the best curve for use in demonstrating yarn. We use a bspline curve, an nth-order bezier curve, and a Catmull-Rom curve to show the differences between interpolating and approximating control points and the effect control points have on continuity of the curve.
Here are screenshots of the three curves, in the above order, using the same control points:







More images can be found here.

The Physics

The user can manipulate the yarn using the WASD keys when the physics are active. Much of the yarn's movement and positioning will be determined by the tension which may be expressed as,

F_Tension = F_Constant + F_Joystick

The constant will come from a source point called a pivot point. A pivot point is a special control point on the curve at which the yarn is grounded at. Everything before that point will remain stationary and everything after will move based on user input. The force of the joystick will be proportional to how much the end point is moved away from the origin.
When in equilibrium (|F_Constant| = |F_Joystick|) the yarn will straighten out, and the control points will form a linear line. If the constant is greater then the joystick force (|F_Constant| >|F_Joystick|) then the control points will sag to form a curve.

The position of the yarn end will depend on the radial position of the joystick. The pivot point would be the center of the radius.

Here the constant is greater than the joystick force:


Here the constant equals the joystick force:


Please note that we use the term "joystick" here because we initially worked off of the Xbox controller. However, the same physics and terms apply to the movement guided by the keyboard keys (IE: The radial direction and use of force).

You can see the physics in action in this video (Note: The lag in JING is horrid):


Download Full Size

The Procedural Animation

In lieu of collision and animation of the yarn against itself and/or a hook, we decided to model free-form yarn movement instead. Given the yarn is a curve, we use the sine wave function to animate the yarn in various ways using different variables for amplitude, wavelength, and rate. In this way, we can further illustrate the pros and cons of the differences in curves in different situations.
You can see a culmination of this animation in this video (Note: The lag in JING is horrid):


Download Full Size

And here are some other pictures using various curves and settings of the wave function:














Related Works

Visit our CMPS 170 Sequence game website, Pattern, here! It inspired our work with curves and yarn!

Acknowledgements

We would like to acknowledge William Tuttle for his help with the nth degree Bezier design and primitive drawing in XNA 3.1, as well as Katarina Yang and her work in creating the yarn texture and background for the project.

References

http://en.wikipedia.org/wiki/Tension_%28physics%29 Tension wikipedia article showing fundamental physics ideas applied in our project.
http://en.wikipedia.org/wiki/B%C3%A9zier_curve Bezier curve description and details.
http://en.wikipedia.org/wiki/Cubic_Hermite_spline Catmull-Rom curve information.
http://en.wikipedia.org/wiki/B-spline Bspline curve information.
Computer Animation: Algorithms and Techniques by Rick Parent. 2nd Edition. Published by Morgan Kaufmann Publishers in Burlington, MA, in 2008. Very useful curve matrix information.

Our Technical paper has additional sources related directly to the content therein.