.obj model is loaded, .mtl not

Hey



So I try to load a model in JME3 with assetManager.loadModel(“Models/tree.obj”);. There is also a tree.mtl file and all the textures are in the same folder “Models”. So the model is loaded but the textures are not assigned to the model.



Models

|- tree.obj

|- tree.mtl

|- bark.jpg

|- leaf.jpg



Spatial tree = assetManager.loadModel(“Models/tree.obj”);



Should I do something extra to assign the material?

Check the logs to see if there’s an attempt to load the material. The OBJ file must have a “mtllib” statement that specifies which material file it should use.

Problem is solved. I didn’t add a light to my world so the object was not shown.

Hey there,



I’m having the same problem as the OP. I’m pretty new to programming and Maya so I am simply trying to modify the Hello Materials tutorial to learn a bit. I can load in .obj just fine, but when running the program, only some of the faces show up (because they are facing the light source?).n the output window I get this:



May 10, 2011 3:06:41 PM com.jme3.material.MaterialDef

INFO: Loaded material definition: Phong Lighting

Unknown statement in MTL! Tf

May 10, 2011 3:06:41 PM com.jme3.asset.DesktopAssetManager loadAsset

Unknown statement in MTL! Tf

WARNING: No loader registered for type .

Unknown statement in MTL! Tf

May 10, 2011 3:06:41 PM com.jme3.asset.DesktopAssetManager loadAsset

WARNING: No loader registered for type .

May 10, 2011 3:06:41 PM com.jme3.scene.plugins.OBJLoader readFace

WARNING: Edge or polygon detected in OBJ. Ignored.





The .mtl file looks like this:



newmtl surfaceShader1SG

illum 4

Kd 0.00 0.00 0.00

Ka 0.00 0.00 0.00

Tf 1.00 1.00 1.00

map_Kd -s 0.125 0.125 plywoodface.jpg

Ni 1.00



Any help would be greatly appreciated!



~jester



ps.

when I run the program I also get this output printed like 20 times:



May 10, 2011 3:06:41 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

May 10, 2011 3:06:41 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)



is that normal?

There are a few issues mentioned there.

First, you have edges or polygons in your OBJ file, if there’s an option in the exporter called “Triangulate” make sure it is selected.

Second, it seems the texture has failed to be loaded, because some arguments were specified on it, recently I committed a fix to the OBJ importer that should hopefully fix that.



OBJ is not a very well supported format in jME3, so if you can, I recommend using the OgreXML exporter for Maya:

Thank you for the response! Using the triangulate make all of the faces show up, but the texture is still not there. I couldn’t get OgreXML exporter to work on my home machine the first time (pc), is there a recommended exporter for maya 2011 on a mac (work machine)? The only exporter is for like maya 8.

I was just going to post a very similar issue I am having with a free model I found on the web. So is JME3 no longer fully supporting obj?

Edit: Actually my issue is a bit different. I have imported an obj model into JME3 app and added Directional light per the tutorial, but it just shows up totally black. Is there something more that I need to do?



2nd edit: my issue with the material was that I was not exporting correctly from blender. Still curious about obj support going forward…

We try to support OBJ as much as possible, however the format is quite limited in certain parts (materials) while more complex in other parts (mesh data).

If you have any OBJ files that fail to load, please send them to me so I can fix the importer

jjhavokk said:
2nd edit: my issue with the material was that I was not exporting correctly from blender. Still curious about obj support going forward..

Can you tell me what you changed with the exporting? I have a similar problem and am wondering if the problem lies here. I used material colors on the model which consist of multiple objects, so it get imported as a node in jme. However it turns up black and I dont know the mtl is parsed correctly.