Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Loading .obj problem

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 gnomgrol   Members   

699
Like
0Likes
Like

Posted 04 July 2012 - 05:34 AM

Hey guys,
My time is short, so Ill have to keep this short also:
I load position, normals, texturecoords and faces from .obj data. Works fine.
Now I need the indices, but i cant manage to calculate them proberly from the faces.
When I load a cude, the front and left side are not there.

Code looks like this:
(Code-Tags still not working thought)


int indexI; indexI = 0;

for(int i=0;i<faceCount;i++){
indices[indexI] = faceData[(i*4)]-1; //-1 cause faces start with 1
indices[indexI+1] = faceData[(i*4)+1]-1; //*4 cause every face has 4 vertices
indices[indexI+2] = faceData[(i*4)+2]-1; // faceData is just a list of all faces,
// eg: 1 2 3 4 5 8 7 6...

indices[indexI+3] = faceData[(i*4)]-1;
indices[indexI+4] = faceData[(i*4)+2]-1;
indices[indexI+5] = faceData[(i*4)+3]-1;
indexI += 6;
}

Can someone provide usefull information on this? Thanks

Edited by gnomgrol, 04 July 2012 - 05:35 AM.


#2 Inukai   Members   

1331
Like
0Likes
Like

Posted 04 July 2012 - 07:26 AM

Try to disable culling.
It looks like indexl+3 and +4 are in the wrong order.

Edited by Inukai, 04 July 2012 - 07:28 AM.


#3 gnomgrol   Members   

699
Like
0Likes
Like

Posted 04 July 2012 - 08:07 AM

switching +3 and +4 makes the cube even more messed up. Disableing culling only shows more clearly that the two sides are missing.


I fixed it. This code was correct, but the bytewidth of the indexbuffer was to small *facepalm*
Well, thanks anyway. Can someone tell me why this causes that kind of trouble?

Edited by gnomgrol, 04 July 2012 - 08:17 AM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.