Пример #1
0
def makeBluescreen(value, renderers):
    '''
    if value is absent, then we store the default background color into value, return it, and change
    the background to blue screen.
    if the value is valid, then we simply assign the value to the background
    '''
    if not value:
        # store the default value
        for color in pm.displayRGBColor(list=True):
            if color.startswith('backgroundTop'):
                value.update( {'backgroundTop':[float(c) for c in color.strip().split(' ')[1:]]} )
            if color.startswith('backgroundBottom'):
                value.update( {'backgroundBottom':[float(c) for c in color.strip().split(' ')[1:]]} )
        value.update( {'displayGradient':pm.displayPref(query=True, displayGradient=True)} )
        # set background
        pm.displayPref(displayGradient=True)
        if renderers=='vp2Renderer':
            pm.displayRGBColor('backgroundTop', 0, 0, 0)
            pm.displayRGBColor('backgroundBottom', 0, 0, 0)
        else:
            pm.displayRGBColor('backgroundTop', 0, 0, 1)
            pm.displayRGBColor('backgroundBottom', 0, 0, 1)
        return value
    else:
        pm.displayPref(displayGradient=value['displayGradient'])
        pm.displayRGBColor('backgroundTop', value['backgroundTop'][0], value['backgroundTop'][1], value['backgroundTop'][2])
        pm.displayRGBColor('backgroundBottom', value['backgroundBottom'][0], value['backgroundBottom'][1], value['backgroundBottom'][2])
Пример #2
0
def set_wireframe_mode(mode):
    """
    Select a viewport wireframe mode:

    "none": no wireframes
    "selected": wireframes on selected objects
    "all": wireframes on all objects
    """
    assert mode in ('none', 'selected', 'all'), mode

    if mode == 'none':
        pm.displayPref(wireframeOnShadedActive='none')
    else:
        pm.displayPref(wireframeOnShadedActive='full')
        for model_panel in pm.getPanel(type='modelPanel'):
            enabled = mode == 'all'
            pm.modelEditor(model_panel, e=True, wireframeOnShaded=enabled)
Пример #3
0
def get_wireframe_mode():
    if pm.displayPref(q=True, wireframeOnShadedActive=True) == 'none':
        return 'none'

    # Look at an arbitrary viewport for the wireframeOnShaded viewport mode.
    model_panels = pm.getPanel(type='modelPanel')
    if not model_panels:
        return 'none'
    if pm.modelEditor(model_panels[0], q=True, wireframeOnShaded=True):
        return 'all'
    else:
        return 'selected'
Пример #4
0
def manage_default_options(**kwargs):
    """
    Sets Various Default options for Maya

    viewmManip : Default Hide the manipulator Cube
    gradient: Default Hide the Background gradient
    autosave: Default Enable Autosave
    mentalray: Default Enable mr as Default Render Engine
    interactiveCreation: Enables Disables Interactive Creation Mode for Primitive Objects

    hardware2: Optional Enable Hardware Renderer 2.0 as Default Render Engine

    """

    # Disable View Cube
    pm.viewManip(visible=kwargs.get("viewManip", False))

    # Disable Background Gradient
    pm.displayPref(displayGradient=kwargs.get("gradient", False))

    # Infinite Undo
    pm.undoInfo(state=True, infinity=kwargs.get("infiniteUndo", True))

    # Enable Autosave, max Versions 10, interval 15min
    pm.autoSave(enable=kwargs.get("autosave", True), maxBackups=kwargs.get(
        "maxBackups", 10), interval=kwargs.get("interval", 900))

    # Activate Mental Ray
    if kwargs.get("mentalray", True):
        enable_mr_plugin()

    # Sets Hardwarerenderer 2.0 as Default
    if kwargs.get("hardware2", False):
        pm.PyNode("defaultRenderGlobals").currentRenderer.set("mayaHardware2")

    # Expose Mental Ray Production Nodes
    pm.optionVar["MIP_SHD_EXPOSE"] = 1

    # Disable Interactive Creation
    set_interactive_creation(kwargs.get("interactiveCreation", False))
Пример #5
0
 def toggleBackground(cls, *args, **kwargs):
   """ toggle maya's viewport background between solid color and gradient """
   if pm.displayPref(query=True, displayGradient=True):
     pm.displayPref(displayGradient=False)
   else:
     pm.displayPref(displayGradient=True)
Пример #6
0
def hideHighlightColor(*args):
	pm.displayPref(da = False)
Пример #7
0
def showHighlightColor(*args):
	pm.displayPref(da = True)
    def process(self, instance, context):
        self.log.info("Extracting capture..")

        camera = instance[0]

        current_min_time = cmds.playbackOptions(minTime=True, query=True)
        current_max_time = cmds.playbackOptions(maxTime=True, query=True)

        default_width = cmds.getAttr("defaultResolution.width")
        default_height = cmds.getAttr("defaultResolution.height")

        width = instance.data('width') or default_width
        height = instance.data('height') or default_height
        start_frame = instance.data('startFrame') or current_min_time
        end_frame = instance.data('endFrame') or current_max_time

        format = instance.data('format') or 'qt'
        compression = instance.data('compression') or 'h264'
        off_screen = instance.data('offScreen', False)
        maintain_aspect_ratio = instance.data('maintainAspectRatio', True)

        cam_opts = capture.CameraOptions()

        # Set viewport settings
        view_opts = capture.ViewportOptions()
        view_opts.displayAppearance = "smoothShaded"
        view_opts.dtx = True
        view_opts.grid = False

        # Set display settings

        display_options = capture.DisplayOptions()
        display_options.background = pm.displayRGBColor('background', q=True)
        display_options.backgroundTop = pm.displayRGBColor('backgroundTop', q=True)
        display_options.backgroundBottom = pm.displayRGBColor('backgroundBottom', q=True)
        display_options.displayGradient = pm.displayPref(dgr=True, q=True)


        if 'show' in instance.data():
            for nodetype in instance.data('show').split():
                self.log.info("Overriding show: %s" % nodetype)
                if hasattr(view_opts, nodetype):
                    setattr(view_opts, nodetype, True)
                else:
                    self.log.warning("Specified node-type in 'show' not "
                                     "recognised: %s" % nodetype)
        else:
            view_opts.polymeshes = True
            view_opts.nurbsSurfaces = True


        # Ensure name of camera is valid
        sourcePath = os.path.normpath(context.data('currentFile'))
        path, extension = os.path.splitext(sourcePath)


        if format == 'image':
            # Append sub-directory for image-sequence
            path = os.path.join(path, camera)
        else:
            path = (path + ".mov")

        self.log.info("Outputting to %s" % path)

        with maintained_time():
            output = capture.capture(
                camera=camera,
                width=width,
                height=height,
                filename=path,
                start_frame=start_frame,
                end_frame=end_frame,
                format=format,
                viewer=False,
                compression=compression,
                off_screen=off_screen,
                maintain_aspect_ratio=maintain_aspect_ratio,
                viewport_options=view_opts,
                camera_options=cam_opts,
                overwrite=True,
                quality=50,
                display_options=display_options,
                )


        components = instance.data('ftrackComponents')
        components['preview']['path'] = path

        instance.set_data("outputPath", output)