Forums/Layer Development Platform/Tips & Tricks by the Community

Blender 2.5 export settings

knisleyj
posted this on August 29, 2011 18:50

Is there anyone who can provide appropriate obj export settings for Blender 2.5 which will allow models to be imported and converted to l3d by the Layar 3D Model Converter?  I have found a few combinations (such as selecting only Triangulate and Material Groups) which allow the obj to be imported, but when I then save it as an l3d and try to open that l3d, I get an error that says "File does not contain a valid Layar3D model."

My assumption is that the problem lies in the fact that I haven't exported any materials from Blender, and hence the materials tab in the converter is empty, possibly leading it to create an invalid l3d file.  However, if I try to include materials in the obj export from Blender it is impossible for me to import the resultant obj into the converter... the converter simply hangs until I kill it from the task manager.  Screen shots are attached.

 

Comments latest first

User photo
xuan
staff

Hello Knisleyi,

Thanks a lot for your input. Yes, I experienced exact issue when there is no material name in the .obj and .mtl file. I have created two tickets (MAIN-3537 and MAIN-3536) for the model converter so that these issues can be detected and meaningful error messages should be returned.

Best Regards,

Xuan

September 06, 2011 10:12
User photo
knisleyj

Xuan,

Unfortunately I don't have the original problematic obj files anymore, but I just created a new one with the same export settings that I first tried (where "Materials" was unchecked in the Blender options settings").  If I try to import an obj file without that I now get an error that says "Trying to use material without a loaded material file.  Cannot load model."  Today is the first time I've ever seen that message, however I can still replicate the original problem I experienced by deleting the "usemtl" line on the obj file, which then allows the file to be imported and saved, however attempting to open the resultant l3d file gives the error "File does not contain a valid Layar3D model" (it actually just produces an empty file now).  The obj file is attached (bad1.obj).  This part seems to be less of an issue now though, because the initial error message now seems to effectively prevent the loading of an obj file without an associated mtl file.

As for the issue where Blender sometimes exports obj filed with an unnamed "usemtl", I've attached an example of that as well (test4.obj, test4.mtl).  Attempting to import test4.obj will not produce any error messages, it will simply cause the converter to hang.

September 02, 2011 17:50
User photo
xuan
staff

Hello Knisleyi,

Thanks for your input! This is the first time we saw this issue in .obj file exported from Blender. It is weird that the l3d model converter did not complain when you import the .obj file at the first place. I also checked a test model and removed the material name from .obj and .mtl files. The 3d model converter even does not allow me to import the .obj file. Can you send me the .obj/.mtl model which can be imported into the converter successfully but failed to open in .l3d format ?

Thanks!

Xuan

September 02, 2011 12:31
User photo
knisleyj

After some more trial and error, I found that the shape doesn't seem to matter.  Immediately after this post I made a simple model with cubes again, and the converter failed to successfully import it.  After that I began comparing the obj and mtl files which could be converted with those which could not, and I believe I've found the solution.  Right now it involves editing both of the files, but perhaps the converter could be modified to handle this instead.

In the obj files which failed to import, there is a line that references the material with "newmtl" but has no name after it, as you can see in this snippet that I cut and paste:

v -10.000004 0.250000 0.250000
v -9.999999 0.250000 -0.250000
usemtl
s off
f 1 2 3 4
f 5 8 7 6
f 1 5 6 2

The corresponding mtl file looks like this:

# Blender MTL File: ''
# Material Count: 1
newmtl
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

If I add a parameter name for newmtl such as "Material" in both the obj and mtl files, then the converter tools seems to work fine.  The obj snippet then looks like:

v -10.000004 0.250000 0.250000
v -9.999999 0.250000 -0.250000
usemtl Material
s off
f 1 2 3 4
f 5 8 7 6
f 1 5 6 2

and the mtl file looks like:

# Blender MTL File: ''
# Material Count: 1
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

As of now, I'm not sure why Blender sometimes names the "newmtl" and other times does not.  It seems to me that the converter is currently coded in such a way that a name MUST follow "newmtl" or else the converter hangs.

September 01, 2011 23:08
User photo
knisleyj

Xuan,

I'm not sure what changed, but when I tried today exporting and converting worked fine without editing the obj file provided that I use cubes.  However, if I try to create a model using cylinders then I get an obj file which causes the converter to hang when it attempts to import it.  I tried selecting the 'triangulate' option in the export settings with the same result.  It is possible to convert a model which uses cylinders?

September 01, 2011 22:41
User photo
xuan
staff

Hi, Knisleyi,

If you open the .obj file in text editor, you might see one line which includes the material file, something like "mtllib material_file.mtl". You can try to remove it and import the .obj file again.

Best Regards,

Xuan

September 01, 2011 12:37