Note that there are some explanatory texts on larger screens.

plurals
  1. POTroubles parsing Wavefront .obj texture coordinates
    primarykey
    data
    text
    <p>I'm coding my own .obj parser in objc for OpenGL ES 2.0 to get a better understanding on how this OpenGLES thing works. Loading the vertices and showing a model with vertex colors on it works like a charm. Just a small note: I'm using an index buffer.</p> <p>The real problem is the mapping of the textures atm. As you'll see a little bit more down below, my texture isn't mapped the way it should be. </p> <p>Here's how I think the .obj format works, please correct me if I'm wrong: the "f"-lines describe a face where the number before a slash defines the index of the vertex and the number after the slash defines a texture coordinate.</p> <p>Consider the following .obj file (exported by Cinema 4D):</p> <pre><code>v -75 75 -50 v 75 75 -50 v -75 -75 -50 v 75 -75 -50 vt 0 0 vt 0 1 vt 1 1 vt 1 0 f 4/3 3/2 1/1 f 2/4 4/3 1/1 </code></pre> <p>And the following texture:</p> <p><img src="https://i.stack.imgur.com/lyOgh.png" alt="512x512 Texture"></p> <p>Now, when I position the vertices in OpenGL ES 3D space and try to map the texture coordinates to each individual vertex, the mapping goes wrong. I could fix this by moving around some of the texture coordinate values but I realise this isn't the way to do it. I also tried to edit some of my .obj exporter settings to flip axises and/or uv mapping around but non of them result in a correct mapping. Is there something I'm missing in my theory concerning the .obj file format? One thing I might say already: I read yesterday that the coordinate system of the .obj format defines topleft as the anchor point of a texture. So I fixed that already in my parsing.</p> <p>Here's a small summary with the current situation: Update: the coordinate system of the texture is the actual .obj texture coordinate system and NOT OpenGL's coordinate system. I translate the coordinates in my parsing algorithm to counter this.</p> <p><img src="https://i.stack.imgur.com/FW4e1.png" alt="Summary"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload