5

An artist gave me all 3D models for me exporting to .obj and .mtl in order that I can render it using OpenGL.

But I can't figure out why the texture vertex are greater than 1 and sometimes negative. Take a look at this example:

(...)
vn -0.000717425 0.00106739 -0.00991695
vn 3.49779e-09 -5.22866e-09 -0.01
vn -0.00142294 0.00211706 -0.00966919
vn -0.00831486 -0.00555545 0
vt 5.82424 -20.091
vt 6.97527 -20.1873
vt 5.81848 -20.1618
vt -7.48189 8.29159
(...)

He sent me all textures on TGA format, which I am loading it correctly, but I am not being able to map these vts to a correct OpenGL texture vector.

genpfault
  • 51,148
  • 11
  • 85
  • 139
rodrigogq
  • 1,943
  • 1
  • 16
  • 25

1 Answers1

6

But I can't figure out why the texture vertex are greater than 1 and sometimes negative.

Texture coordinates outside the [0..1] range indicate texture repetition.

Given a 1D texture ABCD:

   -1    0    1    2
....|ABCD|ABCD|ABCD|....

Make sure GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T are set to GL_REPEAT.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • I got it. But does the negative numbers make any sense? I have the 'GL_TEXTURE_WRAP_S' and 'GL_TEXTURE_WRAP_T' set, and now it is working for some textures, but not all of them. Guess I need to figure out how to set another property for negative numbers to work now. – rodrigogq Mar 18 '14 at 21:58
  • 1
    Negative numbers just wrap in the other direction. See my edit. – genpfault Mar 18 '14 at 22:13