Exemplo n.º 1
0
    def test_frustrum_test_blast(self):
        from maya_psyhive.tools.frustrum_test_blast import blast, remove_rigs

        set_dev_mode(False)

        # Test frustrum test
        _ref = ref.obtain_ref(namespace='archer_TMP',
                              file_=_RIG_PATH,
                              class_=blast._Rig)
        assert isinstance(_ref, blast._Rig)
        _cam = hom.HFnCamera('persp')
        _pos = hom.HMatrix([
            0.95, 0.00, 0.31, 0.00, 0.08, 0.96, -0.26, 0.00, -0.29, 0.27, 0.92,
            0.00, -19.37, 25.40, 54.23, 1.00
        ])
        _pos.apply_to(_cam)
        assert blast._rig_in_cam(rig=_ref, cam=_cam)
        _pos = hom.HMatrix([
            0.80, -0.00, -0.60, 0.00, -0.10, 0.98, -0.13, 0.00, 0.60, 0.16,
            0.79, 0.00, -16.33, 37.34, 109.80, 1.00
        ])
        _pos.apply_to(_cam)
        assert not blast._rig_in_cam(rig=_ref, cam=_cam)

        # Test remove rigs ui
        _dialog = remove_rigs.launch([_ref], exec_=False)
        _dialog.close()
Exemplo n.º 2
0
    def test_frustrum_test_blast(self):

        from maya_psyhive.tank_support.ts_frustrum_test_blast import (
            blast, remove_rigs)

        # Test frustrum test
        _ref = ref.obtain_ref(namespace='archer_TMP',
                              file_=_RIG_PATH,
                              class_=blast._BlastRigRef)
        assert isinstance(_ref, blast._BlastRigRef)
        _cam = hom.HFnCamera('persp')
        _pos = hom.HMatrix([
            0.95, 0.00, 0.31, 0.00, 0.08, 0.96, -0.26, 0.00, -0.29, 0.27, 0.92,
            0.00, -19.37, 25.40, 54.23, 1.00
        ])
        _pos.apply_to(_cam)
        assert blast._rig_in_cam(rig=_ref, cam=_cam)
        _pos = hom.HMatrix([
            0.80, -0.00, -0.60, 0.00, -0.10, 0.98, -0.13, 0.00, 0.60, 0.16,
            0.79, 0.00, -16.33, 37.34, 109.80, 1.00
        ])
        _pos.apply_to(_cam)
        assert not blast._rig_in_cam(rig=_ref, cam=_cam)

        # Test remove rigs ui
        _dialog = remove_rigs.launch([_ref], exec_=False)
        assert len(_dialog.ui.List.all_items()) == 1
        assert len(_dialog.ui.List.selectedItems()) == 1
        _dialog.close()
Exemplo n.º 3
0
def export_img_plane(camera, abc):
    """Export image plane preset data for the given camera/abc.

    Args:
        camera (str): camera shape node name
        abc (str): path to output abc
    """
    _cam = hom.HFnCamera(get_parent(str(camera)))
    lprint(' - CAM', _cam)

    # Read image plane
    _img_plane = get_single(_cam.shp.list_connections(type='imagePlane'),
                            catch=True)
    if not _img_plane:
        lprint(' - NO IMAGE PLANE FOUND')
        return
    _img_plane = hom.HFnTransform(_img_plane.split('->')[-1])

    # Export preset for each shape
    for _shp in [_cam.shp, _img_plane.shp]:
        _preset = '{}/{}.preset'.format(os.path.dirname(abc),
                                        _shp.object_type())
        lprint(' - SAVING', _preset)
        try:
            _shp.save_preset(_preset)
        except RuntimeError:
            lprint(' - FAILED TO SAVE')
Exemplo n.º 4
0
def _get_cam_focal():
    """Get cam focal hud text.

    Returns:
        (str): cam focal hud text
    """
    _model = ui.get_active_model_panel()
    _cam = hom.HFnCamera(cmds.modelPanel(_model, query=True, camera=True))
    return 'focal: {:.02f}'.format(_cam.shp.plug('focalLength').get_val())
Exemplo n.º 5
0
def restore_img_plane(time_control, abc):
    """Restore image plane from preset data.

    Args:
        time_control (str): exocortex time control name
        abc (str): path to output abc
    """
    from psyhive import tk

    # Ignore non camera caches
    _abc = tk.get_output(abc)
    print 'ABC', _abc.path
    if _abc.output_type != 'camcache':
        print 'NOT A CAMERA CACHE'
        return

    # Make sure there are presets to apply
    _presets = []
    for _type in ['imagePlane', 'camera']:
        _preset = '{}/{}.preset'.format(_abc.dir, _type)
        if not os.path.exists(_preset):
            print 'MISSING PRESET', _preset
            return
        _presets.append(_preset)

    # Find camera node
    _time_ctrl = hom.HFnDependencyNode(time_control)
    _cam_shp = get_single(_time_ctrl.find_downstream(type_='camera',
                                                     filter_=_abc.output_name),
                          catch=True)
    if not _cam_shp:
        print 'NO CAM FOUND'
        return
    _cam = hom.HFnCamera(get_parent(_cam_shp))

    # Create image plane and apply presets
    _img_plane = hom.CMDS.imagePlane(camera=_cam)
    for _preset, _shp in safe_zip(_presets, [_img_plane.shp, _cam.shp]):
        _shp.load_preset(_preset)