iphone - How do faces in .obj work? -
when parsing .obj-file, vertices , vertex-faces, easy pass vertices shader , use gldrawelements using vertex-faces.
when parsing .obj-file, vertices , texture-coordinates, type of face occur: texture-coordinate faces.
when displaying textures, apart loading images, binding them , passing texture coordinates parser, how use texture-coordinate faces? differ vertex-faces , suppose texture-coordinate faces have purpose when displaying textures?
regards niclas
not sure you're asking, if understand correctly, you're wondering how store data texture coordinates render textured 3d object. if so, store vertex-normal-texturecoordinate data in interleaved format, below:
vertexx vertexy vertexz normalx normaly normalz texturex texturey texturez
once have array of these, create pointers different parts of array , render below:
glenableclientstate(gl_vertex_array); glenableclientstate(gl_normal_array); glenableclientstate(gl_texture_coord_array); glvertexpointer(3, gl_float, sizeof(vertexarray[0])*9, &vertexarray[0]); glnormalpointer(3, gl_float, sizeof(vertexarray[0])*9, &vertexarray[3]); gltexcoordpointer(gl_float, sizeof(vertexarray[0])*9, &vertexarray[6]); gldrawelements(gl_triangles, indices.size(), gl_unsigned_short, &indices[0]);
at least how i'm doing it. there may better way, , if there is, i'd glad know.
Comments
Post a Comment