Exemplo n.º 1
0
            def transform_matrix(self, matrix):
                # Blender is Z up but Mitsuba is Y up, convert the matrix
                global_matrix = axis_conversion(to_forward="-Z",
                                                to_up="Y").to_4x4()
                l = matrix_to_list(global_matrix * matrix)
                mat = Matrix4x4(l)
                transform = Transform(mat)

                return transform
Exemplo n.º 2
0
def convert_meshlab2mitsuba_camera(camera_def: dict) -> Transform:
    """
    Takes a meshlab camera dict (usually loaded from a meshlab xml file) and turns it into a valid mitsuba Transform
    which can then be applied to a sensor
    :param camera_def: The camera def dict, containing at least keys RotationMatrix and TranslationVector
    :return: A mitsuba transform constructed from the given values
    """
    # Meshlab camera matrix is transposed
    matrix = Matrix4x4([
        float(elem) for elem in camera_def['RotationMatrix'].split(' ')[:16]
    ]).transpose()

    # Add translation vector
    translation = [
        -float(elem) for elem in camera_def['TranslationVector'].split(' ')
    ]
    for i in range(3):
        matrix[i, 3] = translation[i]

    # Make Mitsuba transform and flip rotation signs (y is not flipped, otherwise resulting image will be flipped vertically)
    transform = Transform(matrix)
    transform *= transform.scale(Vector3(-1, 1, -1))

    return transform
Exemplo n.º 3
0
 def __get_glob_transform(self):
     glob_transform = Transform(
         Matrix4x4(self.global_transform.ravel(order="C").tolist()))
     return glob_transform
Exemplo n.º 4
0
 def __get_view_transform(self, active_view):
     transform = np.eye(4)
     transform[0:3, :] = active_view.transform.reshape((3, 4), order="F")
     view_transform = Transform(
         Matrix4x4(transform.ravel(order="C").tolist()))
     return view_transform