PolygonLoadingSample does not work with .obj file with texture

Dec 3, 2013 at 1:27 PM
Hello!

For the context: I am playing for a while with blender, I am learning c# and I heard about sharpGL. I thought sharpGl could be a good opportunity to dig into c# coding with fun.

Before coding by myself I am playing a little bit with the examples. I tried to display an obj file of mine with PolygonLoadingSample. The obj file is a simple cube with a texture. I added the obj, mtl and png files in the PolygonLoadingSample project. When I click on "Load Polygon..." I can select my obj file, but the cube displayed by PolygonLoadingSample does not have my texture but something like a "snow" effect when I select Render/Solid and Render/Lighted.

Where is the error? Did I make an error with my obj/mtl/png files? Are there some special properties to set when I export obj/mtl files from Blender?

here is my obj file:
# Blender v2.68 (sub 0) OBJ File: 'CubeWithTexture.blend'
# www.blender.org
mtllib CubeWithTexture.mtl
o Cube_Cube_Material
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 -1.000000 1.000000 -1.000000
v 0.999999 1.000000 1.000001
v -1.000000 -1.000000 1.000000
v -1.000000 1.000000 1.000000
vt 0.665647 0.333333
vt 0.666667 0.665647
vt 0.333333 0.334353
vt 1.000000 0.334353
vt 0.998980 0.666667
vt 0.667686 0.333333
vt 0.998981 0.000000
vt 1.000000 0.332314
vt 0.666667 0.001019
vt 0.334353 0.333333
vt 0.333333 0.001020
vt 0.666667 0.332314
vt 0.332314 0.333333
vt 0.333333 0.665647
vt 0.000000 0.334353
vt 0.332314 0.000000
vt 0.333333 0.332314
vt 0.000000 0.001020
vt 0.334353 0.666667
vt 0.665647 0.000000
vt 0.001020 0.666667
vt 0.001020 0.333333
usemtl Material.001
s off
f 1/1 2/2 3/3
f 4/4 5/5 6/6
f 1/7 4/8 2/9
f 2/10 6/11 7/12
f 7/13 8/14 3/15
f 4/16 1/17 5/18
f 2/2 7/19 3/3
f 5/5 8/2 6/6
f 4/8 6/6 2/9
f 6/11 8/20 7/12
f 8/14 5/21 3/15
f 1/17 3/22 5/18
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
usemtl Material
s off
f 9 10 11 12
f 13 16 15 14
f 9 13 14 10
f 10 14 15 11
f 11 15 16 12
f 13 9 12 16
and here is my mtl file:
# Blender MTL File: 'CubeWithTexture.blend'
# Material Count: 2

newmtl Material
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

newmtl Material.001
Ns 92.156863
Ka 0.000000 0.000000 0.000000
Kd 0.512000 0.512000 0.512000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd wallc.png
Thank you in advance for your answer.
Coordinator
Mar 25, 2014 at 1:59 PM
The new object loading sample in the master branch uses an updated object file loader (see https://github.com/dwmkerr/file-format-wavefront) to support texture loading and works properly! Take a look at the sample to see if it helps, so far I've been loading textures without any problems :)