Game Development Reference
Figure 14.3 Charlie's head morph objects.
Alternatively, if you are loading a Lightwave 6 file that has embedded
Endomorphs then the loader will automatically create a morph controller
and assign each Endomorph as a new morph target.
Figure 14.3 shows the morph targets available in the head from the low
resolution mesh created in Chapter 5. Even with a very low resolution
mesh it is possible to convey some facial animation.
Extracting morph objects from a Lightwave 6 file
Lightwave stores morph targets as VMAP chunks within a LAYR chunk. If
the basic structure of a Lightwave file is unfamiliar, then now may be a
good time to review Chapter 10, which goes into Lightwave object files in
much greater depth. VMAP chunks are used to store many different types
of data that are attributable at the vertex level. Another VMAP chunk that
is very useful in real-time applications gives the UV data for a texture. To
accommodate using the same chunk for many different types of data, a
VMAP chunk has a header that gives the type of the file and the
dimension of the data applied to each vertex. If the VMAP chunk stores a
morph target then the type will be either 'SPOT' or 'MORF'. The VMAP
chunk has a dimension of 3; this means for each vertex there will be three
floating-point values representing the ( x , y , z ) location of the vertex as
used in the morph target. The vertex locations can be relative to the
original vertex location if the chunk is of type 'MORF' or world locations if
the chunk type is 'SPOT'. Since any morph target chunk is guaranteed to
follow the base point list, we already know how many vertices an object
has and the sample code stores this information in a member variable
called 'numpoints'. The sample code makes use of a very simple structure
called a 'MORPHITEM', which in turn uses a 'VECTORF' structure.