Skip to main content
GameDev.net gamedev.net
🔒 Locked

obj loader texture coord issue

Started by jdavis Feb 22, 2010 at 1:14 AM 2 replies 1.3k views
Original Post
jdavis
jdavis
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
karwosts
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?
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
ankhd
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.


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;
}

jdavis
jdavis
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.