Game Development Reference
In-Depth Information
file.ReadString(line);
if (line.Find("MATERIAL_NAME")!=-1){
if (ParseTokens(line, tokens, 5)<2) return FALSE;
strcpy(materials[matnum].mat.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);
materials[matnum].mat.diffuse=1.0;
materials[matnum].mat.r=(BYTE)(atof(tokens[1].name)*255.0);
materials[matnum].mat.g=(BYTE)(atof(tokens[2].name)*255.0);
materials[matnum].mat.b=(BYTE)(atof(tokens[3].name)*255.0);
continue;
}
if (line.Find("MATERIAL_SPECULAR")!=-1){
if (ParseTokens(line, tokens, 5)<4) return FALSE;
materials[matnum].mat.specular=(float)atof(tokens[1].name);
continue;
}
if (line.Find("MATERIAL_TRANSPARENCY")!=-1){
if (ParseTokens(line, tokens, 5)<2) return FALSE;
materials[matnum].mat.transparency=(float)atof(tokens[1].
name);
continue;
}
if (line.Find("MAP_DIFFUSE")!=-1){
materials[matnum].mat.tex = new TEXTURE;
if (!materials[matnum].mat.tex) return FALSE;
memset(materials[matnum].mat.tex, 0, sizeof(TEXTURE));
if (!FindToken(file, line, "BITMAP")) return FALSE;
if (ParseTokens(line, tokens, 5)<2) return FALSE;
strcpy(materials[matnum].mat.tex->name,tokens[1].name);
continue;
}
if (line.Find("NUMSUBMTLS")!=-1){
if (ParseTokens(line, tokens, 5)<2) return FALSE;
materials[matnum].numsubmtls = atoi(tokens[1].name);
materials[matnum].submat =
new SURFACE[materials[matnum].numsubmtls];
//Initialise the data
memset(materials[matnum].submat, 0,
Search Nedrilad ::




Custom Search