Пример #1
0
def _set_camera_rotation(pgroup_id, cam_id, rx_samples, ry_samples, rz_samples,
                         file_start_frame, file_end_frame, chosen_start_frame,
                         chosen_end_frame):
    """
    Set the camera rotation values on the given 3DE camera ids.

    :param pgroup_id: The Point Group ID with the active camera in it.
    :type pgroup_id: str

    :param cam_id: The Camera ID to apply data to.
    :type cam_id: str

    :param rx_samples: Frame/value pairs for Rotate X, representing
                       a curve of values.
    :type rx_samples: [(int, float), ..]

    :param ry_samples: Frame/value pairs for Rotate Y, representing
                       a curve of values.
    :type ry_samples: [(int, float), ..]

    :param rz_samples: Frame/value pairs for Rotate Z, representing
                       a curve of values.
    :type rz_samples: [(int, float), ..]

    :param file_start_frame: The start frame available from the parsed file.
    :type file_start_frame: int

    :param file_end_frame: The end frame available from the parsed file.
    :type file_end_frame: int

    :param chosen_start_frame: The start frame that the user wants to limit to.
    :type chosen_start_frame: int

    :param chosen_end_frame: The end frame that the user wants to limit to.
    :type chosen_end_frame: int

    :returns: Were the rotation values changed?
    :rtype: bool
    """
    values_were_set = False
    assert isinstance(file_start_frame, (int, long))
    assert isinstance(file_end_frame, (int, long))
    assert isinstance(chosen_start_frame, (int, long))
    assert isinstance(chosen_end_frame, (int, long))
    assert rx_samples
    assert ry_samples
    assert rz_samples

    samples_list = (rx_samples, ry_samples, rz_samples)
    frames = _get_frame_list_to_set_values(cam_id, samples_list,
                                           file_start_frame, file_end_frame,
                                           chosen_start_frame,
                                           chosen_end_frame)

    rotate_data = dict()
    for component_index, samples in [(0, rx_samples), (1, ry_samples),
                                     (2, rz_samples)]:
        for frame, value in samples:
            frame = int(frame)
            if frame not in rotate_data:
                rotate_data[frame] = [None, None, None]
            rotate_data[frame][component_index] = (value * PI) / 180.0

    for global_frame in frames:
        rot_value = rotate_data.get(global_frame)
        if rot_value is None:
            continue
        rot_x, rot_y, rot_z = rot_value
        r3d = vl_sdv.rot3d(rot_x, rot_y, rot_z, vl_sdv.VL_APPLY_ZXY)
        r3d = vl_sdv.mat3d(r3d)
        r3d0 = [[r3d[0][0], r3d[0][1], r3d[0][2]],
                [r3d[1][0], r3d[1][1], r3d[1][2]],
                [r3d[2][0], r3d[2][1], r3d[2][2]]]
        # Internally, 3DE always starts at frame 1.
        raw_frame = 1 + (global_frame - file_start_frame)
        tde4.setPGroupRotation3D(pgroup_id, cam_id, raw_frame, r3d0)
        values_were_set = True
    return values_were_set
Пример #2
0
def convertToAngles(r3d):
    rot = vl_sdv.rot3d(vl_sdv.mat3d(r3d)).angles(vl_sdv.VL_APPLY_ZXY)
    rx = (rot[0] * 180.0) / 3.141592654
    ry = (rot[1] * 180.0) / 3.141592654
    rz = (rot[2] * 180.0) / 3.141592654
    return (rx, ry, rz)