26 if(!fileName)
return false;
28 fopen_s(&fp, fileName,
"rb");
49 for(
unsigned int f = 0; f <
meshList[i].totalFaces; f++)
54 if(!pMesh || !pFace)
continue;
64 n.
x = ((v1.
y * v2.
z) - (v1.
z * v2.
y));
65 n.
y = ((v1.
z * v2.
x) - (v1.
x * v2.
z));
66 n.
z = ((v1.
x * v2.
y) - (v1.
y * v2.
x));
68 float len = 1 / (float)sqrt((n.
x * n.
x + n.
y * n.
y + n.
z * n.
z));
69 n.
x *= len; n.
y *= len; n.
z *= len;
113 strcpy_s(pMesh->
name, name);
137 strcpy_s(pMat->
name, name);
212 char buff[100] = { 0 };
216 fread(buff, 1, 1, fp);
217 while(*(buff + index) != 0)
220 fread(buff + index, 1, 1, fp);
225 return strlen(buff) + 1;
245 unsigned char header[6];
248 pChunk->
bytesRead += fread(header, 1, 6, fp);
249 pChunk->
bytesRead += fread(&color, 1, 3, fp);
259 pChunk->
bytesRead += fread(header, 1, 6, fp);
260 pChunk->
bytesRead += fread(&color, 1, 3, fp);
279 unsigned char header[6];
282 pChunk->
bytesRead += fread(header, 1, 6, fp);
283 pChunk->
bytesRead += fread(&color, 1, 3, fp);
293 pChunk->
bytesRead += fread(header, 1, 6, fp);
294 pChunk->
bytesRead += fread(&color, 1, 3, fp);
313 unsigned char header[6];
316 pChunk->
bytesRead += fread(header, 1, 6, fp);
317 pChunk->
bytesRead += fread(&color, 1, 3, fp);
327 pChunk->
bytesRead += fread(header, 1, 6, fp);
328 pChunk->
bytesRead += fread(&color, 1, 3, fp);
346 unsigned short totalMatIndices = 0;
347 unsigned short *pMatIndices = NULL;
351 pChunk->
bytesRead += fread(&totalMatIndices, 1, 2, fp);
354 pMatIndices =
new unsigned short[totalMatIndices];
357 pChunk->
bytesRead += fread(pMatIndices, 1, totalMatIndices *
358 sizeof(
unsigned short), fp);
371 for(
int i = 0; i < totalMatIndices; i++)
378 unsigned int totalFaces = 0;
383 pChunk->
bytesRead += fread(&totalFaces, 1, 2, fp);
387 pChunk->
bytesRead += fread(pFaces, 1, totalFaces *
396 for(
unsigned int i = 0; i < totalFaces; i++)
420 unsigned int totalVertices = 0;
426 pChunk->
bytesRead += fread(&totalVertices, 1, 2, fp);
429 pVertices =
new stVertex[totalVertices];
430 pChunk->
bytesRead += fread(pVertices, 1, totalVertices *
451 unsigned int totalTexCoords = 0;
456 pChunk->
bytesRead += fread(&totalTexCoords, 1, 2, fp);
460 pChunk->
bytesRead += fread(pTexCoords, 1, totalTexCoords *