All scenes in Polycode are rendered via a Camera. Even in 2D. Each scene comes with its own default camera and is set to automatically render from it. Cameras are entities like any other and you can move and rotate them to change how a scene is rendered.

Contents

2D and 3D cameras.

Cameras can be set to be either perspective or orthographic. When you initialize a Scene with SCENE_2D or SCENE_2D_TOPLEFT, its default camera is set to an orthographic mode and in SCENE_3D the camera is set to perspective mode. You can change this mode at any time using the setProjectionMode method.

Orthographic modes and resolutions.

There are a number of orthographic modes that you can set a camera to and they all have to do with how the orthographic size of the camera relates to the resolution and aspect ratio of the screen. The orthographic size is essentially how many Polycode units the camera can see on the screen.

ORTHO_SIZE_MANUAL - Manual ortho size. Manually set the width and height of the rendered area using the setOrthoSize method. This will effectively stretch the render to fit whatever aspect ratio the viewport is set to.

ORTHO_SIZE_LOCK_HEIGHT - The ortho height is set by setOrthoSize and the width is adjusted based on the aspect ratio of the viewport. Use this mode when you want resolution independent 2D.

ORTHO_SIZE_LOCK_WIDTH - The ortho width is set by setOrthoSize and the height is adjusted based on the aspect ratio of the viewport. Use this mode when you want resolution independent 2D.

ORTHO_SIZE_VIEWPORT - The ortho size is set automatically based on the resolution of the viewport. Use this mode if you want your 2D scene to scale based on the resolution or you want pixel-perfect 2D rendering.

Perspective modes.

Perspective mode is set using PERSPECTIVE_FOV or PERSPECTIVE_FRUSTUM modes. Most of the time you will want PERSPECTIVE_FOV, which uses the camera's FOV setting (setFOV) method to set the perspective. PERSPECTIVE_FRUSTUM is set by calling setFrustumMode and passing it exact frustum planes.

Custom projection matrix.

If you're feeling particularly adventurous and feel the need to set the projection matrix of the camera manually, set the projection mode to MANUAL_MATRIX and use the setProjectionMatrix method to set the matrix.