Dynamic Split Screen

Hello guys,



I am trying to build a dynamic split screen where the user could put the mouse cursor on a location on the screen, press a button and voila, create another camera with the viewport set dividing the screen into two cams. Then if the user clicks again somewhere else, same thing (assuming only a vertical split for now).



I know that I can get the mouse position from the inputManager using getCursorPosition(). However, what I need is the position of the mouse relative to the viewport. In other words, the main screen has a viewport (0,1,0,1) by default. let’s say the user clicks in the middle of the screen. I want to create another camera with the viewport (0.5,1,0,1). The position gives me an actual vector2f position that is not consistent if the user changes the settings of the window.



Any ideas how I can translate the position of the mouse cursor into a number between 0 and 1? maybe is there a method that gives me the max x and max y of the screen so I can divide the current position by it?



thanks in advance

oh my bad … you can get the screen width using: getSettings().getWidth())



sorry I should have looked before posting



thanks

camera.getWidth and camera.getHeight

dont forget to adjust the camera frustrums as well, else you will get a kind of warped effect

1 Like

and can I change focus from one camera to another? i.e. one screen to another?





EDIT: say I have a quad of 4 screens, I am trying to switch (say using TAB) from one cam focus to another to be able to control the camera of that specific screen and move it around. Is that possible?

1 Like
@nightwolf911 said:
and can I change focus from one camera to another? i.e. one screen to another?


EDIT: say I have a quad of 4 screens, I am trying to switch (say using TAB) from one cam focus to another to be able to control the camera of that specific screen and move it around. Is that possible?

jME3 doesn't have a concept of "focus". Your app gets input and it can do whatever it wants with it. See TestMultiViews on how to do split screen.