Example #1
0
    def _ingest_check_capture(self, force=False):
        """Make sure this file has a corresponding psyop capture.

        Args:
            force (bool): lose unsaved changes without confirmation
        """
        _work = self.to_psy_work()

        # Build capture
        if not self.has_capture():

            print 'CAPTURING', _work.path
            _work.load(lazy=True)

            _cam = self.scene_get_cam()
            print ' - CAM', _cam
            assert _cam

            cmds.modelPanel(
                ui.get_active_model_panel(), edit=True, camera=_cam)

            tk2.capture_scene(force=True)

        # Submit version
        assert self.has_capture()
        _cap = _work.find_output_file(
            output_type='capture', extension='jpg', format_='jpg')
        if (
                not self.has_capture_sg_version() and
                not _cap.cache_read('submitted transgen')):
            _cap.submit_sg_version()
            assert _cap.cache_read('submitted transgen')
Example #2
0
def _apply_kealeye_rig_mapping():
    """Apply rig mapping from Sean Kealeye MocapTools.

    This brings in the HSL rig, binds it to the MotionBurner skeleton,
    then bakes the anim. The MotionBurner rig is left in the scene
    for comparison but it is placed in a group and hidden.
    """
    print 'APPLY KEALEYE RIG MAP'
    assert cmds.ogs(query=True, pause=True)
    fr_tools.install_mocap_tools()
    from MocapTools.Scripts import PsyopMocapTools

    # Apply kealeye bake
    print 'BAKING CONTROL RIG SCENE'
    PsyopMocapTools.mocapSetupTools().bakeControlRigScene(incFace=True)

    # Clean up scene
    cmds.currentTime(1)  # Update anim
    cmds.select([
        _node for _node in cmds.ls('SK_Tier1_Male_CR:*', long=True, dag=True)
        if _node.count('|') == 1
    ])
    _grp = cmds.group(name='CaptureRig_GRP')
    cmds.setAttr(_grp + '.visibility', False)
    _editor = ui.get_active_model_panel()
    cmds.modelEditor(_editor, edit=True, nurbsCurves=True)
Example #3
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())
Example #4
0
def get_active_cam():
    """Get camera from the curret active viewport.

    Returns:
        (HFnCamera): active camera
    """
    _model = ui.get_active_model_panel()
    _cam_node = cmds.modelPanel(_model, query=True, camera=True)
    if cmds.objectType(_cam_node) == 'camera':
        _cam = HFnCamera(get_parent(_cam_node))
    else:
        _cam = HFnCamera(_cam_node)
    return _cam
Example #5
0
def _build_face_blast_cam():
    """Build face blast camera.

    Returns:
        (HFnCamera): face blast cam
    """
    _cam = hom.CMDS.camera(name='FACE_CAM')
    _panel = ui.get_active_model_panel()
    cmds.modelPanel(_panel, edit=True, camera=_cam)
    cmds.parent(_cam, 'SK_Tier1_Male:Head_M', relative=False)
    cmds.setAttr(_cam + '.translate', -2.9, 54.3, 0.0)
    cmds.setAttr(_cam + '.rotate', -56, -90, -25)

    _cam = _cam.rename('FACE_CAM')

    return _cam
Example #6
0
def _blast_work(work,
                seq=None,
                build_cam_func=None,
                view=False,
                force=False,
                blast_=True,
                verbose=0):
    """Blast the given work file.

    Args:
        work (FrasierWork): work file to blast
        seq (TTOutputFileSeq): output image sequence
        build_cam_func (fn): function to build blast cam
        view (bool): view images on blast
        force (bool): force overwrite existing images
        blast_ (bool): execute blast
        verbose (int): print process data
    """
    _seq = seq or work.blast

    if cmds.ogs(query=True, pause=True):
        cmds.ogs(pause=True)
    assert not cmds.ogs(query=True, pause=True)

    print 'BLAST', _seq
    print ' - FRAMES', _seq.find_range()
    if not force and _seq.exists(verbose=1):
        print ' - ALREADY EXISTS'
        return

    if not host.cur_scene() == work.path:
        cmds.file(work.path, open=True, prompt=False, force=force)

    _build_cam_func = build_cam_func or _build_blast_cam
    _cam = _build_cam_func()
    print ' - CAM', _cam, type(_cam)

    # Look through cam
    _panel = ui.get_active_model_panel()
    _editor = ui.get_active_model_panel(as_editor=True)
    cmds.modelPanel(_panel, edit=True, camera=_cam)
    cmds.refresh()
    _cur_cam = cmds.modelPanel(_panel, query=True, camera=True)
    print ' - CUR CAM', _cur_cam
    assert _cur_cam == _cam

    # Apply blast settings
    cmds.modelEditor(_editor,
                     edit=True,
                     grid=False,
                     locators=False,
                     cameras=False,
                     nurbsCurves=False,
                     dimensions=False,
                     joints=False)
    cmds.camera(_cam,
                edit=True,
                displayFilmGate=False,
                displayResolution=False,
                overscan=1)
    pm.PyNode("hardwareRenderingGlobals").multiSampleEnable.set(True)
    cmds.setAttr(_cam.shp + '.nearClipPlane', 0.5)

    # Execute blast
    if not blast_:
        return
    blast(seq=_seq, res=(1280, 720), verbose=verbose)
    if view:
        _seq.view()
    print ' - BLASTED', _seq
Example #7
0
def blast(seq,
          range_=None,
          res=None,
          force=False,
          cam=None,
          view=False,
          verbose=0):
    """Execute a playblast.

    Args:
        seq (Seq): output sequence
        range_ (tuple): start/end frame
        res (tuple): override image resolution
        force (bool): overwrite existing images without confirmation
        cam (str): override camera
        view (bool): view blast on complete
        verbose (int): print process data
    """
    from psyhive import host
    from maya_psyhive import ui

    # Get res
    if res:
        _width, _height = res
        cmds.setAttr('defaultResolution.width', _width)
        cmds.setAttr('defaultResolution.height', _height)
    else:
        _width = cmds.getAttr('defaultResolution.width')
        _height = cmds.getAttr('defaultResolution.height')
    lprint('RES', _width, _height, verbose=verbose)

    # Get range
    _rng = range_ or host.t_range()
    _start, _end = _rng

    if cam:
        _panel = ui.get_active_model_panel()
        cmds.modelEditor(_panel, edit=True, camera=cam)

    seq.delete(wording='Replace', force=force)
    seq.test_dir()

    # Set image format
    _fmt_mgr = createImageFormats.ImageFormats()
    _fmt_mgr.pushRenderGlobalsForDesc({
        'jpg': "JPEG",
        'exr': "EXR",
    }[seq.extn])

    _filename = '{}/{}'.format(seq.dir, seq.basename)
    lprint('BLAST FILENAME', _filename, verbose=verbose)
    cmds.playblast(startTime=_start,
                   endTime=_end,
                   format='image',
                   filename=_filename,
                   viewer=False,
                   width=_width,
                   height=_height,
                   offScreen=True,
                   percent=100)
    assert seq.get_frames(force=True)

    _fmt_mgr.popRenderGlobals()

    if view:
        seq.view()