Assimp-based model import and the MonkeyWrench library

Does MonkeyWrench load user data for gltf/glb scenes? I am trying to use userdata to locate certain spatials of my scene, but cannot find any userdata entries.

Spatial scene = assetManager.loadModel("Models/gi-test.gltf");
rootNode.attachChild(scene);
for (Spatial s : new SceneGraphIterator(scene)) {
    System.out.println(s.getName());
    for (String k : s.getUserDataKeys()) {
        System.out.println("  " + k);
    }
    if (s.getUserData("LightMesh") != null) {
        meshLight = s;
        break;
    }
}

The console isn’t printing any userdata entries for any spatial in the scene. The gltf file does contain the userdata entries.

{
	"extras":{
		"LightMesh":true
	},
	"mesh":9,
	"name":"LightCube",
	"translation":[
		10.90345573425293,
		0.3555701673030853,
		2.9181900024414062
	]
},
1 Like

MonkeyWrench loads user data in some cases … for instance when a node has “extras” metadata of certain types (boolean, double, float, integer, long, string, or Vector3f).

If you provide me with a complete glTF file containing the user data you’re interested in, I’ll investigate to see what’s going on and whether MonkeyWrench can be extended to load it. (Small files preferred over large ones.)

1 Like

Here is the gltf file. The corresponding binary and the source blend file are nearby.

Thanks for looking into this!

1 Like

It appears the only node extra in “gi-test.gltf” is the

         "LightMesh":true

in line 373, and that is being loaded to the JME Node correctly.

The other extras appear to be on materials

          "lp":{
                 "uid":"5157a2d78e"
          },
          "pov":{},
          "yp":{
                  "active_ypaint_node":""
           }

or scenes

   "camera_train_target":{},
   "camera_test_target":{},
   "init_active_camera":{},
   "subrect_atlas":{},
   "uv_box":{},
   "trim_atlas":{},
   "duv_hotspotmaterial":{},
   "lp":{
           "mask_assets":[
            {
                  "name":"Spots",
                  "thumbnail":"Spots.jpg",
                  "asset_type":0,
                  "blend_file":"mask_basics.blend"
           },

MonkeyWrench currently ignores extra on materials and scenes. How do you think they should be handled?

1 Like

Strange, I am definitely not seeing any userdata on any spatials… oh, hold on, I see that extras loading was added in 0.6.1, but I haven’t upgraded past 0.5.3. Totally my bad, very sorry about that! :sweat_smile:

MonkeyWrench currently ignores extra on materials and scenes. How do you think they should be handled?

It looks like a scene is parsed as a node, so I think it would be logical to attach the extras data to its userdata if possible.

The materials I’m not sure about, but I imagine it could be handy if the extras were parsed as material parameters and/or render states. I don’t know to what extent gltf’s material parameters overlap with PBRLighting’s, so I don’t know how useful that would end up being.

1 Like

Further investigation suggests Assimp ignores extras on materials, making them invisible to MonkeyWrench. I may open an issue at the Assimp repo, if there isn’t one already.

EDIT: I opened Assimp issue 5960. There’s a backlog of 714 open issues, so I don’t expect anything to happen unless I submit a PR.

I’ve added warnings when scene extras are ignored, to help clarify what’s happening. Without an identified use-case, however, I’m reluctant to attach the information to anything.

2 Likes