Exemplo n.º 1
0
 def process(self, context):
     first = nuke.numvalue('root.first_frame')
     last = nuke.numvalue('root.last_frame')
     context.create_instance('帧范围: {:.0f}-{:.0f}'.format(first, last),
                             first=first,
                             last=last,
                             family='帧范围')
Exemplo n.º 2
0
def _get_frange():
    """Open a dialog to request a Nuke-style frame range

    Args:
        N/A

    Returns:
        <nuke.FrameRange>
            Returns a FrameRange object if valid frange is entered, or none.

    Raises:
        N/A

    """

    first_frame = int(nuke.numvalue('root.first_frame'))
    last_frame = int(nuke.numvalue('root.last_frame'))
    step = 1
    default_frange = str(nuke.FrameRange(first_frame, last_frame, step))
    frange = nuke.getInput('Enter Frame Range:', default_frange)

    if not frange:
        return None
    else:
        try:
            return nuke.FrameRange(frange)
        except:  # TODO: Determine exact exception
            nuke.message('Invalid frame range')
            return None
Exemplo n.º 3
0
def _get_frange():
    """Open a dialog to request a Nuke-style frame range

    Args:
        N/A

    Returns:
        <nuke.FrameRange>
            Returns a FrameRange object if valid frange is entered, or none.

    Raises:
        N/A

    """

    first_frame = int(nuke.numvalue('root.first_frame'))
    last_frame = int(nuke.numvalue('root.last_frame'))
    step = 1
    default_frange = str(nuke.FrameRange(first_frame, last_frame, step))
    frange = nuke.getInput('Enter Frame Range:', default_frange)

    if not frange:
        return None
    else:
        try:
            return nuke.FrameRange(frange)
        except:  # TODO: Determine exact exception
            nuke.message('Invalid frame range')
            return None
Exemplo n.º 4
0
def _autoplace():
    if nuke.numvalue('preferences.wlf_autoplace',
                     0.0) and nuke.Root().modified():
        autoplace_type = nuke.numvalue('preferences.wlf_autoplace_type', 0.0)
        LOGGER.debug('Autoplace. type: %s', autoplace_type)
        if autoplace_type == 0.0:
            autoplace(async_=False)
        else:
            map(nuke.autoplace, nuke.allNodes())
Exemplo n.º 5
0
def dialog_set_framerange():
    """Dialog for set_framerange.  """

    panel = nuke.Panel('设置帧范围')
    panel.addExpressionInput('first', nuke.numvalue('root.first_frame'))
    panel.addExpressionInput('last', nuke.numvalue('root.last_frame'))
    confirm = panel.show()

    if confirm:
        set_framerange(panel.value('first'), panel.value('last'))
Exemplo n.º 6
0
 def set_indicators(self):
     # this function is copied from Foundry's autolabel.py and
     # is copyright Foundry, all rights reserved
     # seemingly more or less need to use this TCL code, as there doesn't
     # seem to be python equivalents for these functions
     ind = nuke.expression(
         "(keys?1:0)+(has_expression?2:0)+(clones?8:0)+(viewsplit?32:0)")
     if int(nuke.numvalue("maskChannelInput", 0)):
         ind += 4
     if int(nuke.numvalue("this.mix", 1)) < 1:
         ind += 16
     nuke.knob("this.indicators", str(ind))
Exemplo n.º 7
0
 def process(self, instance):
     filename = instance.data['name']
     if nuke.numvalue('preferences.wlf_send_to_dir', 0.0):
         render_dir = u(nuke.value('preferences.wlf_render_dir'))
         copy(filename, render_dir + '/')
     else:
         self.log.info('因为首选项设置而跳过')
Exemplo n.º 8
0
    def import_video(self, sign):
        """Import corresponse video by filebox sign.

        Args:
            sign (unicode): Server defined fileboxsign

        Returns:
            nuke.Node: Created read node.
        """

        node_name = {'animation_videos': '动画视频'}.get(sign, sign)
        n = nuke.toNode(utf8(node_name))
        if n is None:
            dir_ = self.filebox.get(sign).path
            videos = Path(dir_).glob('{}.*'.format(self.shot))
            for video in videos:
                n = nuke.nodes.Read(name=utf8(node_name))
                n['file'].fromUserText(unicode(video).encode('utf-8'))
                break
            if not n:
                raise ValueError('No matched upstream video.')
        n['frame_mode'].setValue(b'start_at')
        n['frame'].setValue(b'{:.0f}'.format(
            nuke.numvalue('root.first_frame')))
        CurrentViewer().link(n, 4, replace=False)
        return n
Exemplo n.º 9
0
def custom_create_read(defaulttype="Read"):

    """Create a Read node for a file selected from the file browser. 
    If a node is currently selected in the nodegraph and it has a 'file' 
    (or failing that a 'proxy') knob, the value (if any) will be used as the default 
    path for the file browser."""
    # Get the selected node, and the path on it's 'file' knob if it
    # has one, or failing that, it's 'proxy' node, if it has that.
    sel_node = None
    default_dir = None
    try:
        sel_node = nuke.selectedNode()
    except:
        pass
    if (sel_node is not None) and (sel_node != ""):
        if "file" in sel_node.knobs():
            default_dir = sel_node["file"].value()
        if (default_dir == None or default_dir == "") and "proxy" in sel_node.knobs():
            default_dir = sel_node["proxy"].value()

    # Revert default_dir to None if it's empty so that the file browser
    # will do it's default unset behaviour rather than open on an empty path.
    if default_dir == "":
        default_dir = None

    # Raise the file browser and get path(s) for Read node(s).
    files = nuke.getClipname("Read File(s)", default=default_dir, multiple=True)
    if files != None:
        maxFiles = nuke.numvalue("preferences.maxPanels")
        n = len(files)
        for f in files:
            log_(f)
            isAbc = False
            stripped = nuke.stripFrameRange(f)
            nodeType = defaulttype
            if isAudioFilename(f):
                nodeType = "AudioRead"
            if isGeoFilename(f):
                nodeType = "ReadGeo2"
            if isAbcFilename(f):
                isAbc = True
            if isDeepFilename(f):
                nodeType = "DeepRead"

                # only specify inpanel for the last n nodes. Old panels are kicked out using
                # a deferred delete, so reading large numbers of files can internally build
                # large numbers of active widgets before the deferred deletes occur.
            useInPanel = True
            if maxFiles != 0 and n > maxFiles:
                useInPanel = False
            n = n - 1

            if isAbc:
                nuke.createScenefileBrowser(f, "")
            else:
                try:
                    nuke.createNode(nodeType, "file {" + f + "}", inpanel=useInPanel)
                except RuntimeError, err:
                    nuke.message(err.args[0])
Exemplo n.º 10
0
    def output(self, filename):
        """Save .nk file and render .jpg file."""

        LOGGER.info('{:-^30s}'.format('开始 输出'))
        _path = filename.replace('\\', '/')
        _dir = os.path.dirname(_path)
        if not os.path.exists(_dir):
            os.makedirs(_dir)

        # Save nk
        LOGGER.info('保存为:\t%s', _path)
        nuke.Root()['name'].setValue(_path)
        nuke.scriptSave(_path)

        # Render png
        if CONFIG.get('RENDER_JPG'):
            for n in nuke.allNodes('Read'):
                name = n.name()
                if name in ('MP', 'Read_Write_JPG'):
                    continue
                for frame in (n.firstFrame(), n.lastFrame(),
                              int(nuke.numvalue('_Write.knob.frame'))):
                    try:
                        render_png(n, frame)
                        break
                    except RuntimeError:
                        continue

        # Render Single Frame
        n = nuke.toNode('_Write')
        if n:
            n = n.node('Write_JPG_1')
            n['disable'].setValue(False)
            for frame in (int(nuke.numvalue('_Write.knob.frame')),
                          n.firstFrame(), n.lastFrame()):
                try:
                    nuke.execute(n, frame, frame)
                    break
                except RuntimeError:
                    continue
            else:
                self._errors.append('{}:\t渲染出错'.format(
                    os.path.basename(_path)))
                raise RenderError('Write_JPG_1')
            LOGGER.info('{:-^30s}'.format('结束 输出'))
Exemplo n.º 11
0
def panel_show(keyword):
    """Show control panel for matched nodes."""

    nodes = sorted((n for n in nuke.allNodes() if keyword in n.name()
                    and not nuke.numvalue('{}.disable'.format(n.name()), 0)),
                   key=lambda n: n.name(),
                   reverse=True)
    for n in nodes:
        n.showControlPanel()
Exemplo n.º 12
0
def getFrameRange():
    '''Open a dialog to request a Nuke-style frame range
  @return:  a frameRange object if a valid frame range is entered
                None if frame range is invalid or dialog is cancelled
  '''
    firstFrame = int(nuke.numvalue('root.first_frame'))
    lastFrame = int(nuke.numvalue('root.last_frame'))
    step = 1
    _range = str(nuke.FrameRange(firstFrame, lastFrame, step))
    r = nuke.getInput('Enter Frame Range:', _range)

    try:
        if not r:
            return None
        else:
            return nuke.FrameRange(r)
    except:
        nuke.message('Invalid frame range')
        return None
Exemplo n.º 13
0
def getFrameRange():
  '''Open a dialog to request a Nuke-style frame range
  @return:  a frameRange object if a valid frame range is entered
                None if frame range is invalid or dialog is cancelled
  '''
  firstFrame = int(nuke.numvalue('root.first_frame'))
  lastFrame = int(nuke.numvalue('root.last_frame'))
  step = 1
  _range = str(nuke.FrameRange(firstFrame,lastFrame,step))
  r = nuke.getInput('Enter Frame Range:', _range)

  try:
    if not r:
      return None
    else:
      return nuke.FrameRange(r)
  except:
    nuke.message('Invalid frame range')
    return None
Exemplo n.º 14
0
def GradeLabel():

    # keep node indicators
    ind = nuke.expression(
        "(keys?1:0)+(has_expression?2:0)+(clones?8:0)+(viewsplit?32:0)")
    if int(nuke.numvalue("maskChannelInput", 0)):
        ind += 4
    if int(nuke.numvalue("this.mix", 1)) < 1:
        ind += 16
    nuke.knob("this.indicators", str(ind))
    ###

    # get the node
    node = nuke.thisNode()

    if node.Class() == "Grade":

        # sets autolabel to node name
        autoLabel = node.name()

        # check if values are zero'ed or not
        BP = ('BP' if node['blackpoint'].value() != 0 else None)
        WP = ('WP' if node['whitepoint'].value() != 1 else None)
        Lift = ('Lift' if node['black'].value() != 0 else None)
        Gain = ('Gain' if node['white'].value() != 1 else None)
        Multiply = ('Multiply' if node['multiply'].value() != 1 else None)
        Offset = ('Offset' if node['add'].value() != 0 else None)
        Gamma = ('Gamma' if node['gamma'].value() != 1 else None)

        # creates list
        knobs = [BP, WP, Lift, Gain, Multiply, Offset, Gamma]

        # if value inside list != None, add to autoLabel
        for knob in knobs:
            if knob != None:
                autoLabel = autoLabel + '\n' + knob

        # adds custom user label if exists
        if node['label'].value():
            autoLabel = autoLabel + '\n' + node['label'].value()

        return autoLabel
Exemplo n.º 15
0
def _jump_frame():
    if nuke.numvalue('preferences.wlf_jump_frame', 0.0):
        LOGGER.debug('Jump frame')
        try:
            n = wlf_write_node()
        except ValueError:
            LOGGER.warning('No `wlf_Write` node.')
            return
        if n:
            nuke.frame(n['frame'].value())
            nuke.Root().setModified(False)
Exemplo n.º 16
0
def _tri_render_panel(_list, exceptOnError=True):
 	"""
	This is copied directly from execute_panel.py with the exception
	of changing "execute" to "render" but is likely to evolve
	over time with other rendering-specific options.
	"""

	start = int(nuke.numvalue("root.first_frame"))
	end = int(nuke.numvalue("root.last_frame"))
	incr = 1
	if start < 1:
	    nuke.message("Start frame number cannot be less than 1")
	    return

	try:
	    _range = str(nuke.FrameRange(start, end, incr))
	except ValueError,e:
	     # In this case we have to extract from the error message the
	     # correct frame range format string representation.
	     # I'm expecting to have an error like: "Frame Range invalid (-1722942,-1722942)"
	     msg = e. __str__()
	     _range = msg[msg.index("(")+1:  msg.index(")")]
Exemplo n.º 17
0
def after_created(nodes):
    first_frame = nuke.numvalue('root.first_frame')
    # Skip when no need to offset frame range.
    if first_frame == 1:
        return

    read_nodes = [
        i for i in nodes if i.Class() == 'Read' and _is_reading_video(i)
    ]

    for n in read_nodes:
        n['frame_mode'].setValue('start_at'.encode('utf-8'))
        n['frame'].setValue('{:.0f}'.format(first_frame).encode('utf-8'))
Exemplo n.º 18
0
def _gizmo_to_group_on_create():
    n = nuke.thisNode()
    if not nuke.numvalue('preferences.wlf_gizmo_to_group', 0.0):
        return

    if not isinstance(n, nuke.Gizmo):
        return

    # Avoid scripted gizmo.
    if nuke.knobChangeds.get(n.Class()):
        return

    n.addKnob(nuke.Text_Knob('wlf_gizmo_to_group'))
Exemplo n.º 19
0
def flipbook_with_audio(node, framesAndViews=None):
    """Runs an arbitrary command on the images output by a node. This checks
  to see if the node is a Read or Write and calls the function directly
  otherwise it creates a temporary Write, executes it, and then calls
  the command on that temporary Write, then deletes it.
  
  By writing your own function you can use this to launch your own
  flipbook or video-output programs.
  
  Specify framesAndViews as a tuple if desired, like so: ("1,5", ["main"])
  This can be useful when running without a GUI."""

    # Stop here if we're trying to Framecycle in PLE mode, as in some code paths
    # the execute is called before the Framecycler script could do this check
    if nuke.env['ple']:
        raise RuntimeError("Framecycler is not available in PLE mode.")

    global previous_inrange
    global previous_userrange
    global previous_audio

    if node is None or (node.Class() == "Viewer" and node.inputs() == 0):
        return

    a = int(nuke.numvalue(node.name() + ".first_frame"))
    b = int(nuke.numvalue(node.name() + ".last_frame"))
    if a >= b:
        a = int(nuke.numvalue("root.first_frame"))
        b = int(nuke.numvalue("root.last_frame"))

    try:
        inrange = str(nuke.FrameRange(a, b, 1))
    except ValueError, e:
        # In this case we have to extract from the error message the
        # correct frame range format string representation.
        # I'm expecting to have a error like: "Frame Range invalid (-1722942,-1722942)"

        msg = e.__str__()
        inrange = msg[msg.index("(") + 1:msg.index(")")]
Exemplo n.º 20
0
    def process(self, instance):
        with keep_modifield_status():
            if not nuke.numvalue('preferences.wlf_render_jpg', 0.0):
                self.log.info('因首选项而跳过生成JPG')
                return

            n = wlf_write_node()
            if n:
                self.log.debug('render_jpg: %s', n.name())
                try:
                    n['bt_render_JPG'].execute()
                except RuntimeError as ex:
                    nuke.message(str(ex))
            else:
                self.log.warning('工程中缺少wlf_Write节点')
Exemplo n.º 21
0
def _lock_connections():
    if nuke.numvalue('preferences.wlf_lock_connections', 0.0):
        nuke.Root()['lock_connections'].setValue(1)
        nuke.Root().setModified(False)
Exemplo n.º 22
0
def _eval_proj_dir():
    if nuke.numvalue('preferences.wlf_eval_proj_dir', 0.0):
        attr = 'root.project_directory'
        nuke.knob(attr, os.path.abspath(nuke.value(attr)).replace('\\', '/'))
Exemplo n.º 23
0
 def _enable_node():
     if nuke.numvalue('preferences.wlf_enable_node', 0.0):
         marked_nodes().enable()
Exemplo n.º 24
0
def autolabel():
  """This function is run automatically by Nuke during idle, and the return
  text is drawn on the box of the node. It can also have side effects by
  setting knobs. Currently two knobs are provided that are useful:

  indicators = integer bit flags to turn icons on/off. The icons
  named indicator1, indicator2, indicator4, indicator8, etc are
  drawn if the corresponding bit is on. By default these are loaded
  from the path as indicator1.xpm, etc, but you can use the load_icon
  command to load other files.

  icon = name of a whole extra image you can draw, but it replaces
  any previous one."""

  # do the icons:
  ind = nuke.expression("(keys?1:0)+(has_expression?2:0)+(clones?8:0)+(viewsplit?32:0)")

  if int(nuke.numvalue("maskChannelInput", 0)) :
    ind += 4
  if int(nuke.numvalue("this.mix", 1)) < 1:
    ind += 16
  nuke.knob("this.indicators", str(ind))

  this = nuke.toNode("this")

  # do stuff that works even if autolabel is turned off:
  name = nuke.value("name")
  _class = this.Class()

  label = nuke.value("label")
  if not label:
    label = ""
  else:
    try:
      label = nuke.tcl("subst", label)
    except:
      pass

  if _class == "Dot" or _class == "BackdropNode" or _class == "StickyNote":
    return label
  elif _class.startswith("Read") or _class.startswith("Write") or _class.startswith( "Precomp" ):
    reading = int(nuke.numvalue("this.reading", 0 ))

    if reading and _class.startswith( "Precomp" ):
      filename = nuke.filename( node = this.output().input(0), replace = nuke.REPLACE )
    else:
      filename = nuke.filename(replace = nuke.REPLACE)
    if filename is not None:
      name = __concat_result_string(name, os.path.basename(filename))

    if reading:
      checkHashOnRead = False
      if _class.startswith( "Precomp" ):
        if this.output() != None and this.output().input(0) != None:
          checkHashOnReadKnob = this.output().input(0).knob( "checkHashOnRead" )
          if checkHashOnReadKnob:
            checkHashOnRead = checkHashOnReadKnob.value()
      else:
        checkHashOnRead = this.knob("checkHashOnRead").value()

      if checkHashOnRead == True and ( this.proxy() != True ):
        name = name + "\n(Read)"
      else:
        name = name + "\n(Read - unchecked)"
  elif _class == 'DeepRead':
    filename = nuke.filename(replace = nuke.REPLACE)
    if filename is not None:
      name =  __concat_result_string(name, os.path.basename(filename))
  elif _class.startswith("ParticleCache" ):
    rendering = int(nuke.numvalue("this.particle_cache_render_in_progress", 0 ))
    if rendering:
      name = name + "\n(Rendering)"
    else:
      reading = int(nuke.numvalue("this.particle_cache_read_from_file", 0 ))
      if reading:
        name = name + "\n(Read)"

  if nuke.numvalue("preferences.autolabel") == 0 or _class.find("OFX", 0) != -1:
    return __concat_result_string(name, label)

  # build the autolabel:
  operation = nuke.value('this.operation', '')
  if operation != '' and _class != 'ChannelMerge' and _class != 'Precomp':
    name = name + ' (' + operation + ')'

  layer = nuke.value("this.output", nuke.value("this.channels", "-"))
  mask = nuke.value("this.maskChannelInput", "none")
  unpremult = nuke.value("this.unpremult", "none")

  if _class.startswith("Read") or _class.startswith("Write"):
    # do colorspace labeling for reads and writes
    if int(nuke.numvalue("this.raw", 0)):
      layer = "RAW"
    else:
      colorspace = _getAutoLableColorspace()

      # additional to NUKE-mode default colorspaces not being shown, if the
      # colorspace is set to "custom" (aka unintialised) in the UI the name
      # comes through as empty, so ignore it.
      if colorspace:
        layer = colorspace

    if _class.startswith("Write"):
      order = nuke.numvalue("this.render_order", 1)
      mask = str(order)
      if int(order) == 1:
        mask = "none"
  elif _class == "Reformat":
    if nuke.expression("!type"):
      format = nuke.value("format")
      rootformat = nuke.value("root.format")
      if format is not None and format != rootformat:
        format_list = format.split()
        layer = " ".join(format_list[7:])
  elif _class == "ChannelMerge":
    if operation == "union":
      operation = "U"
    elif operation == "intersect":
      operation = "I"
    elif operation == "stencil":
      operation = "S"
    elif operation == "absminus":
      operation = "abs-"
    elif operation == "plus":
      operation = "+"
    elif operation == "minus":
      operation = "-"
    elif operation == "multiply":
      operation = "*"
    layer = nuke.value("A") + " " + operation + " " + nuke.value("B") + " =\n" + nuke.value("output")
  elif _class == "Premult" or _class == "Unpremult":
    unpremult = nuke.value("alpha")
    if unpremult == "alpha":
      unpremult = "none"
  elif _class == "Copy":
    layer = ""
    if nuke.value("to0") != "none":
      layer += nuke.value("from0") + " -> " + nuke.value("to0")
    if nuke.value("to1") != "none":
      layer += "\n" + nuke.value("from1") + " -> " + nuke.value("to1")
    if nuke.value("to2") != "none":
      layer += "\n" + nuke.value("from2") + " -> " + nuke.value("to2")
    if nuke.value("to3") != "none":
      layer += "\n" + nuke.value("from3") + " -> " + nuke.value("to3")
    if nuke.value("channels") != "none":
      layer += ("\n" + nuke.value("channels") + "->" + nuke.value("channels"))
  elif _class == "FrameHold":
    value_inc = nuke.value("increment")
    if int(value_inc):
      layer = "frame "+nuke.value("knob.first_frame")+"+n*"+value_inc
    else:
      layer = "frame "+nuke.value("knob.first_frame")
  elif _class == "Precomp":
    layer = '-'

  if mask != "none":
    if int(nuke.numvalue("invert_mask", 0)):
      layer += (" / ~" + mask)
    else:
      layer += (" / " + mask)

  if unpremult != "none" and unpremult != mask and _class.find("Deep", 0) == -1:
    layer += ( " / " + unpremult)

  if layer != "rgba" and layer != "rgb" and layer != "-":
    result = __concat_result_string(name, "(" + layer + ")" + "\n" + str(label))
  else:
    result = __concat_result_string(name, label)

  return result
Exemplo n.º 25
0
def startFrame():
    """
    Return first frame number in scene
    """
    return int(nuke.numvalue("root.first_frame"))
Exemplo n.º 26
0
def sceneLenght():
    return int(nuke.numvalue("root.last_frame") - nuke.numvalue("root.first_frame") + 1)
    """
Exemplo n.º 27
0
def lastFrame():
    """
    Return last frame number in scene
    """
    return int(nuke.numvalue("root.last_frame"))
Exemplo n.º 28
0
 def process(self, context):
     fps = nuke.numvalue('root.fps')
     context.create_instance(name='帧速率: {:.0f}'.format(fps),
                             fps=fps,
                             family='帧速率')
Exemplo n.º 29
0
def currentFrame():
    """
    Return current source frame number
    """
    return int(nuke.numvalue("frame"))
Exemplo n.º 30
0
def currentSceneFrame():
    """
    Return current frame number in scene
    """
    return int(nuke.numvalue("frame") - nuke.numvalue("root.first_frame") + 1)
Exemplo n.º 31
0
def _check_framerange():
    if int(nuke.numvalue("root.first_frame")) < 1:
        raise ValueError("Start frame number can not be less than 1")
    return
Exemplo n.º 32
0
def bakeCamera():
    ver=str(nuke.NUKE_VERSION_MAJOR)+str(nuke.NUKE_VERSION_MINOR)
    if int(ver) < 61:
        nuke.message("This script works only withe Nuke 6.1 and higher")
        return
 
    if len(nuke.selectedNodes()) != 1:
        nuke.message("Select Camera Node")
        return
 
    n=nuke.selectedNode()
    if n.Class() != "Camera2":
        nuke.message("No Camera selected")
        return
 
    firstFrame = int(nuke.numvalue('root.first_frame'))
    lastFrame = int(nuke.numvalue('root.last_frame'))
    step = 1
    _range = str(nuke.FrameRange(firstFrame,lastFrame,step))
    r = nuke.getInput('Enter Frame Range:', _range)
 
    bakeFocal = False
    bakeHaperture = False
    bakeVaperture = False
 
 
    k = n['world_matrix']
 
    newCam = nuke.createNode("Camera2")
    newCam.setInput(0, None)
    newCam['rotate'].setAnimated()
    newCam['translate'].setAnimated()
 
    oldFocal = n['focal']
    if oldFocal.isAnimated() and not (oldFocal.animation(0).constant()):
        newCam['focal'].setAnimated()
        bakeFocal = True
    else:
        newCam['focal'].setValue(oldFocal.value())
 
    oldHaperture = n['haperture']
    if oldHaperture.isAnimated() and not (oldHaperture.animation(0).constant()):
        newCam['haperture'].setAnimated()
        bakeHaperture = True
    else:
        newCam['haperture'].setValue(oldHaperture.value())
 
    oldVaperture = n['vaperture']
    if oldVaperture.isAnimated() and not (oldVaperture.animation(0).constant()):
        newCam['vaperture'].setAnimated()
        bakeVaperture = True
    else:
        newCam['vaperture'].setValue(oldVaperture.value())
 
    newCam['win_translate'].setValue(n['win_translate'].value())
    newCam['win_scale'].setValue(n['win_scale'].value())
 
    for x in nuke.FrameRange(r):
        m = nuke.math.Matrix4()
        for y in range(k.height()):
            for z in range(k.width()):
                m[z+(y*k.width())] = k.getValueAt(x, (y+(z*k.width())))
 
        rotM = nuke.math.Matrix4(m)
        rotM.rotationOnly() 
        rot = rotM.rotationsZXY()
 
        newCam['rotate'].setValueAt(math.degrees(rot[0]), x, 0)
        newCam['rotate'].setValueAt(math.degrees(rot[1]), x, 1)
        newCam['rotate'].setValueAt(math.degrees(rot[2]), x, 2)
        newCam['translate'].setValueAt(k.getValueAt(x, 3), x, 0)
        newCam['translate'].setValueAt(k.getValueAt(x, 7), x, 1)
        newCam['translate'].setValueAt(k.getValueAt(x, 11), x, 2)
 
        if bakeFocal:
            newCam['focal'].setValueAt(oldFocal.getValueAt(x), x)
        if bakeHaperture:
            newCam['haperture'].setValueAt(oldHaperture.getValueAt(x), x)
        if bakeVaperture:
            newCam['vaperture'].setValueAt(oldVaperture.getValueAt(x), x)
Exemplo n.º 33
0
 def fps(self):
     """Frame per secondes.  """
     return CONFIG.get('fps') or nuke.numvalue('root.fps')