JmeConvert auto-loader... w/question

So the latest JMEC master now supports extracting parts of the subgraph as separate j3o files that are linked into the main model via AssetLinkNodes.

This is in anticipation of when blender properly supports exporting instances to gltf… but even then (and in the mean time), this behavior is scriptable.

For example, here is a JMEC script snippet that will find all objects marked with a “submodel” custom attribute and export them as a separate j3o (last writer wins):

model.findAll(com.jme3.scene.Spatial.class).each { spatial ->
    String submodel = spatial.getUserData("submodel");
    if( submodel != null ) {
        model.extractSubmodel(spatial, submodel);
    }
}

So if you have a “tree” in your scene that you have many of, you could mark them with a custom attribute “submodel”=“tree”. When your model is written out, a tree.j3o will be written and all of those nodes will be replaced with an AssetLinkNode that will load that tree.j3o.

Even now, if you aren’t using groups/collections in blender and will simply be cut/pasting the same object over and over (linked or not) then you can add a custom property like this before you cut/paste them and then run a script like the above to extract them during conversion.

Useful for level design, I think.

JmecNode has also been updated to support this if you give it an asset manager. The example demo shows also to rejigger the asset locators to hit the file system first, also.