If I drag the mouse, MouseInput.get().getXAbsolute() returns the right value.
If I slowly click, it works
As soon I click faster, it doesn't work anymore.
MouseInput.get().getXAbsolute() and MouseInput.get().getYAbsolute() always return the center position?! 550px 300px --> 275.0 150.0
Whats the problem??
public void performAction(InputActionEvent evt) {
triggerTime += evt.getTime();
PickResults results = new TrianglePickResults();
if (MouseInput.get().isButtonDown(0) && triggerTime > 0.1f) {
Vector2f screenPos = new Vector2f();
triggerTime = 0;
// Get the position that the mouse is pointing to
screenPos.set(MouseInput.get().getXAbsolute(), game.getCanvas().getHeight() - MouseInput.get().getYAbsolute());
System.out.println(screenPos.x + " " + screenPos.y);
// Get the world location of that X,Y value
Vector3f worldCoords = display.getWorldCoordinates(screenPos, 1.0f);
// Create a ray starting from the camera, and going in the direction
// of the mouse's location
Ray mouseRay = new Ray(camera.getLocation(), worldCoords.subtractLocal(camera.getLocation()));
mouseRay.getDirection().normalizeLocal();
//PickResults results = new BoundingPickResults();
results = new TrianglePickResults();
results.setCheckDistance(true);
scene.findPick(mouseRay,results);
if(results.getNumber() > 0) {
System.out.println(results.getNumber());
for(int i = 0; i < results.getNumber(); i++) {
//System.out.println(results.getPickData(i).getTargetTris()..getTargetMesh().getName() + " " + results.getPickData(i).getDistance());
System.out.println(results.getPickData(i).getTargetMesh().getName() + " " + results.getPickData(i).getDistance());
}
}
}
results.clear();
}