Game Development Reference
In-Depth Information
}
if (line.Find("MESH_NORMALS")!=-1){
if (!ReadNormals(file, obj)) goto meshabort;
continue;
}
}
if (tvert) delete [] tvert;
return TRUE;
meshabort:
if (tvert) delete [] tvert;
return FALSE;
}
The vertex list contains MESH_NUMVERTEX lines each describing a
single vertex. The value read from MESH_NUMVERTEX is stored in the
variable obj
numponts. Before reading each line the entire vertex array
is set to zero values using a simple memset call. Then the function uses a
'for' loop to iterate through all the points in the object storing the values
read from the file. To orientate the values read from the ASE file to the
coordinate space used by Toon3D, the y and z values are flipped and the
z value inverted.
BOOL C3DSAscii::ReadVertexList(CStdioFile &file, CToon3DObject
*obj)
{
CString line,tmp;
int start,end;
TOKEN tokens[5];
start = file.GetPosition();
end = GetSectionEnd(file);
memset(obj->pts,0,sizeof(POINT3D)*obj->numpoints);
for (int i=0; i<obj->numpoints; i++){
if (!FindToken(file,line,"MESH_VERTEX ",-1,end)) return
FALSE;
if (ParseTokens(line,tokens,5)<5) return FALSE;
//Swap z and y and flip the z
obj->pts[i].x = atof(tokens[2].name);
obj->pts[i].y = atof(tokens[4].name);
obj->pts[i].z =-atof(tokens[3].name);
}
return TRUE;
}
Search Nedrilad ::




Custom Search