Geometry Translation

I’m trying to realize a Geometry translation through onTouch event using getX() and getY() in this way:

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

float x = evt.getX();

float y = evt.getY();

Vector2f position = new Vector2f();



Vector3f worldPosition = cam.getWorldCoordinates(position, 0.0f);


case MOVE:








where geom is a Geometry object. When I touch a point on the screen the translation doesn’t happen

in this position but in another.I don’t understand the error, can someone help me?

Thank you very much

y inversion?

I don’t know it, is it a problem or a bug? Is my code correct or wrong?

Thanks a lot

:roll: invert the y-axis

Thanks for help, but I don’t solved my problem. If I put the Geometry in the origin coordinates, this is the start position, all works , the Geometry translates in the new position. After I move it again but the translastion doesn’t happen in the correct position.It seems that works only If the Geometry has its start position in the origin of the world.

Well, if I’m not mistaken, the move(Vector3f) method moves your geometry by the given vector relative to the current location.

I think you want setLocalTranslation(Vector3f).

1 Like

Yes it’s right, with setLocalTranslation the result is correct, but I don’t understand why move works as I aspect in desktop application, while not in android application using getWorldCoordinates(). I’m working to understand the difference.

Thank you for your response

Ok I solved my problem:

Vector3f current = geom.getWorldBound().getCenter();



and geom follow my finger movement