1- Create a new scene in Blender. Remove everything.
2- Create a cylinder mesh.
3- Export it using Wavefront format under /assets/models.
4- Right click on the obj file from inside JMonkeySDK and try “View Model”.
At this point you should see the error message and the following details:
java.lang.NullPointerException
at com.jme3.scene.plugins.OBJLoader.readFace(OBJLoader.java:250)
at com.jme3.scene.plugins.OBJLoader.readLine(OBJLoader.java:331)
at com.jme3.scene.plugins.OBJLoader.load(OBJLoader.java:516)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:243)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:379)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:389)
[catch] at com.jme3.gde.core.assets.SpatialAssetDataObject.loadAsset(SpatialAssetDataObject.java:81)
at com.jme3.gde.core.assets.actions.OpenModel$1.run(OpenModel.java:72)
at java.lang.Thread.run(Thread.java:662)
I get the same behavior in Blender 2.49.
Any help/comment?
EDIT: Try the same procedure with a cube instead of a cylinder and all is fine...
I prefer OBJ format to export my complex static scene. No animations. It is convenient for me since I only deal with 2 files as opposed to OgreXML’s 1 file per mesh.
Anyway, I found the problem source:
In the exported OBJ file, if the mesh has no material:
usemtl (null)
AND if the OBJ file references to an MTL file:
mtllib untitled.mtl
then JME throws NullPointerException.
If the mesh has no material AND the OBJ file does NOT reference to an MTL file then all is fine...
This to me looks like a bug in the JME OBJ importer...
What do you think?
EDIT: By the way, you guys did an exceptional job with JME SDK. It truly is amazing. I came from Ogre and Panda3D and it seems like I will hang out with JME for a long time...Hats off...
“(null)” is not a valid value for “usemtl”. I checked the spec.
If no material named “(null)” is defined in the MTL file, then this is a parsing error. I have committed a fix to SVN that displays a better error message when this occurs.
Make sure all meshes in Blender3D have a material assigned, or alternatively you can request the authors of the OBJ exporter to follow the spec.
Momoko_fan, what about the difference between ogre, obj and assetManager uv coordinates? Did you choose UV-flipping standard? I’m just curious about such an issue of UV difference importers.