Sign in to follow this  

obj loader texture coord issue

This topic is 2851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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[i].tu = texcoordList[textureIndexList[f]].x;
pVertex[i].tv = texcoordList[textureIndexList[f]].y;
}
else
{
pVertex[i].tu = 0.0f;
pVertex[i].tv = 0.0f;
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 2851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this