Camera setup for parallel projection

I am lost on how to setup a camera in parallel projection. I tired to look up in the jme sources how the gui camera is setup and found:

        Camera guiCam = new Camera(settings.getWidth(), settings.getHeight());
        guiViewPort = renderManager.createPostView("Gui Default", guiCam);

I cannot see where the rendering area is defined. display width and height for the gui camera.

What i need is to create a camera for rendering the directional light shadows. Placing the camera in the right spot is not a big issue. but i don’t know how to setup the “box frustum”

Generally, you should create new cameras by cloning existing ones instead of new Camera.

Since the GUI camera is set up with parallel projection, you could clone that. Or if that is inconvenient for you, clone the main camera and then apply setParallelProjection(true).

The camera itself works as expected, but i don’t know how to set the viewing area. like i would do with fov + aspect in a perspective projection

left, right, top, bottom just like for a perspective frustum. They just mean a bit different things for orthogonal cameras.

Edit: for example, when I wanted to setup a camera to take orthogonal images for some atlas sprites, I took the regular perspective app camera and did this to it:

            cam.setParallelProjection(true);
            cam.setRotation(new Quaternion().fromAngles(0, FastMath.PI, 0));
            cam.setLocation(new Vector3f(3.4065404f, 3.0012016f, 10.0f));

            float frustumScale = 9;
            cam.setFrustumLeft(cam.getFrustumLeft() * frustumScale);
            cam.setFrustumRight(cam.getFrustumRight() * frustumScale);
            cam.setFrustumTop(cam.getFrustumTop() * frustumScale);
            cam.setFrustumBottom(cam.getFrustumBottom() * frustumScale);
1 Like

Ok, still have to figure out how to exactly position the camera but it seems to work.

Somehow i spend hours looking at various places how to setup the camera and have not found .setFrustum
Still don’t find how the gui viewport camera is setup.
Thank you both

Note that the gui viewport may be weird because Bucket.Gui has special code in the engine that overrides a whole mess of stuff. It’s quite possible that the gui viewport doesn’t even use a special camera.