3

The goal of my program is to display a simple cube UV mapped exported from Blender. But the texture mapping in my openGL program is not correct. I want to precise that the display of my UV mapped cube is perfect on Blender. My texture is composed of a simple color for each face(Red, green, blue, purple, yellow and orange). I've choosen to export my mesh in .obj and .mtl files using quads. Here's the content of my .obj file (I've added some comments):

# Blender v2.63 (sub 0) OBJ File: ''
# www.blender.org
mtllib Box.mtl
o Cube
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.500000 1.000000 //1
vt 0.250000 1.000000 //2
vt 0.250000 0.750000 //3
vt 0.500000 0.750000 //4
vt 0.500000 0.250000 //5
vt 0.500000 0.500000 //6
vt 0.250000 0.500000 //7
vt 0.250000 0.250000 //8
vt 0.500000 0.000000 //9
vt 0.250000 0.000000 //10
vt 0.000000 0.750000 //11
vt 0.000000 0.500000 //12
vt 0.750000 0.500000 //13
vt 0.750000 0.750000 //14
usemtl Material_Box.bmp
s off
f 1/1/1 2/2/1 3/3/1 4/4/1 //Orange OK
f 5/5/2 8/6/2 7/7/2 6/8/2 //Green OK
f 1/9/3 5/5/3 6/8/3 2/10/3 //Red OK
f 2/11/4 6/12/4 7/7/4 3/3/4 //White (should be purple) NOT OK
f 3/3/5 7/7/5 8/6/5 4/4/5 //Yellow 5 OK
f 5/13/6 1/14/6 4/4/6 8/6/6 //White (should be blue) NOT OK

My unwraped cube looks like a cross. Here's my UV texture (I want to precise that the '3bis' and '4bis' correspond to the .obj file wrong coordinates. Only the 1, 2, 5 and 6 faces coordinates are correct):

enter image description here

And here's an exemple of my openGL render :

enter image description here

You can see the '4bis' white face like on the uv texture.

So, certain coordinates generated by blender seems to be wrong. Why? Does the problem comes from that the blue quad doesn't touch the right side of the picture creating a translation of certains coordinates? Maybe I must precise a special parameter before exportation in Blender... Does anyone can help me?

icedwater
  • 4,701
  • 3
  • 35
  • 50
user1364743
  • 5,283
  • 6
  • 51
  • 90
  • 3
    Try to mirror the V coordinate of your texture coordinates, e.g. pass 1-V instead of v. – Nils Pipenbrinck Oct 21 '12 at 15:35
  • Thanks very much for your answer. It works perfectly now. But I would like the coordinates generated by Blender in the .obj file to be good whith its own values. Do you have an idea about that? Or I have to assign to V = 1 - V ? Is that is an openGL rule or the blender exportation is bad? Thanks you. – user1364743 Oct 21 '12 at 15:45
  • The problem is not solved finally : I have another exportation file but this time the unwrapped cube is rotated of 90° and it's the same thing than before. That's why I wonder if I must respect a rule to export uv-textured meshes with Blender. Thanks ion advance. – user1364743 Oct 21 '12 at 15:55
  • Finally, all is ok. I tried to put a UV texture on a more complex mesh (the monkey head in Blender) and the UV mapping is good with your technique! Thanks very much again for your help! Bye. – user1364743 Oct 21 '12 at 22:36
  • @NilsPipenbrinck Maybe it would be a good idea to formulate your answer as an official answer for future readers? – Random Citizen Oct 11 '14 at 10:09
  • @user1364743 You should post your solution as an answer to the question to help future readers – Jojodmo Dec 07 '16 at 00:05

0 Answers0