Reading obj data from file
I read the nehe tutorial, and your data, and I definitively think you swapped X and Y axis.
Also, about the winding, just try to build your quad in reverse order, just to see what happens
// Your codeglVertex3f( vertices[j][facets[j][0]-1][0], vertices[j][facets[j][0]-1][1], vertices[j][facets[j][0]-1][2]);// fixed glVertex3f( vertices[j][facets[j][0]-1][0], vertices[j][facets[j][0]-1][2], vertices[j][facets[j][0]-1][1]);
Also, about the winding, just try to build your quad in reverse order, just to see what happens
Damnit it was an oversight on my part I was working late on this. Thanks so much for you help.
Screenshot
http://imageflock.com/img/1209045095.png
It also looks as if its been drawn inside out
Screenshot
http://imageflock.com/img/1209045095.png
It also looks as if its been drawn inside out
The little boxes are ok now
Comparing how vertices are placed in the first little cube (first object, vertices 1 to 8) and the first big sub box (third object, vertices 17 to 24), I see that
on the little box, vertices 1 to 4 are on the top, and vertices 17 to 20 are on the bottom.
So, try by cutting the four lines defining vertices 21 to 24 and paste before vertices 17 to 20 (in other word : swap the coordinates of vertices 17-20 and 21-24)
And so on for the other parts.
Hope this help
tip : I used paper and pen to draw the vertices and spot what could be wrong.
Comparing how vertices are placed in the first little cube (first object, vertices 1 to 8) and the first big sub box (third object, vertices 17 to 24), I see that
on the little box, vertices 1 to 4 are on the top, and vertices 17 to 20 are on the bottom.
So, try by cutting the four lines defining vertices 21 to 24 and paste before vertices 17 to 20 (in other word : swap the coordinates of vertices 17-20 and 21-24)
And so on for the other parts.
Hope this help
tip : I used paper and pen to draw the vertices and spot what could be wrong.
Thanks david, I fiddled with it abit I think I've got it sorted now.
http://imageflock.com/img/1209047793.png
Thanks again.
- Adam
http://imageflock.com/img/1209047793.png
Thanks again.
- Adam
Actually, everything is now in the right place which was the main problem there is still an issue with winding though, I noticed on this simple recentangle doesnt look as if theres a top,
backface culling is enabled too.
http://imageflock.com/img/1209052609.png
Depending on the angle you can see some faces just not others.
1
3.956007 0.462443 0.199838
3.956007 -1.537557 0.199838
-3.956007 -1.537556 0.199838
-3.956006 0.462444 0.199838
3.956009 0.462443 2.199838
3.956004 -1.537557 2.199838
-3.956008 -1.537556 2.199838
-3.956007 0.462443 2.199838
1 2 3 4
5 8 7 6
1 5 6 2
2 6 7 3
3 7 8 4
5 1 4 8
backface culling is enabled too.
http://imageflock.com/img/1209052609.png
Depending on the angle you can see some faces just not others.
1
3.956007 0.462443 0.199838
3.956007 -1.537557 0.199838
-3.956007 -1.537556 0.199838
-3.956006 0.462444 0.199838
3.956009 0.462443 2.199838
3.956004 -1.537557 2.199838
-3.956008 -1.537556 2.199838
-3.956007 0.462443 2.199838
1 2 3 4
5 8 7 6
1 5 6 2
2 6 7 3
3 7 8 4
5 1 4 8
glBegin(GL_QUADS);for(j=0; j<objects; j++){for (i=0;i<6;i++){glColor3f(1.0,0.0,0.0); glVertex3f(vertices[j][facets[j][0]-1][0],vertices[j][facets[j][0]-1][2],vertices[j][facets[j][0]-1][1]);glColor3f(1.0,2.0,0.0); glVertex3f(vertices[j][facets[j][1]-1][0],vertices[j][facets[j][1]-1][2],vertices[j][facets[j][1]-1][1]);glColor3f(1.0,2.2,3.0); glVertex3f(vertices[j][facets[j][2]-1][0],vertices[j][facets[j][2]-1][2],vertices[j][facets[j][2]-1][1]);glColor3f(1.0,0.0,4.0);glVertex3f(vertices[j][facets[j][3]-1][0],vertices[j][facets[j][3]-1][2],vertices[j][facets[j][3]-1][1]);}}
Another test with multiple objects looks as if I'm missing a top and side from each object
http://imageflock.com/img/1209059237.png
http://imageflock.com/img/1209059237.png
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement