Game Development Reference
In-Depth Information
BOOL C3DSAscii::AssignSurfaces(CToon3DObject *obj, int index)
{
if (materials[index].numsubmtls){
obj->srfs = new SURFACE[materials[index].numsubmtls];
if (!obj->srfs) return FALSE;
obj->numsurfaces = materials[index].numsubmtls;
memcpy(obj->srfs, materials[index].submat,
sizeof(SURFACE)*obj->numsurfaces);
for (int i=0; i<materials[index].numsubmtls; i++){
//Copy any textures that we need
if (materials[index].submat[i].tex){
obj->srfs[i].tex = new TEXTURE;
memcpy(obj->srfs[i].tex,
materials[index].submat[i].tex,
sizeof(TEXTURE));
}
}
for (i=0; i<obj->numpolygons; i++){
if (obj->plys[i].srf>obj->numsurfaces) return FALSE;
}
}else{
obj->srfs = new SURFACE;
if (!obj->srfs) return FALSE;
if (materials[index].mat.tex){
obj->srfs->tex = new TEXTURE;
memcpy(obj->srfs->tex,
materials[index].mat.tex, sizeof(TEXTURE));
}
obj->numsurfaces =1;
memcpy(obj->srfs, &materials[index].mat, sizeof(SURFACE));
for (int i=0; i<obj->numpolygons; i++){
obj->plys[i].srf=0;
}
}
return TRUE;
}
The default scale, position and orientation for the object is read from the
NODE_TM section by the function ReadNodeTM. The function is quite
straightforward except that the axes used in 3DS are different from those
used by Toon3D. To get the orientation back, the z and y components are
Search Nedrilad ::




Custom Search