Node collideWith return

Hi i try to make a ray that shoots to a Node,and then get what spatial has it hited,but all i see i get geom.
is there any way to get back a Node?

Node player;
player = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);

Or a better question ,do i really need to obtain a node?
what i want is to get that “player” object

it give me root node,but what i look for is player not Root Node
and i have to make it get geometry and then get parent.

If getParent() gives you the root node then the Geometry is a child of the root node. Unless you just kept calling it and calling it… then you have to wonder “How will I know if it’s the node I’m looking for?”

…which is a different question with many answers.

What makes your node special? Did you add user data to it? Did you add a control to it?

A simple way is to setUserData() on your node then when you hit a Geometry, check for that user data value, call getParent(), check that node for the user data value, etc…

I’m not sure if your reason is the same as mine, but I made a method similar to this code when I do ray collision since I need to check the parent node’s user data on geometries that are nested in different amounts of nodes.

Regardless, it could help you to add a System.out.println(item.getParent().getName()) into this loop and get rid of the extra conditions just to see how your geometry is nested in the case that .getParent() is returning the rootNode

private boolean traverseNodeHierarchyForUD(String userDataString, Node item){
        boolean found = false;
        while(item.getParent() != null && !found){
            String string = item.getUserData(userDataString);
            if(string != null){
                found = true;
            item = item.getParent();
      return found;

Men actually im as well pretty mutch confused on what player is ?
when we do
Node player
it make think it might become Node
but when we make
player =(Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);
and we cast assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);
it makes me think it might still be a node
but it acts totally different from a simple node… has material and all that stuf geometry has.
I never found explanation to that in tutorial soo WHAT player is now?what ogre that i see is now
and are they the same object?
I do player.getClass and it say its a node ,but what i see is still a node(ogreMesh)


thnx,but i have actually allready seen it,and got pretty clearly difference :slight_smile:
but what i cant get is
Node player;
player = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);

is equal to
Node player;
Geometry geometry
geometry = assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);

or what?
and how that happens? is ther any special method behinde the shene?who gives geom and node its name?

A node is a node. A geometry is a geometry. If you try to cast a geometry to a node you will get an exception. If you try to cast a node to a geometry you will get an exception. You can see from the javadoc that they are separate classes and cannot be cast to one another. This is basic java stuff… super beginner level.

Both are spatials. loadModel() loads either a node or a geometry depending on the file. If you try to cast it to the wrong thing then you will get a class cast exception (see above).

So if this succeeds without an exception:
player = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);

then oto is a node.

Basic java stuff, really.

well i never said i want to cast them to each other… :slight_smile:

ok cap… :smiley:

well i do not call into question this. :slight_smile:


i just say its really confusing to see
player = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);
and see happening every thing magically .
Models/Oto/Oto.mesh.xml its a premade node whith all the stuff ready and no explantions on dinamics of its creation.
Whats inside ? a geom ? and whats more? how has it been set? how to repeat it?We cant see it ,we can only guess and pray… not really best way
soo some nice comment here and there could really be of a help :slight_smile:

Use the SDK to look at it. Then you can see all of this stuff as it expands it in the scene tree where you can see all of the parts.

I thought this stuff was covered in the tutorials… but I don’t remember for sure and no one does them anyway, I guess.

The data structure rendered by the engine is a scene graph, that is, a tree of spatials. There are basically 2 kinds of spatials: (1) nodes (which are invisible but may reference child spatials) and (2) geometries (which are visible but never have children).

Oto is a model, a tree of spatials you can load from an asset and attach to the scene graph. The tree returned by loadModel() contains both nodes and geometries, but you reference it by means of the top node returned by loadModel(). If you load the same model twice, you effectively get two copies of the model, though I believe there’s some sharing of data.

Models are usually created using a tool like Blender, then converted to a more convenient format: the native J3O format. (Oto comes in Ogre XML format, so it’s not a good example of this.)

Err print it out and see what the console tells you? If it’s a node, then print out all its children and repeat until you find a geometry. I’ve had .scene files that layered a single geom inside like 4 nodes. Blender exported ogre xml files should nearly always be geometries inside one node however.

Thnx for answers :slight_smile: