Blender to j3o converter error

  1. i make .blend file
  2. add to project
  3. click convert to j3o
    and have this error
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: WS00
Unknown block header: PL00
Loading animations that will be later applied to scene features.
An Exception has occured when trying to load asset main_scene
com.jme3.asset.AssetLoadException: An exception has occurred while loading asset: Models/scene/main_scene.blend
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:262)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:374)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:417)
	at com.jme3.gde.core.assets.SpatialAssetDataObject.loadAsset(SpatialAssetDataObject.java:94)
	at com.jme3.gde.core.assets.actions.ConvertModel$1.run(ConvertModel.java:65)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.IOException: Unexpected importer exception occurred: null
	at com.jme3.scene.plugins.blender.BlenderLoader.load(BlenderLoader.java:223)
	at com.jme3.scene.plugins.blender.BlenderLoader.load(BlenderLoader.java:88)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:260)
	... 5 more
Caused by: java.lang.NullPointerException
	at com.jme3.scene.plugins.blender.BlenderLoader.load(BlenderLoader.java:109)
	... 7 more
1 Like

The jme3-blender import library was written for a very old version of Blender. (I don’t know exactly which version — maybe from 2015 or 2016?) The .blend file format changes from release to release.

It appears your .blend was written by a newer version of Blender, using a file format that the jme3-blender doesn’t understand.

Trying to load blender files directly into anything is a bit of a pain (I don’t think blender files are intended as transfer formats, you export to something for that). My workflow for converting blender files to j3o is as follows:

  1. In blender export as GLTF (File > Export > gltf 2.0)
  2. Include in a jmonkey project the dependency jme3-plugins

If using gradle that means adding to your build.gradle the following:

implementation 'org.jmonkeyengine:jme3-plugins:3.5.1-stable'

  1. Loading the gltf file in your jmonkey project using the asset loader

  2. (Optionally) save the gltf file back out to j3o format for use in your real application. You can use the gltf file directly but your load time will be slower (And you’ll have to include the jme3-plugins dependency with your final application). This can be done using the BinaryExporter

     BinaryExporter exporter = new BinaryExporter();
     exporter.save(handLeft, new File("someLocation/someFile.j3o"));
    

References:

  1. i export my model to gltf (glb)
  2. i use plugins:3.5.1
  3. i load model
assetManager.registerLocator("./assets", FileLocator.class);
       Spatial mainScene = assetManager.loadModel("Models/main_scene.glb");
       rootNode.attachChild(mainScene);  
       
       DirectionalLight sun = new DirectionalLight();
        sun.setColor(ColorRGBA.White);
        sun.setDirection(new Vector3f(-.5f,-.5f,-.5f).normalizeLocal());
        rootNode.addLight(sun);

in blender
6

and black screen in jmonkey

can you test my glb model?

I’ve had a look at your glb and it looks good

I suspect you didn’t have any light in your scene, hence everything was black, when debugging I often turn the viewport background to anything but black so the “black object on a black background” doesn’t confuse things

    getViewPort().setBackgroundColor(ColorRGBA.Brown);

Put some light in your scene like

    DirectionalLight sun = new DirectionalLight();
    sun.setColor(ColorRGBA.White);
    sun.setDirection(new Vector3f(-.5f,-.5f,-.5f).normalizeLocal());
    rootNode.addLight(sun);

Complete application

public class Example extends SimpleApplication {

    public static void main(String[] args) {
        Example app = new Example();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        getViewPort().setBackgroundColor(ColorRGBA.Brown);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        Spatial spatial = assetManager.loadModel("Models/main_scene.glb");

        DirectionalLight sun = new DirectionalLight();
        sun.setColor(ColorRGBA.White);
        sun.setDirection(new Vector3f(0.5f,-0.5f,-0.5f).normalizeLocal());
        rootNode.addLight(sun);

        cam.setLocation(new Vector3f(-5, 2, 0));
        cam.lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y);

        rootNode.attachChild(spatial);
    }

    @Override public void simpleUpdate(float tpf) {}
    @Override public void simpleRender(RenderManager rm) {}
}
1 Like

Does that mean its fixed? Looks like you’ve got some light in there now