Coordinate Transformation Problem

On the transformation of coordinate system:

sceneNode = (Node) mAssetManager.loadModel("scene name”);
rootNode.attachChild(sceneNode );

public void onTouch(String name, TouchEvent event, float tpf) {

Ray Pick
makeBox(ray contactpoint);
}

private void makeBox(Vector3f contactPoint) {
Box blueBox = new Box(1f, 1f, 1f);
Geometry blueGeometry = new Geometry(“BlueBox”, blueBox);
blueGeometry.setLocalTranslation(contactPoint);
Material materialBlue = new Material(mAssetManager, “Common/MatDef/Misc/Unshaded.j3md”);
materialBlue.setColor(“Color”, ColorRGBA.Blue);
blueGeometry.setMaterial(materialBlue);
//attach sceneNode, not rootNode
sceneNode.attachChild(blueGeometry);
}

The problem now is that the position of the touch screen point is inconsistent with that of the bluebox. How can I convert the coordinate system to keep the position consistent?

BlueBox must be attach to scenenode, not RootNode。

As to the other, you haven’t shown us what “contactPoint” is or where it comes from.

As written, you have basically said:
“I put my box at A but A is not what I expect.”

…and we don’t know anything about A.

Sorry, I may not have described it clearly

I’ll describe it again. Now there are two nodes, NodeA and NodeB,
rootNode.attachChild(NodeA);
NodeA.attachChild(NodeB);

How to calculate the coordinates of NODEA relative to the parent node?

I still don’t understand. Take a step back and tell us what you are actually trying to do… with the code that doesn’t work.

Because otherwise my answer is NODEA.getLocalTranslation() is the coordinates relative to its parent node. Which I suspect is not helpful.

You start with something and you want to end up with something. You’ve so far kind of almost described what you want to end up with… but are still avoiding explaining what you start with.