Game Development Reference
In-Depth Information
}
if (line.Find("TM_ANIMATION")!=-1){
if (!ReadAnimation(file,obj)) return FALSE;
continue;
}
if (line.Find("MATERIAL_REF")!=-1){
if (ParseTokens(line,tokens,5)<2) return FALSE;
index = atoi(tokens[1].name);
if (!AssignSurfaces(obj, index)) return FALSE;
}
if (line.Find("WIREFRAME_COLOR")!=-1){
if (ParseTokens(line,tokens,5)<4) return FALSE;
//Create a single coloured surface
if (obj->srfs) delete [] obj->srfs;
obj->srfs=new SURFACE;
obj->numsurfaces=1;
obj->srfs->diffuse=1.0;
obj->srfs->tex=NULL;
obj->srfs->transparency=0.0;
obj->srfs->flag=0;
strcpy(obj->srfs->name,"Colour");
obj->srfs->specular=0.0;
obj->srfs->r=(BYTE)atoi(tokens[1].name);
obj->srfs->g=(BYTE)atoi(tokens[2].name);
obj->srfs->b=(BYTE)atoi(tokens[3].name);
for (int i=0;i<obj->numpolygons;i++){
obj->plys[i].srf=0;
}
}
}
obj->hide = FALSE;
return TRUE;
}
The token MATERIAL_REF returns a single integer and when reading a
polygon we get a single integer that defines the surface. If an object
contains multiple surfaces then these will be represented by the sub-
materials of that object; if the material is a basic material then the material
can be set directly. The application Toon3D uses an object level surface list
rather than global level, so after reading the MATERIAL_REF the
appropriate surfaces are duplicated in a format expected by Toon3D.
Search Nedrilad ::




Custom Search