As I see, GLTF allows to transfer custom properties from Blender to engine.
(Custom Properties in Object Properties, writted by blender to “extras” property in “nodes” array of GLTF)
But I haven’t found any way to read them from JME. I looked to GltfLoader sources, and it seems that extras used only to get some “targetNames” which then used in Mesh. I expected to see code that transfers custom properties from extras to Spatial.userData or something like that.
Actually, it doesn’t blocks me, because I still can identify geometry nodes by name. But I’m curious if there are more pure ways.
You can implement ExtrasLoader also. This is a quick and dirty implementation, better to be generic on it.
Look at pauls code in the JmeConvert repo for a better example of implementation.
public class GltfUserDataLoader implements ExtrasLoader {
@Override
public Object handleExtras(GltfLoader loader, String parentName, JsonElement parent, JsonElement extras, Object input) {
// if its a geometry, we want to add all the geometry userdata
if (input instanceof Spatial) {
if (extras.isJsonObject()) {
JsonObject ext = extras.getAsJsonObject();
for(Entry<String, JsonElement> element : ext.entrySet()) {
Spatial spatial = (Spatial) input;
if (element.getKey().equals("open")) {
spatial.setUserData(element.getKey(), element.getValue().getAsBoolean());
}
}
}
}
return input;
}
}
Edit: Useage
GltfModelKey modelKey = new GltfModelKey("Textures/Level/Door.gltf");
ExtrasLoader extras = new GltfUserDataLoader();
modelKey.setExtrasLoader(extras);
I usually avoid use of command line or GUI utils with preference for tools embedded to build process or runtime. But hope it’ll be useful for abother jME users!