here is the problem: I have this struct:
Code: Select all
typedef struct { float u, v;
int color;
float x, y, z; } ObjVertexB;
typedef struct { float u, v; } ObjTexCoord; // texture coordinates
Code: Select all
ObjTexCoord TexCoords[ iNumberOfTexCoords ];
....some code
for (j=0;j<iNumberOfFaces-1; j++){
if (FacesDone[j] == TRUE) {}
else {
if (CompareFaces(&ComparedFace, &Faces[ j ]) == 2) {
FacesDone[j] = TRUE;
ComparedFace = Faces[ j ];
tmpObj->Strips[iStripNr].Vertices[j].u = TexCoords[0].u;
tmpObj->Strips[iStripNr].Vertices[j].v = TexCoords[0].v;
tmpObj->Strips[iStripNr].Vertices[j].color = 0xffff0000;
tmpObj->Strips[iStripNr].Vertices[j].x = Vertices[iNewCoord].x;
tmpObj->Strips[iStripNr].Vertices[j].y = Vertices[iNewCoord].y;
tmpObj->Strips[iStripNr].Vertices[j].z = Vertices[iNewCoord].z;
VerticesCount++;
j = 0;
}
}
}
now the TexCoords is filled with this code:
Code: Select all
if ((fp = fopen(filename, "rb")) == NULL) { iNumberOfGroups = -1; return; }
while(!feof(fp))
{
fgets(ReadBuffer, 256, fp);
if (strncmp("g default", ReadBuffer, 9) == 0 )
{
if (iNumberOfGroups == 0) {
}
else {
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);
i hope i gave enough info otherwise please ask so i can provide
thanks in advance