Sign in to follow this  
Followers 0
Anand Baumunk

Loading .obj problem

2 posts in this topic

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
0

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
0

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
0

Share this post


Link to post
Share on other sites

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  
Followers 0