CameraToOpenGlHelper

Helper class to convert a pinhole camera into arrays used as matrices when drawing projective 3D scenes with OpenGL.

Typically, when using OpenGL, a projective matrix defines the projective geometry (i.e. frustum) of the scene, using parameters such as field of view, near and far planes. This kind of information is partially encoded in pinhole camera intrinsic parameters.

OpenGL typically also uses a model-view matrix, which defines the amount of translation and rotation between the camera and vertices to be drawn in the scene. This information is contained in a pinhole camera as its extrinsic parameters (i.e. rotation and camera center).

Finally, OpenGL uses the model-view projection matrix, which is the combination of both the projection and the model-view matrices to draw the scene.

Properties

Link copied to clipboard
const val MATRIX_LENGTH: Int = 16

Length of arrays used to store values of 4x4 homogeneous matrices.

Functions

Link copied to clipboard
fun centerFromCamera(camera: PinholeCamera): Point3D

Obtains the camera center for provided pinhole camera.

Link copied to clipboard
fun computeModelViewMatrix(camera: PinholeCamera, result: FloatArray)

Computes model-view matrix using provided pinhole camera.

fun computeModelViewMatrix(rotationMatrix: Matrix, cameraCenter: Point3D, result: FloatArray)
fun computeModelViewMatrix(cameraRotation: Rotation3D, cameraCenter: Point3D, result: FloatArray)

Computes model-view matrix using provided camera rotation and center.

Link copied to clipboard

Computes model-view matrix using provided pinhole camera.

fun computeModelViewMatrixAndReturnNew(rotationMatrix: Matrix, cameraCenter: Point3D): FloatArray
fun computeModelViewMatrixAndReturnNew(cameraRotation: Rotation3D, cameraCenter: Point3D): FloatArray

Computes model-view matrix using provided camera rotation and center.

Link copied to clipboard
fun computeModelViewProjectionMatrix(projectionMatrix: FloatArray, modelViewMatrix: FloatArray, result: FloatArray)

Computes model-view projection matrix using provided projection and model-view matrices.

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

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

fun computeModelViewProjectionMatrix(intrinsicParameters: PinholeCameraIntrinsicParameters, rotationMatrix: Matrix, cameraCenter: Point3D, width: Int, height: Int, nearPlane: Float, farPlane: Float, result: FloatArray)
fun computeModelViewProjectionMatrix(intrinsicParameters: PinholeCameraIntrinsicParameters, cameraRotation: Rotation3D, cameraCenter: Point3D, width: Int, height: Int, nearPlane: Float, farPlane: Float, result: FloatArray)

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

Computes model-view projection matrix using provided projection and model-view matrices.

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

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

fun computeModelViewProjectionMatrixAndReturnNew(intrinsicParameters: PinholeCameraIntrinsicParameters, rotationMatrix: Matrix, cameraCenter: Point3D, width: Int, height: Int, nearPlane: Float, farPlane: Float): FloatArray
fun computeModelViewProjectionMatrixAndReturnNew(intrinsicParameters: PinholeCameraIntrinsicParameters, cameraRotation: Rotation3D, cameraCenter: Point3D, width: Int, height: Int, nearPlane: Float, farPlane: Float): FloatArray

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

Link copied to clipboard
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.

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.

Link copied to clipboard
fun computeProjectionMatrixAndReturnNew(camera: PinholeCamera, width: Int, height: Int, nearPlane: Float, farPlane: Float): FloatArray

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

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

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

Link copied to clipboard
fun intrinsicParametersFromCamera(camera: PinholeCamera): PinholeCameraIntrinsicParameters

Obtains the intrinsic parameters contained within provided pinhole camera.

Link copied to clipboard
fun rotationFromCamera(camera: PinholeCamera): Rotation3D

Obtains the camera rotation for provided pinhole camera.