No that is not the case at all (well i guess if the following holds:)
this is a piece of my code:
Code: Select all
if ((fp = fopen(filename, "rb")) == NULL) { iNumberOfGroups = -1; return; }
		while(!feof(fp))
		{
			fgets(ReadBuffer, 256, fp);
			if (strncmp("EndGroup", ReadBuffer, 8) == 0 )
			{
			
				tmpObj->ObjMeshParts[iNumberOfGroups].Vertices = (ObjVertexB*)malloc((fc-Correction) * 3 * sizeof(ObjVertexB));
				//tmpObj->ObjMeshPart[iNumberOfGroups].iNumberOfFaces = fc - Correction;
				tmpObj->ObjMeshParts[iNumberOfGroups].iFaces = (fc-Correction);
				l = 0;
				for (j=Correction;j<fc;j++)
				{
					for (k=0; k<3; k++)
					{
						tmpObj->ObjMeshParts[iNumberOfGroups].Vertices[l].u = TexCoords[Faces[j].textc[k]].u;
						tmpObj->ObjMeshParts[iNumberOfGroups].Vertices[l].v = -(TexCoords[Faces[j].textc[k]].v);
						tmpObj->ObjMeshParts[iNumberOfGroups].Vertices[l].color = 0xffffff00;
						tmpObj->ObjMeshParts[iNumberOfGroups].Vertices[l].x = Vertices[Faces[j].vertices[k]].x;
						tmpObj->ObjMeshParts[iNumberOfGroups].Vertices[l].y = Vertices[Faces[j].vertices[k]].y;
						tmpObj->ObjMeshParts[iNumberOfGroups].Vertices[l].z = Vertices[Faces[j].vertices[k]].z;
						l++;
					}
				}
				
				// the texture for this part.
				//sprintf(sBuffer, "Textures/UVtexturesHousePlatDak1024type3.png");
				tmpObj->ObjMeshParts[iNumberOfGroups].texture = loadImage(Textures[iNumberOfGroups]);
				// increment the group number.
				Correction = fc;
				iNumberOfGroups++;
			}
			else if (strncmp("v ", ReadBuffer, 2) == 0 )
			{
				sscanf((ReadBuffer+2), "%f%f%f",&Vertices[ vc ].x, &Vertices[ vc ].y, &Vertices[ vc ].z); 
				vc++;
			}
			else if (strncmp("vt ", ReadBuffer, 3) == 0 )
			{
				sscanf((ReadBuffer+3), "%f%f",&TexCoords[ tc ].u, &TexCoords[ tc ].v); 
				tc++;
			}
			else if (strncmp("f ", ReadBuffer, 2) == 0 )
			{
				
				char *pSplitString = NULL;
				int Waste;
				i=0;
				pSplitString = strtok((ReadBuffer+2)," \t\n");
				do {
					sscanf((pSplitString), "%d/%d/%d",&Faces[ fc ].vertices[ i ], &Faces[ fc ].textc[ i ],&Waste); 
					Faces[ fc ].textc[ i ] -= 1;		// 1 down because the obj file objects start at 1 and arrays start at 0
					Faces[ fc ].vertices[ i ] -= 1;
					pSplitString = strtok(NULL," \t\n");
					i += 1;
				}
				while( pSplitString );
				
				
				
				
				fc++;
			}
		}
		fclose(fp);
the only part that crashes is the part i mentioned. All the other part where i use the number of group do not crash. as you can see i reuse that variable (i know it is not good code, but i clean up afterwards, thats my way of coding) so it looks like that for some reason the problem lies in the part after the "="
i hope you can lead more out of my code now
greets ghoti