Newbie questing - but just wondering

Hi



I’ve been using JME3 quite a bit, and never really had any problems it. Been reading the “…for dummies” and such. And your Spatials/Node/Geometry also seems quite easy to understand. But Somehow, I really don’t understand when to use what. I normally use Spatials and Nodes with no problems. But I can see i ought to use Geometries.



Then I decided to check out your test tutorials. And that didnt help, because you dont “show the way”. Meaning; here are 3 lines from 3 different examples:



Node tank = (Node) assetManager.loadModel(“Models/HoverTank/Tank2.mesh.xml”);



Spatial bumpy = (Spatial) assetManager.loadModel(“Models/MonkeyHead/MonkeyHead.mesh.xml”);



Geometry teaGeom = (Geometry) assetManager.loadModel(“Models/Teapot/Teapot.obj”);



Any quick explanation? Òr simply say - read the “… for dummies” again, dummy :slight_smile:

Every of these is a Spatial. A Geometry is those you actually see, those with meshes. Nodes are those that have children. Open a model in the SDK and look at it in the SceneExplorer, that should make it clearer.

Yes, I know the spatial is abstract, and geom is the visual part, and and and… But why do you use 3 different approaches in your examples?

Well, if they only used one method you would be asking, “why do you only do it this way in the examples and never this other way?”

Remember that when a class extends another class, those two are equal except for any changes made to the subclass.

So Spatial == Node with a Child Spatial and no texture == Geometry with a Texture and no Child Spatial.

And since Node and Geometry are Spatials, Child Spatial can be either of these as well.

Spatial is separate from geometry because you don’t always want to put a texture on a mesh. And sometimes you want to treat many geometries/spatials like 1 geometry/spatial so you put them in a Node.



If you like thinking of things in terms of trees, the Node can be thought of as a…node, and the Spatial is a leaf-node. Except that sometimes we want textures on the Spatials so instead we use Geometry as the leaf-nodes.



We would use Spatials for everything, but we would be limited. Watch:



[java]Spatial thing = new loadMesh(“blah/blah.mesh.xml”);



//cool but i want to see it with a texture on it!

//so instead we use Geometry

Geometry thing2 = new loadMesh(“nameOfThing”, “blah/blah.mesh.xml”);

thing2.setMaterial(newMaterial);



//cool, but what if I want to assemble 30 different things and treat them like 1 thing!?!?!

//so we make the things

Geometry[] thirtyThings = getThirtyGeometries();

//and put them in a Node

Node oneBigThing = new Node()

oneBigThing.attachAll(thirtyThings) //I don’t think this method actually exists, but this is pseudocode



//cool! Now I can forget about the spatial and geometry objects and just use the Node object in exactly the same way![/java]



I hope this makes sense. That code is not legitimate, just to show the general idea.

1 Like

A j3o file can be any scene graph object, a Node or a Geometry. If you know that beforehand you can cast it that way and directly perform e.g. getChildren() or getMesh() which are only available on Node respectively Geometry.

1 Like

OK Thanks. Lets close it :slight_smile: