0

I'm working with Opengl ES 2 on iphone and right now I am trying to get my textures working on my objects. I'm using .obj files and all the data in them are correct. I have written a parser myself to retrieve all data, I convert it to static arrays in C. I discard the material properties for now, only getting the image path from the .mtl files manually.

I have an object with 336 triangles, making this non-trivial to observe, with appertaining vertices, vertex faces and texture coordinates (u,v).

Passing all data into the shaders, the resulting image is this:

http://img530.imageshack.us/img530/9637/pic1io.png

http://img404.imageshack.us/img404/7358/pic2pg.png

But it should look like this (Displaying it in an object viewer). Please ignore the material properties.

http://img16.imageshack.us/img16/1401/pic3cq.png

Using this image as a texture:

http://img217.imageshack.us/img217/1300/shirtdiffuse.png

I'm thinking it might have to do with texture coordinate faces ? It is defined in my .obj file, and I'm not using them at all. In books and tutorials I have not found anything concerning this.

Regards Niclas

skaffman
  • 398,947
  • 96
  • 818
  • 769
tyuip
  • 157
  • 2
  • 10

1 Answers1

0

Have you tried to flip the texture vertically? Some times when a texture has been loaded it is layed out in memory so the vertical lines come in the opposit direction as intended in the texcoords.

epatel
  • 45,805
  • 17
  • 110
  • 144
  • Yes I have :) The images you are looking at are actually vertically flipped. Do you know of what use the texture coordinate faces are? – tyuip Dec 01 '10 at 13:14
  • @Adl does the texture "move" when you rotate the model? I'm no shader expert but if that occur I'd imagine there's a bug in your texcoord shader. – epatel Dec 02 '10 at 00:06
  • The problem is that I have different indices, depending on which attributes I use. Vertices, Normals and TextureCoordinates all have different indices. I dont know how to draw Vertices with their corresponding indices when I'm also is supposed to draw TextureCoords with their indices. – tyuip Dec 02 '10 at 12:29