[SOLVED] Cloned Spatial local translation not translating into world translation

This still prints correct data. However adding a print into update loop showed, that world translation is still correct on the first frame and then changes to 0,0,0.

Can you post the code with your printlns in it?

I mean, if you want to prove to yourself that this normally works it would be pretty easy to create a single class test file that clones a few spatials and moves them around.

This

@Override
    public void simpleUpdate(float tpf) {
        light.setPosition(cam.getLocation());
        for (Spatial s : rootNode.getChildren()){
            System.out.println(s.getWorldTranslation());
        }
    }

Creates this output:

(0.0, 0.0, 0.0)
(0.0, 0.0, 16.0)
(0.0, 0.0, 32.0)
(16.0, 0.0, 0.0)
(16.0, 0.0, 16.0)
(16.0, 0.0, 32.0)
(32.0, 0.0, 0.0)
(32.0, 0.0, 16.0)
(32.0, 0.0, 32.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0,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 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
//And so on.

I could create a test case, but at the moment I donā€™t really have time. Reason: school.

Well, cloning is fundamental to JME as the asset manager clones everything when it loads it. So I guarantee that it is working properly and there is just some aspect of your code that we havenā€™t spotted.

When you get time to create the simpler test case, you should be able to track down what the issue is from there, I guess.

How were your parts created? Did you add physics controls to them externally?

If soā€¦ then itā€™s that setup that is wrong as the physics seems to be overriding the position you set. Physics objects have to be positioned in a different way.

Edit: as a test you could simply try not initializing the bullet state.

1 Like

That was it!!!
When I created straight.j3o I added a PhysicsControl to it into Scene Composer. Later on I deleted it, but the SDK is bugged and didnā€™t let me save. Now I just deleted the j3o and regenerated it form .blend.
Thanks for all the help.


To anyone having similar problems in future:
Disable physics first!

1 Like