I’m trying to use lemur to pick a specified square on a board that is divided into squares:
CursorEventControl.addListenersToSpatial(board, new CursorListener() {
@Override
public void cursorButtonEvent(CursorButtonEvent event, Spatial target, Spatial capture) {
if (boardClickListener != null && event.getCollision() != null) {
Vector3f point = event.getCollision().getContactPoint();
board.getWorldTransform().transformVector(point, working);
boardClickListener.accept(event, (int)working.x, (int)working.y);
}
}
I’m using a CursorEventControl
rather than a MouseEventControl
to get the collision data so I can read the collision point where the mouse click ray hits the board.
Unfortunately though event.getCollision()
is always null. I even dug into the code and so far as I can see it always will be:
event1 = new CursorButtonEvent(buttonIndex, pressed, findViewPort(hitTarget), hitTarget, x, y, null);
Am I trying to use this wrong or have I missed a step somewhere?
Thanks,
Tim