Hi all,
starting to import some blender models into jmp I realized, that I’ll have a closer look what goes wrong when importing blender files. Most files just did not load.
Here are some notes on the behavior of the blender loader. If a patch is attached, this is only for showing the lines, not a REAL PATCH. I just wanted to analyse where the causes come from.
A zip with all the files and a testcalss can be found here: http://code.google.com/p/l2jserver-client/downloads/detail?name=FCBlenderTests.zip&can=2&q=
The models are all from opengameart
=================================================================
The loader has some problems with IndexBuffers, as this is way to internal for me I didn’t touch it.
@Kaelthas Perhaps some of the devs can have a look at this.
IntBuffer cloneIndexes = (IntBuffer) clone.getBuffer(Type.Index).getData();
com.jme3.asset.AssetLoadException: An exception has occured while loading asset: cementery_gate.blend
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:284)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:411)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:421)
at TestBlenderFile.simpleInitApp(TestBlenderFile.java:19)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at com.jme3.system.NullContext.initInThread(NullContext.java:85)
at com.jme3.system.NullContext.run(NullContext.java:128)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: java.nio.DirectShortBufferU cannot be cast to java.nio.IntBuffer
at com.jme3.scene.plugins.blender.modifiers.MirrorModifier.apply(MirrorModifier.java:113)
at com.jme3.scene.plugins.blender.objects.ObjectHelper.toObject(ObjectHelper.java:170)
at com.jme3.scene.plugins.blender.AbstractBlenderLoader.toObject(AbstractBlenderLoader.java:132)
at com.jme3.scene.plugins.blender.BlenderLoader.toObject(BlenderLoader.java:1)
at com.jme3.scene.plugins.blender.BlenderModelLoader.toObject(BlenderModelLoader.java:1)
at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:63)
at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:1)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:282)
… 7 more
=================================================================
Next one:
It seems to me the properties in blender and the user data use different IDs for the data types (or blender loader tries to store userdata which is not atomized/converted to userdata)
Unsupported type: com.jme3.scene.plugins.blender.objects.Properties
In UserData.getObjectType() line:98
called through com.jme3.scene.plugins.blender.meshesMeshHelper.toMesh() line:340
=================================================================
There are some issues with catching Exceptions. I had the following exceptions on this one (ClassCastException, AssetNotFoundException, IllegalstateException), though it only catches IOExceptions.
Index: src/core/com/jme3/asset/DesktopAssetManager.java
===================================================================
— src/core/com/jme3/asset/DesktopAssetManager.java (revision 9466)
+++ src/core/com/jme3/asset/DesktopAssetManager.java (working copy)
@@ -280,7 +280,7 @@
try {
handler.establishParentKey(key);
obj = loader.load(info);
-
} catch (IOException ex) {<br />
-
} catch (Exception ex) {<br />
throw new AssetLoadException("An exception has occured while loading asset: " + key, ex);
} finally {
handler.releaseParentKey(key);
=================================================================
getTextureFromImage might return null, resulting in an NPE. Saw on other use cases it is queried for null before usage, so I did the same here. And further down also added more exception catching, for the same reasons as above.
Index: src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.java
===================================================================
— src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.java (revision 9466)
+++ src/blender/com/jme3/scene/plugins/blender/textures/TextureHelper.java (working copy)
@@ -137,7 +137,9 @@
if (pImage.isNotNull()) {
Structure image = pImage.fetchData(blenderContext.getInputStream()).get(0);
result = this.getTextureFromImage(image, blenderContext);
-
this.applyColorbandAndColorFactors(tex, result.getImage(), blenderContext);<br />
-
if(result != null) {<br />
-
this.applyColorbandAndColorFactors(tex, result.getImage(), blenderContext);<br />
-
}<br />
}
break;
case TEX_CLOUDS:
@@ -497,6 +499,8 @@
LOGGER.log(Level.FINE, “Adding texture {0} to the loaded features with OMA = {1}”, new Object[] { texturePath, image.getOldMemoryAddress() });
}
blenderContext.addLoadedFeatures(image.getOldMemoryAddress(), image.getName(), image, result);
-
} else {<br />
-
LOGGER.log(Level.SEVERE, "Failed to load texture from file: {0}", texturePath);<br />
}
}
return result;
@@ -606,7 +610,7 @@
result = assetManager.loadTexture(key);
break;// if no exception is thrown then accept the located asset
// and break the loop
-
} catch (AssetNotFoundException e) {<br />
-
} catch (Exception e) {<br />
LOGGER.fine(e.getLocalizedMessage());
}
}