Hi, i am new to JMonkey and I am currently in the process of creating a two player boxing game. Each boxer requires for there to be a camera behind him so I am trying to create two cameras for split screen.
The current code I have has the problem of only showing one view of the camera, the second camera. When I turn off the second camera then the first one begins to work.
I have looked at 3 other forum posts here about split screen. Even though they did help me to advance I have become stuck at this one point.
Heres my current code:
// Get the display dimensions
DisplaySystem display = DisplaySystem.getDisplaySystem();
int width = display.getWidth();
int height = display.getHeight();
/* CAMERA 1
*/
// Set up the camera to match the display dimensions and set up the view frustum the camera can see
myCamera1 = display.getRenderer().createCamera(width, height);
myCamera1.setFrustumPerspective(45.0f, (float)width / (float)height, 1, 1000);
myCamera1.setViewPortRight(0.5f);
myCamera1.setViewPortLeft(0);
// Place the camera in its position
myCamera1.setLocation(new Vector3f(8, 5, 8));
// Tell the camera what it should be looking at and which way is up
myCamera1.lookAt(boxer1.getLocalTranslation(), new Vector3f(0, 1, 0));
/* CAMERA 2
*/
// Set up the camera to match the display dimensions and set up the view frustum the camera can see
myCamera2 = display.getRenderer().createCamera(width, height);
myCamera2.setFrustumPerspective(45.0f, (float)width / (float)height, 1, 1000);
myCamera2.setViewPortRight(1);
myCamera2.setViewPortLeft(0.5f);
// Place the camera in its position
myCamera2.setLocation(new Vector3f(-8, 5, -8));
// Tell the camera what it should be looking at and which way is up
myCamera2.lookAt(boxer2.getLocalTranslation(), new Vector3f(0, 1, 0));
/* DISPLAY CAMERAS
*/
display.getRenderer().clearBuffers();
GameTaskQueueManager.getManager().getQueue(GameTaskQueue.RENDER).execute();
myCamera1.update();
// Display the camera view on the screen
display.getRenderer().setCamera(myCamera1);
myCamera2.update();
// Display the camera view on the screen
display.getRenderer().setCamera(myCamera2);
display.getRenderer().flush();
I think the problem is in the last part of DISPLAY CAMERAS.
If anyone could point out my error or if someone could post an example of split screen camera I would be very grateful.