# Spatials attached to a node does not change location when the node does

So I read the scene graph for dummies and found that spatials attached to nodes move relative to the node so when the node changes location, its children should do so too. Now, I have three models (as spatials) attached to a node. When i change the direction or rotation of the node, nothing happens to the spatials but when I change them individually, it affects them. Any suggestions to why it is behaving like this?

So I have a piece of string in my hand, any suggestions on how long it is?

Given the information provided, I can only say one thing with 100% certaintyâ€¦

Based on this:

This is false:

Guaranteed.

``````    pathway = new Node("Path");

leftWallModel.setLocalScale(new Vector3f(2f, 10f, 20f));
leftWallModel.setLocalTranslation(-50f, -5f, -20f);

rightWallModel.setLocalScale(new Vector3f(2f, 10f, 20f));
rightWallModel.setLocalTranslation(-10f, -5f, -20f);

floorModel.setLocalScale(new Vector3f(20f, 40.1f, 1f));
floorModel.setLocalRotation(new Quaternion(-1f, 0f, 0f, 1f));
floorModel.setLocalTranslation(-30f, -15f, -20f);

pathway.attachChild(floorModel);
pathway.attachChild(rightWallModel);
pathway.attachChild(leftWallModel);
pathway.setLocalTranslation(0f, 10f, 0f);

rootNode.attachChild(pathway);``````

Where is the problem?

So when i set the local translation of the node, the spatials attached to it does not move relative to it. They all remain in their positions

The childs did move but not themselfes. The parent (here the pathway node) has moved 10 units on the y-axis. And with that the childs have â€śmovedâ€ť also relative to it!

Make screenshots, one time with
`pathway.setLocalTranslation(0f, 10f, 0f);`
and another time without. You will see a difference!

By the way you never should set a rotation like this:

Read the following for better understanding:
https://jmonkeyengine.github.io/wiki/tutorials/math/assets/fallback/index.html

It does not change. I put this statement after setting the local translation of the pathway node: `System.out.println(floorModel.getLocalTranslation());` But the translation of the floor model stayed at where it was before

Yes, thatâ€™s an intended behaviour! The LOCAL translation of the floorModel does not change when the parent moves! The thing what is changed is the WORLD translation! When you print out the world translation before and after you will see a difference!

What is the difference between World and Local coordinates?
World coordinates of a Spatial are its absolute coordinates in the 3D scene (this is like giving GPS coordinates). Local coordinates are relative to the Spatialâ€™s parent Spatial (this is like saying, â€śIâ€™m ten meters left of the entrance). - from jME Wiki

Domenicâ€™s right.
Use System.out.println(floorModel.getWorldTranslation() ); before and after.
You will see the difference.
A spatialâ€™s world translation is its distance from the worldâ€™s origin point/center O(0,0,0).
A spatialâ€™s local translation is its distance from the parent node that itâ€™s attached to.
So if you have moved the parent node,the childâ€™s distance from its parent remains the same locally.
From the wiki:
â€śWorld coordinates of a Spatial are its absolute coordinates in the 3D scene (this is like giving GPS coordinates). Local coordinates are relative to the Spatialâ€™s parent Spatial (this is like saying, â€śIâ€™m ten meters left of the entrance).â€ť

1 Like

So I want to move three models by moving its parent node which is the pathway node in this case. But i don't see any change graphically, the three models stay in their same place. You are right that the world translation changes but how can i combine all three of them in one node and change all their positions by changing its parent node's position?

You can do that by changing the local translation of the pathway node!

I do that, as you can see from the above code I posted. But i do not see any graphical difference in the position of the three models. Their world translation changes but no difference if i look through the fly camera.

Try setting the offset to something large. Depending on how things are scaled and how they are positioned relative to other scene objects, it may be difficult to tell the difference. If you print out the world position and it is as expected (no mistakes in parenting/positioning), then that is truly where the objects are. If they donâ€™t look right then itâ€™s an optical illusion, camera positioning mistake, or something else throwing your view off.

1 Like

You can also try to add a reference box directly attached to the rootNode to (0,0,0). This way youâ€™ll see that the other objets are in different places if their worldtranslation says so. (be sure that the box World translation is always 0,0,0)

Ok so when i try moving the node without any physics control, everything moves fine. But as soon as I add rigid body controls to the models attached to the node, the models stops moving whenever i change the position of the node. Any ideas why?

1 Like

Thatâ€™s what non-kinematic rigid body controls do. They control the position and motion of the controlled spatial.

Ok thanks everyone, am just gonna attach them to a node and iterate through them to change their physical location to move them all at once

Show the code you use to move the node and the settings for the controls.