def get_camera_matrix(camera, global_matrix):
    """
    Get the camera transformation decomposed as origin, forward, up and target.
    """
    camera_mat = global_matrix * camera.matrix_world
    origin = camera_mat.col[3]
    forward = -camera_mat.col[2]
    up = camera_mat.col[1]
    target = origin + forward
    return origin, forward, up, target