Hi,
I'm currently working on a 3D-Shoppingcenter game in JME. I have a JMECanvas integrated in a Swing application. I noticed that when I resize the application window (and with that also the JMECanvas of course), that the camera settings are completely wrong after that. With wrong camera settings I mean that when I try to pick my products out of the shelves in my shoppingcenter game it always takes the wrong ones. For picking the products out of the shelves I use a class NormalKeyboardHandler that extends InputHandler where I initialize an object KeySelectAction (extends InputActionInterface) with the current camera object. In the latter class I have the following method for picking the products:
public void performAction(InputActionEvent evt) {
Ray selectRay = new Ray(cam.getLocation(), cam.getDirection());
pr.clear();
rootNode.findPick(selectRay, pr);
if(pr.getNumber() > 1 && pr.getPickData(1).getDistance() < productPickDistance){
ProductModelNode node = getModelNode(pr.getPickData(1).getTargetMesh().getParentGeom());
if(node != null)
selectAction.performAction(node);
}
}
In RenParticelEditor I have seen that the author always reinizializes the frustum when the canvas is getting resized:
protected void doResize() {
if (impl != null) {
impl.resizeCanvas(glCanvas.getWidth(), glCanvas.getHeight());
if (impl.getCamera() != null) {
Callable<?> exe = new Callable() {
public Object call() {
impl.getCamera().setFrustumPerspective(
45.0f,
(float) glCanvas.getWidth()
/ (float) glCanvas.getHeight(), 1,
10000);
return null;
}
};
GameTaskQueueManager.getManager()
.getQueue(GameTaskQueue.RENDER).enqueue(exe);
}
}
}
Do I need to do something like that also for the camera so that afterwards after a canvas resize I'll still be able to pick the right products?
Any help would be much appreciated.
Thanks,
Michael