Jump to content
  • Advertisement
Sign in to follow this  
jdavis

obj loader texture coord issue

This topic is 3214 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
Advertisement
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?

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.tu = texcoordList[textureIndexList[f]].x;
pVertex.tv = texcoordList[textureIndexList[f]].y;
}
else
{
pVertex.tu = 0.0f;
pVertex.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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!