Multiple Cameras with Multiple Perspectives

Hello,

I have been trying to establish the use of multiple cameras in my JME3 application, the rub however, is that each extra camera has a different resolution/aspect ratio and fov degree. What I am doing is at an instant in time(key-press) all camera images are rendered offscreen(Using the RenderToMemoryTest as basis) and displayed in JFrame. Unfortunately it would seem that any camera that is not close to the startup size of JME3 application will render incorrectly, by means of splicing the image in half vertically and rendering that one half twice and adding in segmented empty space as vertical bars.

My understanding is that since the same RenderManager is used for all the viewports of each camera, then the same renderer is being used. Namely the renderer that is sized for the jme3 application. My first thought was maybe seeing if it would be possible to resize the renderer for the instant i need it, but I have not been able to find how to do it. My second thought was to create independent renderers/render-managers for each camera-viewport though in these threads I have read that that would be a very bad thing to do.

Any ideas?

Thank you for your time

I have not, myself, had any trouble rendering different resolution textures with different cameras using different fov settings using the same renderer.

For the camera you just use the resize method to set the resolution and create a new FrameBuffer and Texture of the same resolution. When you render that camera you use the RenderManager’s setCamera method which will setup the proper transform matrices and then use the Renderer’s setFrameBuffer method to set which FrameBuffer to render to.

Use that to render geometries manually otherwise you can create a ViewPort, attach your camera and FrameBuffer to it and use the RenderManager’s renderViewPort or renderViewPortRaw methods.

https://javadoc.jmonkeyengine.org/com/jme3/renderer/RenderManager.html

I do recall having a problem at one point with one of my projects where the camera’s transform was not working, moving the camera had no effect. Using the RenderManager’s setUsingShaders(true) solved that issue.

1 Like

Tryder,

You are exactly right. I somehow overlooked resizing the camera when focused on trying to get the buffers the right size.

Thank you so much for the help, I will go sit in my dunce corner now.