We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Obj importer materials issue.
Page Index Toggle Pages: 1
Obj importer materials issue. (Read 899 times)
Obj importer materials issue.
Jul 27th, 2007, 4:38pm
 
Hello,

I'm using the saito.objloader library, and have come across a weird bug. The obj files I'm using are exported from Blender. The bug is thus: I'm using untextured materials, and for some reasons the objects show up completely black. If, however, I go into the .obj file and remove both the line where it imports the matlib and the line where it sets the material, then the material shows up.

I thought maybe it was just an issue with my sketch, but even on the downloaded sample from the web page there is the same issue of untextured materials appearing black.
Re: Obj importer materials issue.
Reply #1 - Jul 27th, 2007, 10:53pm
 
The objloader get's it material color (the fill part in processing) from the Ka line in the mtl file. They are float values between 0 and 1 (0 to 255 in processing color terms) If the map_Kd line is blank then it should default to not using a texture and just use the Ka line as a fill color value for the model. In version 013 a bunch of material options went in to disable the mtl material and use your own.

Saito is in the middle of updating the official site but I've got a mirror of the new material changes here http://www.polymonkey.com/2008/page.asp?obj_loader

Having said all that I haven't done any tests with obj/mtl info out of blender so if none of this helps I'd be happy to check it out if you can post a link to the problem files.
Re: Obj importer materials issue.
Reply #2 - Jul 31st, 2007, 4:12pm
 
Well I realized that my problem was that the colorMode had been switched to HSB in the sketch. I was trying to have a red material (255, 0, 0), but it was being interpreted as a colour with 0 brightness and saturation.

Textures stil don't work for me, however. My files are thus:
Code:

# Blender3D v244 OBJ File: truck.blend
# www.blender3d.org
mtllib truck.mtl
o Grid
v -2.461555 -1.004614 1.000000
v 2.187815 -1.004614 1.000000
v -1.791051 -0.230420 1.000000
v -2.461555 -0.230420 1.000000
v -1.016858 0.543773 1.000000
v -0.758793 0.543773 1.000000
v 2.187815 1.043494 1.000000
v -0.758793 1.043494 1.000000
v -1.265245 -1.004614 1.000000
v -0.965245 -0.704614 1.000000
v -0.665245 -1.004614 1.000000
v 0.634755 -1.004614 1.000000
v 0.934756 -0.704614 1.000000
v 1.234756 -1.004614 1.000000
v 1.234755 -1.004614 -1.000000
v 0.934755 -0.704614 -1.000000
v 0.634755 -1.004614 -1.000000
v -0.665245 -1.004614 -1.000000
v -0.965245 -0.704614 -1.000000
v -1.265245 -1.004614 -1.000000
v -0.758793 1.043494 -1.000000
v 2.187815 1.043494 -1.000000
v -0.758793 0.543773 -1.000000
v -1.016858 0.543773 -1.000000
v -2.461555 -0.230421 -1.000000
v -1.791051 -0.230421 -1.000000
v 2.187815 -1.004614 -1.000000
v -2.461555 -1.004614 -1.000000
s 1
usemtl Material
f 1 3 4
f 1 9 3
f 3 9 10
f 3 10 5
f 5 10 6
f 6 10 11
f 6 11 8
f 2 7 8
f 8 11 12
f 8 12 13
f 2 13 14
f 2 8 13
f 25 26 28
f 26 20 28
f 19 20 26
f 24 19 26
f 23 19 24
f 18 19 23
f 21 18 23
f 21 22 27
f 17 18 21
f 16 17 21
f 15 16 27
f 16 21 27
f 5 6 23
f 5 23 24
f 1 4 25
f 1 25 28


and

Code:

# Blender3D MTL File: truck.blend
# Material Count: 1
newmtl Material
Kd 0.60 0.60 0.60
Ka 0.6 0.60 0.60
Ks 0.9 0.9 0.9
Ns 0.0
map_Kd cloud1.png
d 1
illum 2
Re: Obj importer materials issue.
Reply #3 - Aug 1st, 2007, 12:13am
 
The mtl file looks fine. The problem is that the obj file has no texture information(UV coordinates). What you want to see is a line that starts with "vt". This refers to the UV position of the vertex. Once there is "vt" information then the "f" line will also change. At the moment it is "f int". This int tells the face to look at the numbered "v" line for position. Once "vt" infomation is there the "f" line will look like this "f int/int".

So if you're seeing the texture on the model in blender then maybe check the export settings. Is there an option in the blender obj export to "export UV's" that kind of thing?
Page Index Toggle Pages: 1