Example #1
0
    def __init__(self, name):
        if kDebugAll or kDebugRenderOverride:
            print("Initializing viewRenderOverride")

        #omr.MRenderOverride.__init__(self, name)
        super(viewRenderOverride, self).__init__(name)
        # name in the renderer dropdown menu
        self.mUIName = kPluginName
        # everytime you are preparing a plate,
        # you have to count which step you are on
        # this is reset when you start a new plate
        self.mOperation = 0
        # label for the onion
        # current frame, used for setting the onion target key
        self.mCurrentFrame = 0
        # holds all avaialable onions
        # the key to the target is its frame number
        self.mOnionBuffer = {}
        # sometimes M doesn't want to see onions,
        # thats when this should be False
        self.mEnableBlend = False
        # save the relative Onions
        self.mRelativeOnions = {}
        # save the absolute onions
        self.mAbsoluteOnions = {}
        # save all the objects to display in a list
        self.mOnionObjectList = om.MSelectionList()
        # store the render operations that combine onions in a list
        self.mRenderOperations = []
        # the tints for onions
        self.mRelativeFutureTint = [255, 0, 0]
        self.mRelativePastTint = [0, 255, 0]
        self.mAbsoluteTint = [0, 0, 255]
        # tint strengths, 1 is full tint
        self.mRelativeTintStrength = 1.0
        self.mAbsoluteTintStrength = 1.0

        # If this is True, we will show onions on the next keyticks
        # e.g. if mRelativeOnions has 1 and 3 in it, it will draw
        # the next and the 3rd frame with a tick on the timeslider
        self.mRelativeKeyDisplay = True
        self.mCallbackId = 0

        # Passes
        self.mClearPass = viewRenderClearRender("clearPass")
        self.mClearPass.setOverridesColors(False)
        self.mRenderOperations.append(self.mClearPass)

        self.mStandardPass = viewRenderSceneRender(
            "standardPass", omr.MClearOperation.kClearNone)
        self.mRenderOperations.append(self.mStandardPass)

        self.mOnionPass = viewRenderSceneRender("onionPass",
                                                omr.MClearOperation.kClearAll)
        self.mOnionPass.setSceneFilter(omr.MSceneRender.kRenderShadedItems)
        self.mOnionPass.setDrawSelectionFilter(True)
        self.mRenderOperations.append(self.mOnionPass)

        self.mHUDPass = viewRenderHUDRender()
        self.mRenderOperations.append(self.mHUDPass)

        self.mPresentTarget = viewRenderPresentTarget("presentTarget")
        self.mRenderOperations.append(self.mPresentTarget)

        # TARGETS
        # standard target is what will be displayed. all but onion render to this target
        self.mStandardTargetDescr = omr.MRenderTargetDescription()
        self.mStandardTargetDescr.setName("standardTarget")
        self.mStandardTargetDescr.setRasterFormat(
            omr.MRenderer.kR8G8B8A8_UNORM)

        # onion target will be blended over standard target
        self.mOnionTargetDescr = omr.MRenderTargetDescription()
        self.mOnionTargetDescr.setName("onionTarget")
        self.mOnionTargetDescr.setRasterFormat(omr.MRenderer.kR8G8B8A8_UNORM)

        # Set the targets that don't change
        self.mTargetMgr = omr.MRenderer.getRenderTargetManager()

        self.mStandardTarget = self.mTargetMgr.acquireRenderTarget(
            self.mStandardTargetDescr)
        self.mClearPass.setRenderTarget(self.mStandardTarget)
        self.mStandardPass.setRenderTarget(self.mStandardTarget)
        self.mHUDPass.setRenderTarget(self.mStandardTarget)
        self.mPresentTarget.setRenderTarget(self.mStandardTarget)
Example #2
0
    def __init__(self, name):
        if DEBUG:
            print ("Initializing ViewRenderOverride")

        #omr.MRenderOverride.__init__(self, name)
        super(ViewRenderOverride, self).__init__(name)

        # name in the renderer dropdown menu
        self.UIName = PLUGIN_NAME

        # this counts through the render passes
        # restarts for every frame output to the screen
        self.operation = 0

        # label for the onion
        # current frame, used for setting the onion target key
        self.currentFrame = 0
        # holds all avaialable onion skin renders
        # the key to the target is its frame number
        self.onionSkinBuffer = {}
        # save the order in which onions where added
        self.onionSkinBufferQueue = collections.deque()
        # max amount of buffered frames
        self.maxOnionSkinBufferSize = 200
        # store blend passes for relative onion skin display
        # a pass is stored when the user activates it in the ui with the "v" icon
        self.relativeBlendPasses = {}
        # only display every nth relative onion
        self.relativeStep = 1
        # store blend passes for absolute onion skin display
        # a blend pass is stored with the key being its frame
        # a blend pass is added for each absolute onion skin display the user registers
        self.absoluteBlendPasses = {}
        # buffer onion objects to make adding sets possible
        self.onionObjectBuffer = om.MSelectionList()
        # save all the objects to display in a list
        self.onionObjectList = om.MSelectionList()
        # store the render operations that combine onions in a list
        self.renderOperations = []
        # tint colors for different os types rgb 0-255
        self.relativeFutureTint = [255,0,0]
        self.relativePastTint = [0,255,0]
        self.absoluteTint = [0,0,255]
        # tint strengths, 1 is full tint
        self.tintStrength = 1.0
        self.globalOpacity = 1.0
        self.onionSkinDisplayType = 1
        # outline width in pixels
        self.outlineWidth = 3
        self.drawBehind = 1

        # range 0-2.
        # 0 = default, 1 = relative random, 2 = static random
        self.tintType = 0
        # seed value set by user to get different random colors for tints
        self.tintSeed = 0

        # If this is True, we will show onion skins on the next keyticks
        # e.g. if relativeBlendPasses has 1 and 3 in it, it will draw
        # the next and the 3rd frame with a tick on the timeslider
        self.relativeKeyDisplay = True
        # 
        self.timeCallbackId = 0
        # 
        self.cameraMovedCallbackIds = []
        # 
        self.autoClearBuffer = True

        # Passes
        self.clearPass = clearRender.viewRenderClearRender("clearPass")
        self.clearPass.setOverridesColors(False)
        self.renderOperations.append(self.clearPass)

        self.standardPass = sceneRender.OSSceneRender(
            "standardPass",
            omr.MClearOperation.kClearNone
        )
        self.renderOperations.append(self.standardPass)

        # the onion skin pass buffers an image of the specified object on the current frame
        self.onionSkinPass = sceneRender.OSSceneRender(
            "onionSkinPass",
            omr.MClearOperation.kClearAll
        )
        self.onionSkinPass.setSceneFilter(omr.MSceneRender.kRenderShadedItems)
        self.onionSkinPass.setDrawSelectionFilter(True)
        self.renderOperations.append(self.onionSkinPass)

        self.HUDPass = hudRender.viewRenderHUDRender()
        self.renderOperations.append(self.HUDPass)

        self.presentTarget = presentTarget.viewRenderPresentTarget("presentTarget")
        self.renderOperations.append(self.presentTarget)
        
        # TARGETS
        # standard target is what will be displayed. all but onion skins render to this target
        self.standardTargetDescr = omr.MRenderTargetDescription()
        self.standardTargetDescr.setName("standardTarget")
        self.standardTargetDescr.setRasterFormat(omr.MRenderer.kR8G8B8A8_UNORM)

        self.depthTargetDescr = omr.MRenderTargetDescription()
        self.depthTargetDescr.setName("depthTarget")
        self.depthTargetDescr.setRasterFormat(omr.MRenderer.kD24S8)

        # with this onion skins will be blended over standard target
        self.blendTargetDescr = omr.MRenderTargetDescription()
        self.blendTargetDescr.setName("onionTarget")
        self.blendTargetDescr.setRasterFormat(omr.MRenderer.kR8G8B8A8_UNORM)

        # Set the targets that don't change
        self.targetMgr = omr.MRenderer.getRenderTargetManager()
        
        self.standardTarget = self.targetMgr.acquireRenderTarget(self.standardTargetDescr)
        self.clearPass.setRenderTarget(self.standardTarget)
        self.standardPass.setRenderTarget(self.standardTarget)
        self.HUDPass.setRenderTarget(self.standardTarget)
        self.presentTarget.setRenderTarget(self.standardTarget)