Hair demo

Description

This project attempts to simulate the behavior of hair using a spring system.

The method used here is based on the spring-mass system in the flag demo. Each strand of hair is represented by a number of spring attached in serial. The elasticity of these springs is determined by their length and the angle at the joint between each pair. When a spring is streched beyond its rest length it will tend to pull back. Also when two adjoint spring are bent they tend to straighten themselves out (assuming that the rest angle between them is 180 degrees).

Each hair originates on the surface of a sphere, and the program allows the user to randomly select an area on which hair is to be grown. Ten joints connect the individual springs composing the hair.

The hair is rendered in either wireframe or textured mode. In the case of the latter, a texture file (tex.bmp) that contains three different colors of hair is loaded and used. Then a series of rectangles outlining each hair and facing the camera are rendered.

To actually view the motion of hair a force resembling wind is used. The user has the option of turning it on or off. Additionaly, a combing effect is implemented which "brushes" the hair upwards.

User's guide

On the screen there will appear the sphere onto which the hair will be grown as well as a purple spot which directly points to the location where hair will be generated. Controlling the rotation of the camera, the spot and the lights is done by first selecting the mode with either the '1', '2', or '3' key, and then moving the mouse while holding the left button pushed. To add hair push the right mouse button.

Keys:
'1' - camera rotation mode
'2' - spot rotation mode
'3' - light rotation mode
'q' - exit
'a' - zoom in
'z' - zoom out
'-' - decrease the size of the growth spot
'+' - increase the size of the growth spot
'v' - switch between wireframe and textured rendering modes
'w' - enable/disable wind
'N'/'n' - increase/decrease the X component of the wind
'M'/m' - increase/decrease the Y component of the wind
'H'/'h' - increase/decrease the Z component of the wind
'4' - select light hair type
'5' - select dark hair type
'6' - select red hair type
'd' - delete all hair
'c' - comb hair

Screenshots


The startup screen


Some hair added


Hair after wind forces have been applied


Hair using a dark texture