Пример #1
0
    def cameraInversion():
        camera = mari.canvases.current().camera()

        lookAt = camera.lookAt()
        up = camera.up()
        translation = camera.translation()
        
        camera.setTranslation( mari.VectorN(-translation.x(),translation.y(),translation.z()))
        camera.setUp( mari.VectorN(-up.x(),up.y(),up.z()))
        camera.setLookAt( mari.VectorN(-lookAt.x(),lookAt.y(),lookAt.z()))
Пример #2
0
    def fitBufferToUdim(udim):
        '''
		In Uv view. frame and fit the paint buffer to a given uv tile.
		'''
        can = mari.canvases.current()
        if can.camera().type() != 2:
            print "current viwe is not UV view."
            return
        cam = can.camera()
        cam.setScale(1)
        uvIndex = mu.udimToMariIndex(udim)
        udim_V = uvIndex / 10
        udim_U = uvIndex % 10
        vectorN_x = udim_U + 0.5
        vectorN_y = udim_V + 0.5
        lookvec = mari.VectorN(vectorN_x, vectorN_y, 1.0)
        #move the camera accordingly.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        cam.setScale(0.5)
        cam.setLookAt(lookvec)
        pBuffer = mari.canvases.paintBuffer()
        defaultSize = PythonQt.Qt.QSizeF(1, -1)
        defaultPoint = PythonQt.Qt.QPoint(0.0, 0.0)
        defaultPos = PythonQt.Qt.QPointF(defaultPoint)
        #move the bufer accordingly.
        pBuffer.setRotation(0)
        pBuffer.setScale(defaultSize)
        pBuffer.setTranslation(defaultPos)
Пример #3
0
def cameraInverseZ():

    camera = mari.canvases.current().camera()

    lookAt = camera.lookAt()
    up = camera.up()
    translation = camera.translation()


    
    camera.setTranslation( mari.VectorN(translation.x(),translation.y(),-translation.z()))
    camera.setUp( mari.VectorN(up.x(),up.y(),-up.z()))
    camera.setLookAt( mari.VectorN(lookAt.x(),lookAt.y(),-lookAt.z()))

    core = PySide.QtCore

    def paintBufferFlip( scaleFactor ):
            paintBuffer = mari.canvases.paintBuffer()
            scale = paintBuffer.scale()
            scale = core.QSizeF( scale.width() * scaleFactor[0], scale.height() * scaleFactor[1] )
            paintBuffer.setScale( scale )

    paintBufferFlip((-1,1))

    def paintBufferRotate():
            paint_buffer = mari.canvases.paintBuffer()
            rotation = paint_buffer.rotation()
            paint_buffer.setRotation( 360-rotation )

    paintBufferRotate()


    def paintBufferTranslation():

            paint_buffer = mari.canvases.paintBuffer()
            translation = paint_buffer.translation()
            paint_buffer.setTranslation(core.QPointF(-translation.x(), translation.y()))

    paintBufferTranslation()
Пример #4
0
def mirror_bake():
    '''Executes a Mirror Bake'''

    actions = mirrorActions()
    X = actions['X'][1]
    Y = actions['Y'][1]
    Z = actions['Z'][1]

    x = 1
    y = 1
    z = 1
    pbx = 1
    pby = 1

    if X.isChecked():
        x = -1
        pbx = -1
    elif Y.isChecked():
        y = -1
        pbx = -1
    elif Z.isChecked():
        z = -1
        pbx = -1

    canvas = mari.canvases.current()
    camera = canvas.camera()

    #Avoid Mirroring in the UV Viewport.
    if camera.UV == camera.type():
        return

    bake = mari.actions.find("/Mari/Canvas/Bake")

    paintBuffer = mari.canvases.paintBuffer()
    currentpaint = paintBuffer.saveContent()

    pb_scale = paintBuffer.scale()
    pb_rotation = paintBuffer.rotation()
    pb_translation = paintBuffer.translation()

    lookAt = camera.lookAt()
    translation = camera.translation()
    up = camera.up()

    #Move to mirrored position
    camera.setLookAt(
        mari.VectorN(x * lookAt.x(), y * lookAt.y(), z * lookAt.z()))
    camera.setTranslation(
        mari.VectorN(x * translation.x(), y * translation.y(),
                     z * translation.z()))
    camera.setUp(mari.VectorN(x * up.x(), y * up.y(), z * up.z()))

    #Mirror paint buffer
    paintBuffer.setScale(
        PySide.QtCore.QSizeF(pbx * pb_scale.width(), pby * pb_scale.height()))
    paintBuffer.setTranslation(pb_translation)
    paintBuffer.setRotation(pb_rotation)

    # #disconnect to avoid looping
    paintBuffer.aboutToBake.disconnect(mirror_bake)

    #Bake from the mirrored position first
    bake.trigger()

    #Restore the original position
    camera.setLookAt(lookAt)
    camera.setTranslation(translation)
    camera.setUp(up)
    #Resotre the original paint buffer
    paintBuffer.setScale(pb_scale)
    paintBuffer.setTranslation(pb_translation)
    paintBuffer.setRotation(pb_rotation)
    paintBuffer.restoreContent()

    currentBehave = mari.projection.getProperty("Projection/bakeBehavior")

    bake.trigger()
    mari.projection.setProperty("Projection/bakeBehavior", currentBehave)

    #reconnect now that we already passed the bake steps and avoided the loop.
    paintBuffer.aboutToBake.connect(mirror_bake)