Game Development Reference
In-Depth Information
if (!ok || !pts){
//Skip over chunk
fseek(fp, length - 4, SEEK_CUR);
return TRUE;
}
//OK to load
if (!ReadShort(fp, dimension)) return FALSE;
int index, bytesread = 6;
char name[128];
//Read name of morph target
ReadString(fp, name, index, 127);
bytesread += index;
MORPHITEM mi;
//Allocate memory for the vertex locations
mi.pts = new VECTOR[numpoints];
//If object doesn't have a morph controller then create one
if (!morph){
for (int i=0; i<numpoints; i++){
mi.pts[i].x = pts[i].x;
mi.pts[i].y = pts[i].y;
mi.pts[i].z = pts[i].z;
}
morph = new CMorph(mi);
}
//Read each vertex until the length of the chunk is reached
while(bytesread < length){
//Read vertex index
if (!ReadShort(fp, vindex)) return FALSE;
//Abort if vertex index is out of range
if (vindex < 0 || vindex >= numpoints) return FALSE;
//Read x,y, z values
if (!ReadFloat(fp, x)) return FALSE;
if (!ReadFloat(fp,y)) return FALSE;
if (!ReadFloat(fp, z)) return FALSE;
//Store value
Search Nedrilad ::




Custom Search