I am working on a program and trying to use model selection via mouse click and mouse picking to change the appearance of the models as the mouse moves over. I have a crosshairs to show the model to click on and I have flyCam enabled. Problem is that the mouse click works as expected but the mouse pick ‘spot’ does not coincide with the crosshairs, it is off to one side and a little up.
As an experiment to try to figure out what is going on, I started from TestMousePick, enabled flyCam and added a crosshairs. The arrows still appear as before but only when the models are shifted left and down into the corner.
Another test was to use the vanilla TestMousePick with flyCam enabled. Everything is shifted down and left.
How do I get everything to coincide?
Thanks,
Morris
When fly cam is enabled are you still using the mouse coordinates to do picking? I think it is better just to cast a ray from camera position in the look direction. The mouse coordinates may be strange in this case.
Thanks. That works a treat!
I changed
Vector3f origin = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);
Vector3f direction = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.3f);
direction.subtractLocal(origin).normalizeLocal();
Ray ray = new Ray(origin, direction);
to
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
Morris