Exemplo n.º 1
0
    def colllect_renderlayer_members(self, name):
        """Return renerlayer members in short name

        This method is implemented with Maya API 1.0.

        (NOTE)
        `editRenderLayerMembers` can only return either full path or just
        node name. And using `listConnections` to list out the connection
        between renerlayer's `renderInfo` and node's `renderLayerInfo` to
        find members, doesn't work with defaultRenderLayer.

        """
        import maya.OpenMaya as om_v1
        import maya.OpenMayaRender as omrender_v1

        members = set()

        mobj = omrender_v1.MFnRenderLayer.findLayerByName(name)
        layer = omrender_v1.MFnRenderLayer(mobj)

        marray = om_v1.MObjectArray()
        layer.listMembers(marray)

        for index in range(marray.length()):
            mobj = marray[index]
            # Assume all member `hasFn(om_v1.MFn.kDagNode)`
            node = om_v1.MFnDagNode(mobj)
            members.add(node.partialPathName())

        return list(members)
Exemplo n.º 2
0
    def _writeClip(self, track_elem, isVideo, clip):

        # Note: we'll make the clip name and id the same as the maya node-name
        # used for linking of audio and video
        clip_info = {"name": clip, "id": clip}

        if isVideo:
            seqStartTime = cmds.shot(clip, q=1, sequenceStartTime=1)
            clip_info["duration"] = cmds.shot(clip, q=1, sequenceDuration=1)
            clip_info["start"] = seqStartTime

            # Final frame in editorial is always exclusive (bug 342715), but it
            # is not in Maya, so we must add 1 at the end here when exporting
            seqEndTime = cmds.shot(clip, q=1, sequenceEndTime=1) + 1
            clip_info["end"] = seqEndTime
            clip_info["enabled"] = not cmds.shot(clip, q=1, mute=1)

            inTime = cmds.shot(clip, q=1, clipZeroOffset=1)
            clip_info["in"] = inTime
            clip_info["out"] = inTime + seqEndTime - seqStartTime

            # TODO: pre/post hold

        else:
            seqOffset = cmds.sound(clip, q=1, offset=1)
            silence = float(cmds.getAttr((clip + ".silence")))
            mediaIn = cmds.sound(clip, q=1, sourceStart=1)
            mediaOut = cmds.sound(clip, q=1, sourceEnd=1)
            clip_info["start"] = (seqOffset + silence)
            clip_info["end"] = seqOffset + silence + mediaOut - mediaIn
            clip_info["in"] = mediaIn
            clip_info["out"] = mediaOut
            clip_info["duration"] = mediaOut - mediaIn
            clip_info["enabled"] = not cmds.sound(clip, q=1, mute=1)

        clip_elem = self.translator.writeClip(track_elem, clip_info)

        # Note: we won't be able to open this up unless we have a file.
        # So even if there's no file, create a dummy one
        file_info = {"name": clip}

        if isVideo:
            imagePlane = cmds.shot(clip, q=1, clip=1)
            if imagePlane is not None:
                try:
                    # Using Maya API to get absolute path for the image plane media
                    node = _nameToNode(imagePlane)
                    file_info["pathurl"] = OpenMayaRender.MRenderUtil(
                    ).exactImagePlaneFileName(node)
                except:
                    file_info["pathurl"] = cmds.getAttr(imagePlane +
                                                        ".imageName")
                file_info["duration"] = cmds.shot(clip, q=1, clipDuration=1)
        else:
            file_info["pathurl"] = cmds.sound(clip, q=1, file=1)
            file_info["duration"] = cmds.sound(clip, q=1, length=1)

        file_elem = self.translator.writeFile(clip_elem, file_info)
Exemplo n.º 3
0
	def setPixel(self, width, height, n, r, g, b, a, bc):
		px = OpenMayaRender.RV_PIXEL()
		x = int(n % width)
		y = int(math.floor( n / width ))
		px.r = r
		px.g = g
		px.b = b
		if bc == 4:
			px.a = a
		else:
			px.a = 255
			
		OpenMayaRender.MRenderView.updatePixels(x, x, y, y, px )
Exemplo n.º 4
0
 def _GetCurrentRenderLayerName(self):
     currentRenderLayerObj = OMR.MFnRenderLayer.currentLayer()
     currentRenderLayer = OMR.MFnRenderLayer(currentRenderLayerObj)
     return currentRenderLayer.name()
Exemplo n.º 5
0
 def _GetDefaultRenderLayerName(self):
     defaultRenderLayerObj = OMR.MFnRenderLayer.defaultRenderLayer()
     defaultRenderLayer = OMR.MFnRenderLayer(defaultRenderLayerObj)
     return defaultRenderLayer.name()
Exemplo n.º 6
0
 def __init__(self):
     self.render_Layer = OpenMayaRender.MFnRenderLayer()