Spatial.getLocalTranslation() always returns 0,0,0

Hi! I’m not sure what’s up with this, so I’m hoping someone has an idea. I’m loading in a simple cube model from blender with the following standard code:

[java]
Texture grass = assetManager.loadTexture(“Textures/Grass.png”);
Spatial block = assetManager.loadModel(“Models/Grass Block.j3o”);
Material m_block = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
m_block.setTexture(“DiffuseMap”, grass);
block.setMaterial(m_block);
block.setLocalTranslation(0, -1, 0);
rootNode.attachChild(block);
[/java]

I can set the LocalTranslation when I create it and it positions where I want just fine, however, whenever I cast a ray to get the LocalTranslation, it is always returned at 0,0,0 no matter where it’s initially placed in the scene. Even when I create a second cube and place it next to the first one, it’s coordinates are still returned at 0,0,0 when it is visibly not.

Any thoughts? Could there be something I need to do to my cube mesh in Blender?

Thanks!

Also, this only happens when I cast a ray at the cube and get the results with:
[java]resultsNegZ.getCollision(i).getGeometry().getLocalTranslation()[/java]

Does getGeometry() not work on spatials?

In short: Try getWorldTranslation()

If a Node (a parent of other nodes, geometries) is translated, the children’s locations in relation to the node’s location do not change.

You should read this: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

Thanks for the pointer. It’s all good now. It was a parent / child thing. :slight_smile: