Game Development Reference
In-Depth Information
//A float type vector
typedef struct stVECTORF{
float x,y, z;
}VECTORF;
//Used by the Cmorph class
typedef struct stMORPHITEM{
char name[30]; //Used to store a user friendly name for the target
VECTORF *pts; //Vertex locations
double level; //Stores current level of morph target
}MORPHITEM;
The level member stores the currently used level for the morph target.
This will be used when we look at blending the morph targets and
interpolating across keyframes.
To load a morph target we allocate memory for the vertex locations to
the 'pts' member of the 'MORPHITEM' structure. Then we read each
vertex in turn. Each vertex uses a short to store the vertex index, and a
float for the x , y and z values. If the chunk is of 'MORF' type, then we add
the base value of the vertex to the read value. Lightwave uses Motorola
or Network byte ordering and so we use the utility functions ReadShort
and ReadFloat to read the actual data. These functions, described in
Chapter 10, flip the byte ordering to Intel native.
BOOL CLW2Object::LoadVmap(FILE *fp, int length){
char type[4];
BOOL relative, ok = FALSE;
float x, y, z;
unsigned short dimension, vindex;
//Check Vmap type only SPOT and MORF supported
if (fread(type, 4, 1, fp) != 1) return FALSE;
if (strncmp(type, ”SPOT”, 4) == 0){
relative = FALSE;
ok = TRUE;
}
if (strncmp(type, ”MORF”, 4) == 0){
relative = TRUE;
ok = TRUE;
}
Search Nedrilad ::




Custom Search