Object must be a geometry

So I load a .j3o object into a spatial and when debugging it show that the spatial has only one Geometry. And then when I try to cast it to Geometry I get a java.lang.IllegalArgumentException: Object being imported is a Node. The object imported must be a Geometry.

How come it is a node when it only contains one geometry? To my understanding from the wiki a Node could have several geoms and u get them by looping the array but if it only has one geom then I should be able to cast it directly to a Geometry right?

thats not how inheritance works, Node and Geometry are siblings, and have the parent, Spatial (the superclass). They both contain all Spatial’s functionality like .addControl(), as well as their own specialized functionality. It follows the “is a” paradigm. You can cast Node and Geometry to a Spatial because they are both (is a) Spatials, but a Node is not a Geometry.

As to why your .j3o is a Node with 1 geometry and not just a geometry, idk

Read the manual, theres always a geometry per object or material. Also multiple textures will divide into multiple geometry.

ah I should have looked more into the source code, I didn’t know that. Thanks…

so If I have a .blend file and I import it to JMP, it gets converted to .j3o… anyone has an idea why this file is a node and not a geom? and what can I do?


but that’s the thing, in Blender I only have a mesh and ONE material (no textures, nothing else) - does that count as a node??

I guess the blender importer always puts it in a node regardless, just open the model in the SceneComposer and look at the SceneExplorer to see the structure.

It’s created a node with a geometry inside it - most likely just because that’s the more flexible arrangement and the conversion is generic.

You can extract the geometry from the node for use though and just use that geometry without the node.

I did and here it is: (not sure what it means if node or geom)


<img src=

anything I could do to convert it to a geometry?

and to convert is it something like this


Node node = (Node) assetManager.loadModel("/Models/shelf/Shelf.j3o");

mySpatial = (Geometry) node.getChild(0);[/java]

I get the same error - what am I missing :S?

Its two nodes.

The two icons with 3 arrows are a node, the cube is a geometry.


if you dont want to specify path to geometry, just search it.

something like:

[java]public Geometry findGeom(Spatial spatial) {

if (spatial instanceof Node) {

Node findingnode = (Node) spatial;

for (int i = 0; i < findingnode.getQuantity(); i++) {

Spatial child = findingnode.getChild(i);

Geometry result = findGeom(child);

if (result != null) {

return result;



} else if (spatial instanceof Geometry) {

return (Geometry) spatial;


return null;


Theres a nice traversal system built into the jme scenegraph that allows you to check for geometry or nodes only:

[java]spatial.depthFirstTraversal(new SceneGraphVisitorAdapter(){


public void visit(Geometry g){

//do stuff to geometry here




I did not know about it, thanks! :slight_smile:

thanks guys

but I am almost sure it used to import it as a geometry… even if I convert it back to geom using your method it messes up some other code such as batching

[java]May 30, 2012 2:35:06 PM class com.jme3.app.AppTask invoke()

SEVERE: Exception


at com.jme3.scene.BatchNode.mergeGeometries(BatchNode.java:495)

at com.jme3.scene.BatchNode.doBatch(BatchNode.java:202)

at com.jme3.scene.BatchNode.batch(BatchNode.java:175)[/java]

Well your geom is obviously null (open up BatchNode and look at line 495).

Step through the debugger where you load your stuff and see what is going on, and why it is null.