Exemplo n.º 1
0
    def applyShader(cls, shaderConfig, transforms):
        shader, shaderEngine = cls.createShaderFromConfig(shaderConfig)

        priorSelection = MayaUtils.getSelectedTransforms()
        MayaUtils.setSelection(transforms)
        cmds.sets(forceElement=shaderEngine)
        MayaUtils.setSelection(priorSelection)
Exemplo n.º 2
0
    def createLayer(self, layer, useExisting =True):
        """ Creates a display layer with the specified name. """

        if useExisting and cmds.objExists(layer):
            return

        priorSelection = MayaUtils.getSelectedTransforms()
        cmds.select(clear=True)
        cmds.createDisplayLayer(name=layer)
        MayaUtils.setSelection(priorSelection)
Exemplo n.º 3
0
    def colorTrackNode(cls, node, props):
        # Save state of selected nodes to restore at end of this function
        priorSelection = MayaUtils.getSelectedTransforms()

        # Use red for left, green for right, in accordance with international
        # maritime convention
        left = props[TrackPropEnum.LEFT.name]
        pes  = props[TrackPropEnum.PES.name]

        if left:
            ShadingUtils.applyShader(TrackwayShaderConfig.RED_COLOR,   node)
        else:
            ShadingUtils.applyShader(TrackwayShaderConfig.GREEN_COLOR, node)

        # Next, get a shortcut to the components of the track node
        root = node + '|inverter'

        # Make the width and length rulers either light gray (for manus) or
        # dark gray (for pes) and the 'error bars' white.
        c = TrackwayShaderConfig.DARK_GRAY_COLOR if pes else \
            TrackwayShaderConfig.LIGHT_GRAY_COLOR

        ShadingUtils.applyShader(c, root + '|WidthRuler')
        ShadingUtils.applyShader(c, root + '|LengthRuler')

        ShadingUtils.applyShader(
            TrackwayShaderConfig.WHITE_COLOR, root + '|BarN')
        ShadingUtils.applyShader(
            TrackwayShaderConfig.WHITE_COLOR, root + '|BarS')
        ShadingUtils.applyShader(
            TrackwayShaderConfig.WHITE_COLOR, root + '|BarW')
        ShadingUtils.applyShader(
            TrackwayShaderConfig.WHITE_COLOR, root + '|BarE')

        # And finish up with other details
        ShadingUtils.applyShader(
            TrackwayShaderConfig.YELLOW_COLOR, root + '|ThetaPlus')
        ShadingUtils.applyShader(
            TrackwayShaderConfig.YELLOW_COLOR, root + '|ThetaMinus')

        MayaUtils.setSelection(priorSelection)
Exemplo n.º 4
0
    def initializeCadenceCam(self):
        """ This creates an orthographic camera that looks down the Y axis onto
            the XZ plane, and rotated so that the AI file track labels are
            legible.  This camera is positioned so that the given track nodeName
            is centered in its field by setCameraFocus. """

        if cmds.objExists(self.CADENCE_CAM):
            return

        priorSelection = MayaUtils.getSelectedTransforms()

        c = cmds.camera(
            orthographic=True,
            nearClipPlane=1,
            farClipPlane=100000,
            orthographicWidth=400)
        cmds.setAttr(c[0] + '.visibility', False)
        cmds.rename(c[0], self.CADENCE_CAM)
        cmds.rotate(-90, 180, 0)
        cmds.move(0, 100, 0, self.CADENCE_CAM, absolute=True)

        MayaUtils.setSelection(priorSelection)