Jump to content
  • Advertisement
Sign in to follow this  
Anand Baumunk

Loading .obj problem

This topic is 2302 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,
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

Share this post

Link to post
Share on other sites
Try to disable culling.
It looks like indexl+3 and +4 are in the wrong order. Edited by Inukai

Share this post

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

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!