01 MV_MODEL *mv_ParseMeshData(FILE *file_ptr, tLONG mesh_size, MV_OBJECT *pObj) 02 { 03 tWORD id; 04 tLONG size; 05 tLONG end_of_block; 06 MV_MODEL *pMesh; 07 08 end_of_block = ftell(file_ptr) + mesh_size; /* where the block should end... */ 09 end_of_block -= sizeof(tWORD)+sizeof(tLONG); /*...ignoring the header */ 10 11 pMesh = (MV_MODEL *)malloc(sizeof(MV_MODEL)); 12 if (!pMesh) 13 return (MV_MODEL *)0; 14 15 pMesh->iNumFaces = 0; 16 pMesh->iNumVertices = 0; 17 18 do 19 { 20 mv_ReadChunk(file_ptr, &id, &size); 21 22 switch(id) 23 { 24 case SMV_OBJECTDESCRIPTION: 25 mv_ParseObjectBlock(file_ptr, size, pObj, pMesh); 26 break; 27 default: 28 mv_SkipChunk(file_ptr, size); 29 } 30 } 31 while(ftell(file_ptr) < end_of_block); 32 33 return pMesh; 34 }