As many of you know, I developed the JMEC (JmeConvert) tool some time back. It works pretty well to convert models to j3o and can even run post-processing scripts on them to make adjustments during the conversion process.
Yesterday, I threw together a prototype of an autoloader. Essentially, you can add this to your scene and it will automatically reconvert the source on the fly if the file changes. It even detects when scripts change.
Here is a video demonstrating what I mean:
This is all I had to do to add that model to my test scene:
JmecNode jmecNode = new JmecNode(new File("samples/test-model.gltf")); jmecNode.addModelScript(new File("sampleScripts/test-script.groovy")); rootNode.attachChild(jmecNode);
This is the relevant part of the script I edited in the video:
// Move the model so that it's base is at y=0 def bound = model.modelRoot.getWorldBound() model.modelRoot.setLocalTranslation(0, (float)(bound.yExtent - bound.center.y), 0);
It’s some pretty standard script code I use to make a model stand on the ground.
I wonder how folks might envision using this?
For myself, I was thinking I’d add this to my game temporarily while I worked on the model and then switch to regular asset loading. So the JmecNode in the example code above was the very simplest way to do that.
But it occurs to me that maybe some folks would want to be able to easily switch back and forth between auto-convert mode and “production” mode where it just loads the converted asset.
This could either be done with some kind of JmecLoader that would provide auto-convert nodes or regular AssetLinkNodes depending on the mode it was in… or I might be able to work this as an actual AssetLoader where adding the loader or not adding the loader changes what would happen for some special type of asset key.
That last bit might be tricky so I thought I’d see what folks might want before diving into the asset loader swamp.