Question

I'm trying to make a 3D scene with OpenGL ES 2, I'm new into xCode and Objective-C. I follow this tutorial to transform blender *.obj generated file to *.h and *.c files But, the script want obj like this:

v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vt 0.375624 0.500625
vt 0.624375 0.500624
vt 0.375625 0.749375
vt 0.375625 0.251875
vt 0.375624 0.003126
vt 0.624374 0.251874
vt 0.873126 0.749375
vt 0.873126 0.998126
vt 0.624375 0.749375
vt 0.624375 0.998126
vt 0.126874 0.998126
vt 0.126874 0.749375
vt 0.375625 0.998126
vt 0.624373 0.003126
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 1.000000 -0.000000 0.000000
vn 0.000000 -0.000000 1.000000
vn -1.000000 -0.000000 -0.000000
vn 0.000000 0.000000 -1.000000
vn 1.000000 0.000000 0.000001
s off
f 1/1/1 2/2/1 4/3/1
f 5/4/2 8/5/2 6/6/2
f 1/1/3 5/4/3 2/2/3
f 2/7/4 6/8/4 3/9/4
f 3/9/5 7/10/5 4/3/5
f 5/11/6 1/12/6 8/13/6
f 2/2/1 3/9/1 4/3/1
f 8/5/2 7/14/2 6/6/2
f 5/4/7 6/6/7 2/2/7
f 6/8/4 7/10/4 3/9/4
f 7/10/5 8/13/5 4/3/5
f 1/12/6 4/3/6 8/13/6

And when I create a new cube (or anything else) I obtain an obj like this:

v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 1.000000 -0.000000 0.000000
vn 0.000000 -0.000000 1.000000
vn -1.000000 -0.000000 -0.000000
vn 0.000000 0.000000 -1.000000
vn 1.000000 0.000000 0.000001
s off
f 1//1 2//1 4//1
f 5//2 8//2 6//2
f 1//3 5//3 2//3
f 2//4 6//4 3//4
f 3//5 7//5 4//5
f 5//6 1//6 8//6
f 2//1 3//1 4//1
f 8//2 7//2 6//2
f 5//7 6//7 2//7
f 6//4 7//4 3//4
f 7//5 8//5 4//5
f 1//6 4//6 8//6

Faces are separated by two slashes where I expected only one. There is any simpliest way to generate .h and .c files for xCode, every script (for Blender) I try failed. Or anyone can tell me how to get a clean obj file.

Thanks a lot

Was it helpful?

Solution

Your resulting file is correct obj. However, what you want it to be - is incorrect obj.

Format for f command is f position_id/texture_coordinates_id/normal_id. You don't have texture coordinates, so this field is empty.

Options are

  1. fix parser so it could load obj without texture coordinates, or

  2. just add UV map to your object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top