computeProjectionMatrix

fun computeProjectionMatrix(camera: PinholeCamera, width: Int, height: Int, nearPlane: Float, farPlane: Float, result: FloatArray)

Computes projection matrix using provided pinhole camera, viewport size expressed in pixels, near and far planes and field of view.

The viewport is the surface where the scene is rendered. OpenGL internally normalizes viewport coordinates from -1.0 to 1.0, but the hardware needs to know the actual size of the surface expressed in pixels.

Near and far planes define the region of the 3D space that is actually drawn. Any vertex being at a depth closer to the camera than the near plane, or any vertex being at a depth further from the camera than the far plane, is ignored and not drawn.

The field of view defines how wide is the region of the visible space. It is closely related to the focal length of the pinhole camera intrinsic parameters, and related to the amount of zoom of the scene.

Parameters

camera

pinhole camera.

width

width of viewport expressed in pixels.

height

height of viewport expressed in pixels.

nearPlane

near plane defining the closest visible vertices.

farPlane

far plane defining the furthest visible vertices.

result

16-length array that will store the resulting matrix.


fun computeProjectionMatrix(intrinsicParameters: PinholeCameraIntrinsicParameters, width: Int, height: Int, nearPlane: Float, farPlane: Float, result: FloatArray)

Computes projection matrix using provided intrinsic pinhole camera parameters, viewport size expressed in pixels, near and far planes and field of view.

The viewport is the surface where the scene is rendered. OpenGL internally normalizes viewport coordinates from -1.0 to 1.0, but the hardware needs to know the actual size of the surface expressed in pixels.

Near and far planes define the region of the 3D space that is actually drawn. Any vertex being at a depth closer to the camera than the near plane, or any vertex being at a depth further from the camera than the far plane, is ignored and not drawn.

The field of view defines how wide is the region of the visible space. It is closely related to the focal length of the pinhole camera intrinsic parameters, and related to the amount of zoom of the scene.

Parameters

intrinsicParameters

intrinsic pinhole camera parameters.

width

width of viewport expressed in pixels.

height

height of viewport expressed in pixels.

nearPlane

near plane defining the closest visible vertices.

farPlane

far plane defining the furthest visible vertices.

result

16-length array that will store the resulting matrix.