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。
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.