Nuke Python 自定義動(dòng)畫(huà)

這部分介紹如何下Nuke中自定義、擴(kuò)展自己的動(dòng)畫(huà)流程

Tweak Software的RV作為默認(rèn)動(dòng)畫(huà)程序
# Copyright (c) 2010 The Foundry Visionmongers Ltd.  All Rights Reserved.
import platform
import sys
import os.path
import re
import thread
import nuke
import subprocess
import nukescripts
import nukescripts.flipbooking as flipbooking

class RVFlipbook(flipbooking.FlipbookApplication):
""" This is an example implementation of how to deal with implementing a
flipbook application other than NUKE's Player for NUKE. This script
needs to be modified in several places before it can work, so please
read all of the notes marked with TODO and modify them where
necessary."""
  def __init__(self):
    # TODO: Please put your own path in here or add RV path discovery.
    self._rvPath = "/Applications/RV64.app/Contents/MacOS/RV64"

  def name(self):
    return "RV"

  def path(self):
    return self._rvPath

  def cacheDir(self):
    return os.environ["NUKE_TEMP_DIR"]

  def run(self, filename, frameRanges, views, options):
    # TODO: You probably want more involved handling of frame ranges!
    sequence_interval = str(frameRanges.minFrame())+"-"+str(frameRanges.maxFrame())
    for frame in xrange(frameRanges.minFrame(), frameRanges.maxFrame()):
      if frame not in frameRanges.toFrameList():
        print "This example only supports complete frame ranges"
        return

    os.path.normpath(filename)

    args = []
    if nuke.env['WIN32']:
      args.append( "\"" + self.path() + "\"" )
      filename = filename.replace("/", "\\")
      filename = "\"" + filename + "\""
    else:
      args.append( self.path() )


    roi = options.get("roi", None)
    if roi != None and not (roi["x"] == 0.0 and roi["y"] == 0.0 and roi["w"] == 0.0 and roi["h"] == 0.0):
      args.append("-c "+str(int(roi["x"])))
      args.append(str(int(roi["y"])))
      args.append(str(int(roi["w"])))
      args.append(str(int(roi["h"])))

    lut = options.get("lut", "")
    if lut == "linear-sRGB":
      args.append("-sRGB")
    elif lut == "linear-rec709":
      args.append('-rec709')

    args.append(filename)
    args.append(sequence_interval)

    #print args
    os.spawnv(os.P_NOWAITO, self.path(), args)

  def capabilities(self):
    return {
      'proxyScale': False,
      'crop': True,
      'canPreLaunch': False,
      'supportsArbitraryChannels': True,
      'maximumViews' : 2,
      # TODO: This list is compiled from running rv with the following:
      # RV64 -formats | grep 'format "' | awk '{print $2}' | tr '[:space:]' ','; echo
      # This may differ for your platform!
      'fileTypes' : ["j2k","jpt","jp2","dpx","cin","cineon","jpeg","jpg","rla","rpf","yuv","exr","openexr","sxr","tif","tiff","sm","tex","tx","tdl","shd","targa","tga","tpic","rgbe","hdr","iff","png","z","zfile","sgi","bw","rgb","rgba","*mraysubfile*","movieproc","stdinfb","aiff","aif","aifc","wav","snd","au","mov","avi","mp4","m4v","dv"]

    }

flipbooking.register( RVFlipbook() )
nukescripts.setFlipbookDefaultOption("flipbook", "RV")
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容