I load my model
[java]
model = assetManager.loadModel(fileName);
System.out.println(">> "+model.getName());
[/java]
and model.getName() returns filename, which I need.
But when using
String objName = results.getCollision(i).getGeometry().getName();
this is geometry’s name (which I dont need atm, it’s almost always Cube anyway (scenes created with blender)).
Where I find that collision object’s filename?
Probably its a parent of that geometry, so go up the scene graph until you find it.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies
Ah, I didnt go up enough, had checked .getParent().getName(); but it was
results.getCollision(i).getGeometry().getParent().getParent().getName();
(first time some object throws null pointer so I forgot searching it this way)
You should probably do a recursive search that either terminates when a node has no parent or when the node has the name you searched for. You should not hard-code the search the way you did.
1 Like