Game Development Reference
In-Depth Information
sizeof(SURFACE) * materials[matnum].numsubmtls);
for(int i=0; i<materials[matnum].numsubmtls; i++){
if (!ReadSubMaterial(file, matnum, i)) return FALSE;
}
continue;
}
}
return TRUE;
}
Reading a sub-material is just the same as reading a material, except we
search for the tags SUBMATERIAL n , where n is the number of the current
sub-material. The MATERIAL structure contains the member submat that
is allocated memory for NUMSUBMTLS SURFACE structures. Sub-
materials nested into sub-materials are not allowed with this parser and will
force a message box to be displayed.
BOOL C3DSAscii::ReadSubMaterial(CStdioFile &file, int matnum, int
submatnum)
{
CString line,tmp;
int start,end;
TOKEN tokens[5];
SURFACE *srf = &materials[matnum].submat[submatnum];
tmp.Format("SUBMATERIAL %i", submatnum);
if (!FindToken(file, line, (LPCTSTR)tmp)) return FALSE;
start = file.GetPosition();
end = GetSectionEnd(file);
while(file.GetPosition()<(UINT)end){
file.ReadString(line);
if (line.Find("MATERIAL_NAME")!=-1){
if (ParseTokens(line, tokens, 5)<2) return FALSE;
strcpy(srf->name, tokens[1].name);
continue;
}
if (line.Find("MATERIAL_DIFFUSE")!=-1){
if (ParseTokens(line, tokens, 5)<4) return FALSE;
strcpy(materials[matnum].mat.name,tokens[1].name);
srf->diffuse=1.0;[1].name)*255.0);
srf->g = (BYTE)(atof(tokens[2].name)*255.0);
Search Nedrilad ::




Custom Search