obj loader texture coord issue
Hey guys, I started writing an obj loader for Direct3D tonight and am running into a texture coord issue.. I just wanted to post to see if anyone could spot something. I know it's nothing to do with parsing the data from the file or the mesh itself. It's definitely when I'm setting up the uv coords. Here is a screenshot of what I'm getting..
Here is a link to the code
http://codepad.org/im48teST
Any help would be appreciated!
Cheers,
Jon
Might be a long shot, but are you making sure to take account of the fact that obj indexes vertices and texcoords starting from 1 instead of 0?
Hey there.
some time there no texture coord uv's, for each vertex, the sdk plane is a good one for here.
so set the ones that dont have uv pairs set them to 0.
for (int f = 0; f < g_numFaces * 3; f++)
{
if (i == vertexIndexList[f])
{
pVertex.tu = texcoordList[textureIndexList[f]].x;
pVertex.tv = texcoordList[textureIndexList[f]].y;
}
else
{
pVertex.tu = 0.0f;
pVertex.tv = 0.0f;
}
some time there no texture coord uv's, for each vertex, the sdk plane is a good one for here.
so set the ones that dont have uv pairs set them to 0.
for (int f = 0; f < g_numFaces * 3; f++)
{
if (i == vertexIndexList[f])
{
pVertex.tu = texcoordList[textureIndexList[f]].x;
pVertex.tv = texcoordList[textureIndexList[f]].y;
}
else
{
pVertex.tu = 0.0f;
pVertex.tv = 0.0f;
}
Quote:Original post by karwosts
Might be a long shot, but are you making sure to take account of the fact that obj indexes vertices and texcoords starting from 1 instead of 0?
Yeah, I'm doing that when I parse the file. If I wasn't, the mesh wouldn't display right but good observation!
vertexIndexList.push_back( index - 1 );
Quote:Original post by ankhd
Hey there.
some time there no texture coord uv's, for each vertex, the sdk plane is a good one for here.
so set the ones that dont have uv pairs set them to 0.
In this case, all vertices have texture coords. I observed the face data information from the obj file itself and both my vertexIndexList and textureIndexList are equal size.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement