Implementation Details


As first with any program I had to sit down and think the design over. How did I want to implement certain things and what data structures did I want to use to implement these things. What I ultimately decided to do was to implement the hairs as individual cylinders that behave like strings.

Firstly I set up the data structures:

  typedef struct point_tag{
	float x, y, z;
  } Point;

  typedef struct joint_tag{
	float x, y;
	float vx, vy;
        Point points[ WIDTH_SEGMENTS ];
  } Joint;

  typedef struct strand_tag{
	float x, y, z;
	Joint joints[ LENGTH_SEGMENTS ];
  } Strand;

  typedef struct hair_tag{
	Strand strands[ NUM_HAIRS ];
  } Hair;
These data structures together would decribe a patch of hair. A patch of hair consists of strands of hair, which have N number of joints, and M number of points.

The joints describe each bending joint of the hair. Each joint will be described by a xy coordinate and a velocity. The number of points that each joint has will account for the smoothness of the hair. Since the hair is so small compared to the size of a pixel a number around 5 should give a round looking strand of hair.

When it comes time to animate the hair is when the joints are manipulated to create smoothly bending hairs. Each joint has a velocity. This velocity is adjusted to such things as wind and gravity, but most importantly it is adjusted in a way that make sures that it remains connected to the other joints. After the joints new velocity is found, we just run thought the joints and adjusted their position according to it's velocity. At this point we should do collision detection for things such as the floor or the head.

This project is concentrating on the modeling aspect of hair, therefore the program outputs Alias Wavefront model files. These files are converted to AutoCad DXF files and then imported into 3D Studio Max for rendering. After porting this to libsxAnim, this program can now output bitmaps.

During the course of this project a few things were added to give more realism to the hair's movement and look. One of these things was wind deflection. Realisticly wind will not hit all hairs evenly, usually the hairs in the center will get less wind. I modeled this by assuming that the close the hair got to the center of all the hairs, the less the wind affected it. This technique seemed to work well. Some other things that added more realism were things such as varying the starting position of each of the hairs joints. Also adding translucency to the hair proved to make the hair more realistic.

There are many other things that can be done to this project to achieve more realistic hair. Take a look at the Further Research Suggestions.


jhoward@wpi.edu 1998