PDA

View Full Version : Problem importing .obj / .mtl (exported using blender) into my OpenGL view



fp13__
09-27-2012, 04:14 AM
Hi,

i have a problem when trying to import a blender-generated .obj/.mtl into my OpenGL view.

The problem is the that the textures are not how they should be.

I append a picture of the object in my Opengl view and how it is displayed in blender.
If you want i can upload my code, just tell me which part you need.

I tried to fix / understand this for a long time, but as im only starting with openGL...
i THINK it is a problem with negative texture coordinates. Still im not sure how to handle it.

http://i45.tinypic.com/2exucu0.png
http://i47.tinypic.com/332b0py.png


# Blender v2.63 (sub 0) OBJ File: 'quad_UV.blend'
# www.blender.org
mtllib quad_UV.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.000000 0.000000
vt -0.000000 -1.000000
vt 1.000000 -1.000000
vt 1.000000 0.000000
vt -1.000000 0.000000
vt 0.000000 1.000000
vt -1.000000 1.000000
vt 1.000000 1.000000
vt -1.000000 -1.000000
usemtl Material_BrownBrickWall_tileable.jpg
s off
f 8/1 7/2 6/3
f 5/4 6/1 2/2
f 6/4 7/1 3/2
f 4/1 3/5 8/6
f 5/4 1/3 8/1
f 4/1 1/4 3/2
f 5/6 8/7 6/1
f 1/1 5/6 2/5
f 2/1 6/6 3/5
f 3/1 7/6 8/8
f 8/6 1/4 4/1
f 1/1 2/2 3/9



# Blender MTL File: 'quad_UV.blend'
# Material Count: 1
newmtl Material_BrownBrickWall_tileable.jpg
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
map_Kd BrownBrickWall_tileable.jpg

newsb
10-02-2012, 02:08 PM
Hi,

i have a problem when trying to import a blender-generated .obj/.mtl into my OpenGL view.

The problem is the that the textures are not how they should be.

I append a picture of the object in my Opengl view and how it is displayed in blender.
If you want i can upload my code, just tell me which part you need.Did you try to load your obj and mtl file into another program, which you trust and believe works correctly? Does it work? If it works, then your code is wrong. And if it's wrong, why don't you post your code here? How should we see what is wrong with your code, if we cannot see your code? You know that you can download source code for these obj-loaders, various places right? If you download a few and find one that works then all you have to do, is to compare the code that works with your code that doesn't work. Shouldn't be too difficult.

fp13__
03-28-2013, 04:17 AM
Did you try to load your obj and mtl file into another program, which you trust and believe works correctly? Does it work? If it works, then your code is wrong. And if it's wrong, why don't you post your code here? How should we see what is wrong with your code, if we cannot see your code? You know that you can download source code for these obj-loaders, various places right? If you download a few and find one that works then all you have to do, is to compare the code that works with your code that doesn't work. Shouldn't be too difficult.

Sorry for bringing this up again. I solved the above problem (it was due to a major misunderstanding of one of the opengl functions).

But do you / does anyone know a good loader for .obj/.mtl files or other files in general? I did some research in the internet but found no loader with a good documentation.

hermin_potter
04-08-2013, 09:03 AM
Sorry for bringing this up again. I solved the above problem (it was due to a major misunderstanding of one of the opengl functions).

But do you / does anyone know a good loader for .obj/.mtl files or other files in general? I did some research in the internet but found no loader with a good documentation.

I'm having the same problem. Could you elaborate what the problem was you had?

Sincerely,
H.P.