Hiall,
I have an obj. file for a simple cube exported from Blender,
where is the vertex data and faces data in which order vertexes are in a single face:
v 3.935551 -1.000000 -1.000000
v 3.932597 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 3.709118 -0.797889 -0.851264
v 3.728637 -0.725917 0.637501
v -0.749396 -0.730253 0.654301
v -0.776180 -0.718190 -0.887628
usemtl Material
s off
f 1 2 3 4
f 5 8 7 6
f 1 5 6 2
f 2 6 7 3
f 3 7 8 4
f 5 1 4 8
After parsing these values to an array or vertexes, how to draw it with OpenGL ES correctly using:
Does the vertex array writing data order matter?
How do i get the correct triangles, (not hardcoding them)? Do i need to calculate the triangles using face data or something?
Do some 3d file formats have triangle data ready if exported?
You could draw wireframe and/or at least a different color for each triangles ? It would be easier to visually debug.
Within Blender, be sure your cube is still correct even when disabling the double sided mode.
EDIT: try different ordering, I could not find a definite response about the order of vertices within a .obj face.
Found the problem(Took a while…).Looks like in face data exported by Blender does not include index “0” at all. (As can be seen from the .obj file i included.)
Other examples like SimpleCube had this “0”, so i just:
(TInt is Symbian type for int)
TInt i=0;
for(TInt k=0;k<36;){
iTriangles[k] = iFaces[i] - 1 ;
iTriangles[k+1] = iFaces[i+1] -1 ;
iTriangles[k+2] = iFaces[i+2] -1;
iTriangles[k+3] = iFaces[i] -1;
iTriangles[k+4] = iFaces[i+2] -1;
iTriangles[k+5] = iFaces[i+3] -1;
i=i+4;
k=k+6;