daily pastebin goal
49%
SHARE
TWEET

CornerPinOffset

jedypod Sep 16th, 2012 216 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Group {
  2.  name CornerPinOffset2
  3.  tile_color 0xaa55ffff
  4.  addUserKnob {20 PinControl}
  5.  addUserKnob {26 CornerPinControls l "" +STARTLINE T "<font size=5><b>Corner Pin Data</b></font>"}
  6.  addUserKnob {20 CornerPinData l "" +STARTLINE n 1}
  7.  addUserKnob {41 to1 T cpMaster.to1}
  8.  addUserKnob {41 enable1 -STARTLINE T cpMaster.enable1}
  9.  addUserKnob {41 to2 T cpMaster.to2}
  10.  addUserKnob {41 enable2 -STARTLINE T cpMaster.enable2}
  11.  addUserKnob {41 to3 T cpMaster.to3}
  12.  addUserKnob {41 enable3 -STARTLINE T cpMaster.enable3}
  13.  addUserKnob {41 to4 T cpMaster.to4}
  14.  addUserKnob {41 enable4 -STARTLINE T cpMaster.enable4}
  15.  addUserKnob {20 endGroup_1 l endGroup n -1}
  16.  addUserKnob {41 invert T cpOutput.invert}
  17.  addUserKnob {41 filter T cpOutput.filter}
  18.  addUserKnob {41 black_outside l "black outside" T cpOutput.black_outside}
  19.  addUserKnob {41 motionblur T cpOutput.motionblur}
  20.  addUserKnob {41 shutter T cpOutput.shutter}
  21.  addUserKnob {41 shutteroffset l "shutter offset" T cpOutput.shutteroffset}
  22.  addUserKnob {41 shuttercustomoffset l "" -STARTLINE T cpOutput.shuttercustomoffset}
  23.  addUserKnob {26 ""}
  24.  addUserKnob {26 OffsetControls l "" +STARTLINE T "<font size=5><b>Offset Controls</b></font>"}
  25.  addUserKnob {41 offsetto1 l "offset to1" T offset1.translate}
  26.  addUserKnob {22 control1 t "Show the transform jack by opening the control panel of the grouped transform node" -STARTLINE T "nuke.show(nuke.thisGroup().node('offset1'), True)"}
  27.  addUserKnob {22 hide1 t "Closes the panel if you don't feel like doing it yourself" -STARTLINE T nuke.thisGroup().node('offset1').hideControlPanel()}
  28.  addUserKnob {41 offsetto2 l "offset to2" T offset2.translate}
  29.  addUserKnob {22 control2 t "Show the transform jack by opening the control panel of the grouped transform node" -STARTLINE T "nuke.show(nuke.thisGroup().node('offset2'), True)"}
  30.  addUserKnob {22 hide2 t "Closes the panel if you don't feel like doing it yourself" -STARTLINE T nuke.thisGroup().node('offset2').hideControlPanel()}
  31.  addUserKnob {41 offsetto3 l "offset to3" T offset3.translate}
  32.  addUserKnob {22 control3 t "Show the transform jack by opening the control panel of the grouped transform node" -STARTLINE T "nuke.show(nuke.thisGroup().node('offset3'), True)"}
  33.  addUserKnob {22 hide3 t "Closes the panel if you don't feel like doing it yourself" -STARTLINE T nuke.thisGroup().node('offset3').hideControlPanel()}
  34.  addUserKnob {41 offsetto4 l "offset to4" T offset4.translate}
  35.  addUserKnob {22 control4 t "Show the transform jack by opening the control panel of the grouped transform node" -STARTLINE T "nuke.show(nuke.thisGroup().node('offset4'), True)"}
  36.  addUserKnob {22 hide4 t "Closes the panel if you don't feel like doing it yourself" -STARTLINE T nuke.thisGroup().node('offset4').hideControlPanel()}
  37.  addUserKnob {22 showRefLines l "Show Ref Lines" t "Show Lines between pins, for lining up occluded corners." T "nuke.show(nuke.thisGroup().node('Roto1'), True)" +STARTLINE}
  38.  addUserKnob {26 div l "" +STARTLINE}
  39.  addUserKnob {22 LoadMochaAE l "Load Mocha AE Track" T "import nuke, re\n# is a comment about what following code does\n#??? is an informational side note\n#!!! is something that needs to be fixed or extended\n\n# Creates a Nuke Panel for the user to paste tracking data into.\np = nuke.Panel('Get MochaAE Track')\np.addMultilineTextInput('Track Data', '''Paste corner pin data from Mocha AE here. \\nMust be the type that supports RG Warp and mochaImport''')\np.addBooleanCheckBox('Motionblur On', True)\np.addSingleLineInput('Frame Offset', 'Frame Offset (Default: 0)')\n\nif not p.show():\n\traise\nmochatrack = p.value('''Track Data''')\ntext = mochatrack.splitlines(True)\ntry:\n\tif p.value('Frame Offset') == 'Frame Offset (Default: 0)':\n\t\tframe_offset = 0 + int(nuke.root().knob(\"first_frame\").value())\n\telse:\n\t\tframe_offset = int(p.value('Frame Offset')) + int(nuke.root().knob(\"first_frame\").value())\nexcept:\n\tnuke.message(\"Error! Start Frame must be an integer.\")\n\traise\nmotionblur_on = p.value('Motionblur On')\n# Get width and height from mocha tracking data\ncomp_width = int(re.search(r'Source Width\\t\\b\\d+\\b', mochatrack).group().split('\\t')\[1])\ncomp_height = int(re.search(r'Source Height\\t\\b\\d+\\b', mochatrack).group().split('\\t')\[1])\n\n\n# Iterates through every match for frame xpos ypos. The regex searches for <tab><int><tab><float/int><tab><float/int>\n# The search also matches 'Pin-####'. When a match for pin is found, it gets the corner number, and then skips getting frame and xpos/ypos\n# Data is added to a 4-dimensional list called track_data\n# The track_data list has 4 lists, one for each corner. Each of these lists has a list for each frame with frame,xpos,ypos data. \n# Therefore, track_data\[0] is the list of all frames for corner 1, track_data\[1] is corner 2, etc.\n# track_data\[0]\[23] would return \[frame,xpos,ypos] for frame 23 of corner 1\n\n# Initialize vars for loop\t\ntrack_data = \[\[],\[],\[],\[]]\nlast_frame = 0\nfor match in re.finditer(r'\\b\\d+\\b\\t\[-+]?\\b\[0-9]*\\.?\[0-9]+\\b\\t\[-+]?\\b\[0-9]*\\.?\[0-9]+\\b|Pin-\\d*', mochatrack):\n\tif re.match(r'Pin*', match.group()):\n\t\tcorner = int( match.group().split('-')\[1] )-1\n\t\tcontinue\n\tframe \t= int(match.group().split('\\t')\[0])\n\txpos\t= float(match.group().split('\\t')\[1])\n\typos\t= float(match.group().split('\\t')\[2])\n\ttrack_data\[corner].append(\[frame, xpos, ypos])\n\tlast_frame = frame\n\n# Converts the track_data corner order from AE to Nuke, since our data is stored in AE's corner format\n# Nuke is 1=LL, 2=LR, 3=UR, 4=UL. AE is LL=2, LR=3, UR=1, UL=0\ntrack_data\[0], track_data\[1], track_data\[2], track_data\[3] = track_data\[2], track_data\[3], track_data\[1], track_data\[0]\n\n\n##########################\n# Create CornerPin Node\n##########################\ncp = nuke.thisGroup().node('cpMaster')\n#cp = nuke.createNode('CornerPin2D')\nif motionblur_on == True:\n\tcp.knob('shutteroffset').setValue('centred')\n\tcp.knob('motionblur').setValue(20)\nto_knobs = \[ cp.knob('to1'), cp.knob('to2'), cp.knob('to3'), cp.knob('to4') ]\ncorner = 0\n# For each 'to' knob in the CornerPin node, set it to be animated, and for every frame in the track, set a key for xpos and ypos\n# frame\[0] is the frame number, frame\[1] is the xpos, frame\[2] is the ypos\n# ypos must be inverted (height - ypos), to be right in nuke\nfor knob in to_knobs:\n\tknob.setAnimated()\n\tfor frame in track_data\[corner]:\n\t\tknob.setValueAt( frame\[1], frame\[0]+frame_offset, 0 )\n\t\tknob.setValueAt( (comp_height - frame\[2]), frame\[0]+frame_offset,  1 )\n\tcorner += 1" +STARTLINE}
  40.  addUserKnob {20 OffsetCornerPinData n 1}
  41.  OffsetCornerPinData 0
  42.  addUserKnob {41 to1_1 l to1 T cpOutput.to1}
  43.  addUserKnob {41 to2_1 l to2 T cpOutput.to2}
  44.  addUserKnob {41 to3_1 l to3 T cpOutput.to3}
  45.  addUserKnob {41 to4_1 l to4 T cpOutput.to4}
  46.  addUserKnob {20 endGroup n -1}
  47. }
  48.  Input {
  49.   inputs 0
  50.   name Input1
  51.   xpos 704
  52.   ypos -263
  53.  }
  54.  CornerPin2D {
  55.   to1 {{cpMaster.to1+offset1.translate} {cpMaster.to1+offset1.translate}}
  56.   to2 {{cpMaster.to2+offset2.translate} {cpMaster.to2+offset2.translate}}
  57.   to3 {{cpMaster.to3+offset3.translate x1 1794} {cpMaster.to3+offset3.translate x1 1014}}
  58.   to4 {{cpMaster.to4+offset4.translate} {cpMaster.to4+offset4.translate}}
  59.   invert false
  60.   shutteroffset centred
  61.   from1 {0 0}
  62.   from2 {{input.width i} 0}
  63.   from3 {{input.width i} {input.height i}}
  64.   from4 {0 {input.height i}}
  65.   name cpOutput
  66.   xpos 704
  67.   ypos -157
  68.  }
  69.  Output {
  70.   name Output1
  71.   xpos 704
  72.   ypos -28
  73.  }
  74.  Transform {
  75.   inputs 0
  76.   center {{cpMaster.to4 i x1 0 x64 0 x172 0 x189 0 x1475 0} {cpMaster.to4 i x1 0 x64 0 x172 0 x189 0 x1475 0}}
  77.   name offset4
  78.   xpos 450
  79.   ypos -210
  80.  }
  81.  Transform {
  82.   inputs 0
  83.   scale {1 0.74}
  84.   center {{cpMaster.to1 i x1 0 x64 0 x172 0 x189 0 x1475 0} {cpMaster.to1 i x1 0 x64 0 x172 0 x189 0 x1475 0}}
  85.   name offset1
  86.   xpos 445
  87.   ypos -106
  88.  }
  89.  CornerPin2D {
  90.   inputs 0
  91.   to1 {0 0}
  92.   to2 {1920 0}
  93.   to3 {1920 1080}
  94.   to4 {0 1080}
  95.   invert false
  96.   motionblur 20
  97.   shutteroffset centred
  98.   from1 {0 0}
  99.   from2 {1920 0}
  100.   from3 {1920 1080}
  101.   from4 {0 1080}
  102.   name cpMaster
  103.   xpos 509
  104.   ypos -157
  105.  }
  106.  Transform {
  107.   inputs 0
  108.   center {{cpMaster.to3 x1 0 x4 0 0 x64 0 x172 0 x189 0 x1475 0} {cpMaster.to3 x1 0 x4 0 0 x64 0 x172 0 x189 0 x1475 0}}
  109.   name offset3
  110.   xpos 561
  111.   ypos -211
  112.  }
  113.  Transform {
  114.   inputs 0
  115.   center {{cpMaster.to2 x1 0 x64 0 x65 0 x172 0 x189 0 x295 0 x313 0 x1475 0} {cpMaster.to2 x1 0 x64 0 x65 0 x172 0 x189 0 x295 0 x313 0 x1475 0}}
  116.   name offset2
  117.   xpos 570
  118.   ypos -108
  119.  }
  120.  Roto {
  121.   inputs 0
  122.   curves {{{v x3f99999a}
  123.   {f 0}
  124.   {n
  125.    {layer Root
  126.     {f 512}
  127.     {t x44700000 x44070000}
  128.     {a}
  129.     {curvegroup Bezier1 512 bezier
  130.      {{cc
  131.        {f 8192}
  132.        {p
  133.         {}
  134.         {{=cpOutput.to4 x43870000}
  135.          {=cpOutput.to4 x441b8000}}
  136.         {}
  137.         {}
  138.         {{=cpOutput.to3 x44358000}
  139.          {=cpOutput.to3 x44410000}}
  140.         {}
  141.         {}
  142.         {{=cpOutput.to2 x446e8000}
  143.          {=cpOutput.to2 x43c50000}}
  144.         {}
  145.         {}
  146.         {{=cpOutput.to1 x43d70000}
  147.          {=cpOutput.to1 x43480000}}
  148.         {}}}
  149.       {cc
  150.        {f 8192}
  151.        {p
  152.         {}
  153.         {}
  154.         {}
  155.         {}
  156.         {}
  157.         {}
  158.         {}
  159.         {}
  160.         {}
  161.         {}
  162.         {}
  163.         {}}}}
  164.      {t x4414c000 x43f88000}
  165.      {a spx 0 spy 0 sb 1 tt x40800000}}}}}}
  166.   toolbox {selectAll {
  167.   { selectAll str 1 ssx 1 ssy 1 sf 1 }
  168.   { createBezier str 1 ssx 1 ssy 1 sf 1 sb 1 tt 4 }
  169.   { createBezierCusped str 1 ssx 1 ssy 1 sf 1 sb 1 }
  170.   { createBSpline str 1 ssx 1 ssy 1 sf 1 sb 1 tt 5 }
  171.   { createEllipse str 1 ssx 1 ssy 1 sf 1 sb 1 tt 6 }
  172.   { createRectangle str 1 ssx 1 ssy 1 sf 1 sb 1 tt 7 }
  173.   { createRectangleCusped str 1 ssx 1 ssy 1 sf 1 sb 1 }
  174.   { brush str 1 ssx 1 ssy 1 sf 1 sb 1 }
  175.   { eraser src 2 str 1 ssx 1 ssy 1 sf 1 sb 1 }
  176.   { clone src 1 str 1 ssx 1 ssy 1 sf 1 sb 1 }
  177.   { reveal src 3 str 1 ssx 1 ssy 1 sf 1 sb 1 }
  178.   { dodge src 1 str 1 ssx 1 ssy 1 sf 1 sb 1 }
  179.   { burn src 1 str 1 ssx 1 ssy 1 sf 1 sb 1 }
  180.   { blur src 1 str 1 ssx 1 ssy 1 sf 1 sb 1 }
  181.   { sharpen src 1 str 1 ssx 1 ssy 1 sf 1 sb 1 }
  182.   { smear src 1 str 1 ssx 1 ssy 1 sf 1 sb 1 }
  183. } }
  184.   toolbar_autokey false
  185.   toolbar_brush_hardness 0.200000003
  186.   toolbar_source_transform_scale {1 1}
  187.   toolbar_source_transform_center {320 240}
  188.   colorOverlay 0
  189.   lifetime_type "all frames"
  190.   view {}
  191.   motionblur_on true
  192.   motionblur_shutter_offset_type centred
  193.   source_translate_round false
  194.   source_black_outside true
  195.   createNewTrack {{-1} "-1\t(none)\t-1" "1000\tNew Track Layer\t1000"}
  196.   name Roto1
  197.   selected true
  198.   xpos 860
  199.   ypos -155
  200.  }
  201. end_group
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top