Get Access to sub-meshes of Spatial-Objects


i need help to get access to a sub-mesh which belongs to a scene, that i load via the assetManager.

The Example-Code: (houseScene = Node)

Geometry submesh = (Geometry) houseScene.getChild(“door 12”);

which is written by a tutorial on this site, doesn´t work. I get a NullPointerExeption…

The Example-Code: (spatial = the loaded scene)

Geometry result = spatial.getName().startsWith(name);

which is written in the FAQ, doesn`t work. I get the message, that netbeans cannot cast from boolean to geometry…

Anyone can help me?

Geometry result = spatial.getName().startsWith(name); o.O?

You might want to increase you basic java knowledge first, (even if the faq/tutorials have errors)

startsWith(name) return true or false , true if it starts iwth name, but it does not return a geomtry

houseScene probably hasn’t been initialised yet when you try to get a child from it.

And yes the FAQ does give [java]Geometry result = spatial.getName().startsWith(name); [/java] someone should probably change that :wink:

I said that this returns a boolean variable in my post. Cause of that, i want to ask why :wink:

I want to realize, that i can move an object, which is loaded as part of a scene. The scene was loaded as a Spatial. But a spatial-object has no “getName()”-Method…How can i realize my problem? :confused:

For example:

Szene as obj: Terrain

Terrain contains a house, a tree and a flower.

I load the 3D-Scene: testScene = assetManager.loadModel(“Models/terrain_scene.mesh.xml”);

Now i want to place the house in this scene to another point, by moving the sub-object.

Is that realizable?

I did like this:

Also there is visit(Spatial) method in JME… or node.visit(Spatial)… don’t remember, but something like:


visit(spatial) {

if (spatial instanceof Geometry && spatial.getName(“door 12″)) {

Geometry geo = (Geometry) spatial;





1 Like

Of course. Just take the terrain node, iterate over the children and once you found the house, move it. Obviously you give your house a unique name or something else you can recognize it with.

1 Like

Yeah…Thanks a lot for helping! :slight_smile: