Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Group {
- name Pixels2Position
- inputs 2
- tile_color 0x990000ff
- addUserKnob {20 User l Parameters}
- addUserKnob {26 NodeName l "" +STARTLINE T "<font color = white font size = 4> Pixels2Position<font color = grey font size = 2> By Eli Saliba"}
- addUserKnob {26 ""}
- addUserKnob {3 pointCounter l INVISIBLE +INVISIBLE}
- addUserKnob {22 addPoint l "<font color=green>Add Point" T "#Add point\nnode = nuke.thisNode()\n\nFrame = nuke.frame()\ninput = node.input(1)\nwhile node.input and input.Class() == 'Dot':\n input = input.input(0)\nif input and input.Class() == 'Camera2' or 'Camera':\n sFocal= input\['focal'].value(0)\n sHaperture= input\['haperture'].value(0)\n sVaperture= input\['vaperture'].value(0)\n sWinTranslateX= input\['win_translate'].value(0)\n sWinTranslateY= input\['win_translate'].value(1)\n sWinScaleX= input\['win_scale'].value(0)\n sWinScaleY= input\['win_scale'].value(1)\n sWinRoll= input\['winroll'].value(0)\nnode.begin()\ntargetCamera = nuke.toNode('CameraMain')\ntargetCamera\['focal'].setAnimated()\ntargetCamera\['haperture'].setAnimated()\ntargetCamera\['vaperture'].setAnimated()\ntargetCamera\['win_translate'].setAnimated()\ntargetCamera\['win_translate'].setAnimated()\ntargetCamera\['win_scale'].setAnimated()\ntargetCamera\['win_scale'].setAnimated()\ntargetCamera\['winroll'].setAnimated()\ntargetCamera\['focal'].setValueAt(sFocal, Frame)\ntargetCamera\['haperture'].setValueAt(sHaperture, Frame)\ntargetCamera\['vaperture'].setValueAt(sVaperture, Frame)\ntargetCamera\['win_translate'].setValueAt(sWinTranslateX, Frame, 0)\ntargetCamera\['win_translate'].setValueAt(sWinTranslateY, Frame, 1)\ntargetCamera\['win_scale'].setValueAt(sWinScaleX, Frame, 0)\ntargetCamera\['win_scale'].setValueAt(sWinScaleY, Frame, 1)\ntargetCamera\['winroll'].setValueAt(sWinRoll, Frame)\n\nnode.end()\n\npointCounter = node\['pointCounter']\naccuracy = node\['accuracy']\nindex = node\['pointCounter'].value()\n\n\n\nif index < 2:\n index += 1\n pointCounter.setValue(index)\n \n def Position2D():\n viewer = nuke.activeViewer()\n activeInput = nuke.ViewerWindow.activeInput(viewer)\n viewerNode = viewer.node()\n sampledImage=viewerNode.input(activeInput)\n bboxinfo = viewer.node()\['colour_sample_bbox'].value()\n aspect = float(sampledImage.width())/float(sampledImage.height())\n position = 0\n position = \[(bboxinfo\[0]*0.5+0.5)*sampledImage.width(),(((bboxinfo\[1]*0.5)+(0.5/aspect))*aspect)*sampledImage.height()]\n return position\n \n samples = nuke.Text_Knob('Sample\{0\}'.format(int(pointCounter.value())) , 'Position <font color=\"grey\">\{1\} \{2\} <font color=\"light grey\">Frame<font color=\"grey\"> \{0\}'.format( int(nuke.frame()), int(Position2D()\[0]), int(Position2D()\[1])) )\n #samples.setFlag(0x00040000) #Hide\n samples.clearFlag(0x1000) #newline\n\n #add 2d samples knobs\n position = nuke.UV_Knob('Position\{0\}'.format(int(pointCounter.value())))\n position.setValue(Position2D())\n position.setFlag(0x00040000) #Hide\n position.setFlag(0x1000) #newline\n \n frame = nuke.Int_Knob('Frame\{0\}'.format(int(pointCounter.value())))\n frame.setValue(nuke.frame())\n frame.setFlag(0x00040000) #Hide\n frame.clearFlag(0x1000) #newline\n \n for each in (position, samples, frame):\n node.addKnob(each)\n \nelse:\n nuke.message( \"maximum points amount\" )\n\nif index == 2:\n node.begin()\n nuke.toNode('XYZMesh')\['disable'].setValue(0)\n node.end()\n" +STARTLINE}
- addUserKnob {22 reset l "<font color =red> Reset" -STARTLINE T "#reset\n\nnode = nuke.thisNode()\npointCounter = node\['pointCounter']\n\nindex = 0\npointCounter.setValue(index)\nnode\['sceneScale'].setValue(999)\n\nfor each in node.allKnobs():\n if each.name().startswith('Position') or each.name().startswith('Frame') or each.name().startswith('Sample') or each.name().startswith('Remove') or each.name().startswith('textAccuracy'):\n node.removeKnob(each)\n elif each.name().startswith('Feedback'):\n node.removeKnob(each)\n\n\nnode.begin()\ntargetCamera = nuke.toNode('CameraMain')\ntargetCamera\['focal'].clearAnimated()\ntargetCamera\['haperture'].clearAnimated()\ntargetCamera\['vaperture'].clearAnimated()\ntargetCamera\['win_translate'].clearAnimated()\ntargetCamera\['win_translate'].clearAnimated()\ntargetCamera\['win_scale'].clearAnimated()\ntargetCamera\['win_scale'].clearAnimated()\ntargetCamera\['winroll'].clearAnimated()\nnuke.toNode('XYZMesh')\['disable'].setValue(1)\nnode.begin()\n\nnode\['XYoutput'].clearAnimated()\nnode\['XYoutput'].setValue(0)\nnode\['XYoutput'].setVisible(False)"}
- addUserKnob {22 Help -STARTLINE T "#help\n\nimport webbrowser\nwebbrowser.open('http://www.nukepedia.com/gizmos/3d/pixels2position')"}
- addUserKnob {26 ""}
- addUserKnob {41 XYZoutput l "XYZ output" T IntersectionPoint.translate}
- addUserKnob {12 XYoutput l "XY output" +HIDDEN}
- addUserKnob {22 exportAxis l "Export Axis" T "node = nuke.thisNode()\nwith nuke.root():\n\tknob = node\['XYZoutput'].value()\n\tposX = node\['xpos'].value()\n\tposY = node\['ypos'].value()\n\n\tAxis = nuke.nodes.Axis()\n\tAxis\['xpos'].setValue(posX + 100)\n\tAxis\['ypos'].setValue(posY + 100)\n\tAxis\['translate'].setValue(knob)" +STARTLINE}
- addUserKnob {22 showXY l "Export XY" -STARTLINE T "#show XY\n\nimport nuke\nfrom nukescripts import snap3d as sn\nimport math\n\n\ndef cameraProjectionMatrix(cameraNode, frame, imageformat):\n ## modified code from nukescripts/Snap3D\n # Matrix to transform points into camera-relative coords.\n wm = nuke.math.Matrix4()\n for i in xrange(16):\n wm\[i] = cameraNode\['matrix'].getValueAt(frame,i)\n wm.transpose()\n camTransform = wm.inverse()\n # Matrix to take the camera projection knobs into account\n roll = float(cameraNode\['winroll'].getValueAt(frame,0))\n scale_x = float(cameraNode\['win_scale'].getValueAt(frame,0))\n scale_y = float(cameraNode\['win_scale'].getValueAt(frame,1))\n m = nuke.math.Matrix4()\n m.makeIdentity()\n m.rotateZ(math.radians(roll))\n m.scale(1.0 / scale_x, 1.0 / scale_y, 1.0)\n #matrix to fix win_translate\n focal_length = float(cameraNode\['focal'].getValueAt(frame))\n h_aperture = float(cameraNode\['haperture'].getValueAt(frame))\n win_translateX = float(cameraNode\['win_translate'].getValueAt(frame,0))\n win_translateY = float(cameraNode\['win_translate'].getValueAt(frame,1))\n translate_x = (( h_aperture / focal_length ) * -0.5) * win_translateX\n translate_y = (( h_aperture / focal_length ) * -0.5) * win_translateY\n wt = nuke.math.Matrix4()\n wt.makeIdentity()\n for i in xrange(16):\n if i == 2:\n wt\[i] = translate_x\n elif i == 6:\n wt\[i] = translate_y\n wt.transpose()\n wti = wt.inverse()\n # Projection matrix based on the focal length, aperture and clipping planes of the camera\n focal_length = float(cameraNode\['focal'].getValueAt(frame))\n h_aperture = float(cameraNode\['haperture'].getValueAt(frame))\n near = float(cameraNode\['near'].getValueAt(frame))\n far = float(cameraNode\['far'].getValueAt(frame))\n projection_mode = int(cameraNode\['projection_mode'].getValueAt(frame))\n p = nuke.math.Matrix4()\n p.projection(focal_length / h_aperture, near, far, projection_mode == 0)\n # Matrix to translate the projected points into normalised pixel coords\n imageAspect = float(imageformat.height()) / float(imageformat.width())\n t = nuke.math.Matrix4()\n t.makeIdentity()\n t.translate( 1.0, 1.0 - (1.0 - imageAspect / float(imageformat.pixelAspect())), 0.0 )\n # Matrix to scale normalised pixel coords into actual pixel coords.\n x_scale = float(imageformat.width()) / 2.0\n y_scale = x_scale * imageformat.pixelAspect()\n s = nuke.math.Matrix4()\n s.makeIdentity()\n s.scale(x_scale, y_scale, 1.0)\n return s * t * p * m * wti * camTransform\n\n\ndef projectPoints(frame, camera=None, point=None, imageformat=None):\n # Modify projectpoint function in nukescripts.snap3d to add frame argument\n if not imageformat:\n imageformat = nuke.root()\['format'].value()\n camMatrix = cameraProjectionMatrix(camera, frame, imageformat)\n if camMatrix == None:\n raise RuntimeError, \"snap3d.cameraProjectionMatrix() returned None for camera.\"\n\n if not ( isinstance(point, list) or isinstance(point, tuple) ):\n raise ValueError, \"Argument point must be a list or tuple.\"\n\n for point in point:\n # Would be nice to not do this for every item but since lists/tuples can\n # containg anything...\n if isinstance(point, nuke.math.Vector3):\n pt = point\n elif isinstance(point, list) or isinstance(point, tuple):\n pt = nuke.math.Vector3(point\[0], point\[1], point\[2])\n else:\n raise ValueError, \"All items in point must be nuke.math.Vector3 or list/tuple of 3 floats.\"\n\n tPos = camMatrix * nuke.math.Vector4(pt.x, pt.y, pt.z, 1.0)\n #print tPos\n try:\n yield nuke.math.Vector2(tPos.x / tPos.w, tPos.y / tPos.w)\n except ZeroDivisionError:\n print \"Zero Division Error on frame \{0\} with point data \{1\}\".format(frame, point)\n yield nuke.math.Vector2()\n\ndef getCamera(node):\n myInput = node.input(0)\n while 'Camera' not in myInput.Class():\n myInput = getCamera(myInput)\n return myInput\n\ndef Project(node):\n cam_input = node.input(1)\n if 'Camera' in cam_input.Class():\n cam = cam_input\n else:\n cam = getCamera(cam_input)\n # Get framerange to operate on from camera animation curves\n first = None\n last = None\n try:\n if cam\['translate'].isAnimated():\n for curve in cam\['translate'].animations():\n if first == None:\n first = int(curve.keys()\[0].x)\n else:\n first = min(first, int(curve.keys()\[0].x))\n for curve in cam\['translate'].animations():\n if last == None:\n last = int(curve.keys()\[-1].x)\n else:\n last = max(last, int(curve.keys()\[-1].x))\n elif cam\['rotate'].isAnimated():\n for curve in cam\['rotate'].animations():\n if first == None:\n first = int(curve.keys()\[0].x)\n else:\n first = min(first, int(curve.keys()\[0].x))\n for curve in cam\['rotate'].animations():\n if last == None:\n last = int(curve.keys()\[-1].x)\n else:\n last = max(last, int(curve.keys()\[-1].x))\n else:\n return\n except:\n nuke.message(\"!!!\")\n first = nuke.root().firstFrame()\n last = nuke.root().lastFrame()\n framerange = nuke.FrameRange('\{0\}-\{1\}'.format(first, last))\n\n input = node\[\"XYZoutput\"]\n output = node\[\"XYoutput\"]\n output.clearAnimated()\n output.setAnimated()\n point_animcurve = \[\[], \[]]\n for frame in framerange:\n\n #print \"values are \", ipknob.getValueAt(frame)\n # Sample input point knob on every frame if it's animated or expression-linked\n if input.isAnimated() or input.hasExpression():\n point = projectPoints(frame, cam, \[input.getValueAt(frame)], node.format()).next()\n else:\n point = projectPoints(frame, cam, \[input.value()], node.format()).next()\n for index in xrange(2):\n point_animcurve\[index].append(nuke.AnimationKey(frame, point\[index]))\n\n for index, curve in enumerate(output.animations()):\n curve.addKey(point_animcurve\[index])\n\n\nnode = nuke.thisNode()\nknob = node\['XYoutput']\n\n#set visibility\nif knob.visible() == 1:\n knob.setVisible(False)\nelse:\n knob.setVisible(True)\n if __name__==\"__main__\":\n Project(node)"}
- addUserKnob {20 advancedSettings l "Advanced Settings" n 1}
- advancedSettings 0
- addUserKnob {7 sceneScale l "Scene Scale" R 1 999}
- sceneScale 999
- addUserKnob {41 disable_1 l Locator T Switch1.disable}
- addUserKnob {41 uniform_scale l Size -STARTLINE T TransformGeo1.uniform_scale}
- addUserKnob {20 endGroup n -1}
- addUserKnob {26 feedback l Feedback}
- addUserKnob {41 accuracy l Accuracy T fourPoints.accuracy}
- }
- Input {
- inputs 0
- name Camera
- xpos 262
- ypos 192
- number 1
- }
- set N171644f0 [stack 0]
- Axis2 {
- inputs 0
- translate {{parent.fourPoints.IntersectionPoint.x} {parent.fourPoints.IntersectionPoint.y} {parent.fourPoints.IntersectionPoint.z}}
- name IntersectionPoint
- xpos 941
- ypos 124
- }
- set N171699d0 [stack 0]
- Group {
- inputs 0
- name XYZMesh
- xpos 769
- ypos 89
- disable true
- }
- Constant {
- inputs 0
- channels {-rgba.red -rgba.green rgba.blue none}
- color 1
- name Constant2
- xpos 635
- ypos 50
- postage_stamp false
- }
- Cylinder {
- inputs 0
- rows 1
- columns 8
- radius 0.03
- height 1
- translate {0 0.5 0}
- uniform_scale 0.9
- pivot {0 -0.5 0}
- name Cylinder1
- xpos 878
- ypos -335
- }
- set N1718e9a0 [stack 0]
- push $N1718e9a0
- RadialDistort {
- distortion 55
- power_bias 1.98
- scale {0.3 0.03 0.3}
- name RadialDistort1
- xpos 972
- ypos -266
- }
- TransformGeo {
- translate {3.540680638e-09 -0.04420004 0}
- rotate {0 0 180}
- pivot {0 0.68 0}
- name TransformGeo4
- xpos 972
- ypos -242
- }
- MergeGeo {
- inputs 2
- name MergeGeo2
- xpos 878
- ypos -242
- }
- set N171bd5b0 [stack 0]
- TransformGeo {
- rotate {90 0 0}
- name TransformGeo2
- xpos 758
- ypos -167
- }
- ApplyMaterial {
- inputs 2
- name ApplyMaterial3
- xpos 758
- ypos 50
- }
- Constant {
- inputs 0
- channels {-rgba.red rgba.green -rgba.blue none}
- color 1
- name Constant3
- xpos 635
- ypos 21
- postage_stamp false
- }
- push $N171bd5b0
- ApplyMaterial {
- inputs 2
- name ApplyMaterial2
- xpos 878
- ypos 47
- }
- Constant {
- inputs 0
- channels {rgba.red -rgba.green -rgba.blue none}
- color 1
- name Constant1
- xpos 1109
- ypos 42
- postage_stamp false
- }
- push $N171bd5b0
- TransformGeo {
- rotate {0 0 -90}
- name TransformGeo3
- xpos 1004
- ypos -165
- }
- ApplyMaterial {
- inputs 2
- name ApplyMaterial1
- xpos 1004
- ypos 42
- }
- MergeGeo {
- inputs 3
- name MergeGeo1
- xpos 878
- ypos 143
- }
- Output {
- name Output1
- xpos 878
- ypos 279
- }
- end_group
- TransformGeo {
- inputs 2
- uniform_scale 1
- name TransformGeo1
- xpos 769
- ypos 145
- }
- Switch {
- which 1
- name Switch1
- xpos 769
- ypos 192
- disable true
- }
- Input {
- inputs 0
- name Input
- xpos 580
- ypos 145
- addUserKnob {20 User}
- addUserKnob {14 format R 0 100}
- format {{"\[value Input.format.w]"} {"\[value Input.format.h]"}}
- addUserKnob {7 aspect}
- aspect {{format.h/format.w}}
- addUserKnob {7 pixelAspect l "Pixel Aspect"}
- pixelAspect {{"\[value Input.format.pixel_aspect]"}}
- }
- ScanlineRender {
- inputs 3
- conservative_shader_sampling false
- antialiasing medium
- motion_vectors_type distance
- name ScanlineRender1
- xpos 580
- ypos 192
- }
- Output {
- name Output1
- xpos 580
- ypos 248
- }
- push $N171699d0
- Dot {
- name Dot10
- xpos 965
- ypos 287
- }
- push $N171644f0
- Camera2 {
- useMatrix true
- matrix {
- {1 0 {((CameraMain.haperture/CameraMain.focal)*-0.5)*CameraMain.win_translate.0} 0}
- {0 1 {((CameraMain.haperture/CameraMain.focal)*-0.5)*CameraMain.win_translate.1} 0}
- {0 0 1 0}
- {0 0 0 1}
- }
- focal 47.4744898
- haperture 23.56826019
- vaperture 19.0597551
- win_translate {0.07755101995 0.03877550997}
- win_scale {1.19387755 0.96122449}
- winroll -4.062499944
- name CameraMain
- label "Apply win_translate in matrix"
- xpos 272
- ypos 249
- addUserKnob {20 plus}
- addUserKnob {7 FOV}
- FOV {{"degrees(2 * atan (( 0.5 * this.haperture) / (this.focal)))"}}
- }
- Axis2 {
- xform_order RST
- rotate {0 0 {-CameraMain.winroll}}
- scaling {{CameraMain.win_scale.u} {CameraMain.win_scale.v} 1}
- name Axis3
- label "Apply \"win_scale\" and \"winroll\""
- xpos 272
- ypos 344
- }
- set N1728b870 [stack 0]
- Axis2 {
- translate {{"tan(radians(CameraMain.FOV*0.5)) * sceneScale * (Position2.u - Input.format.w/2)/(Input.format.w/2)"} {"tan(radians(CameraMain.FOV*0.5)) * sceneScale * (Position2.v - Input.format.h/2)/(Input.format.h/2) * Input.aspect"} {-sceneScale}}
- name Axis2
- label Position2
- xpos 399
- ypos 344
- }
- NoOp {
- inputs 0
- name fourPoints
- xpos 928
- ypos 54
- hide_input true
- addUserKnob {20 User}
- addUserKnob {13 a}
- a {{parent.CameraMain.world_matrix.3(Frame1)} {parent.CameraMain.world_matrix.7(Frame1)} {parent.CameraMain.world_matrix.11(Frame1)}}
- addUserKnob {13 b}
- b {{parent.Axis1.world_matrix.3(Frame1)} {parent.Axis1.world_matrix.7(Frame1)} {parent.Axis1.world_matrix.11(Frame1)}}
- addUserKnob {13 c}
- c {{parent.CameraMain.world_matrix.3(Frame2)} {parent.CameraMain.world_matrix.7(Frame2)} {parent.CameraMain.world_matrix.11(Frame2)}}
- addUserKnob {13 d}
- d {{parent.Axis2.world_matrix.3(Frame2)} {parent.Axis2.world_matrix.7(Frame2)} {parent.Axis2.world_matrix.11(Frame2)}}
- addUserKnob {26 ""}
- addUserKnob {13 IntersectionPoint}
- IntersectionPoint {{"\[python -execlocal node\\ =\\ nuke.thisNode()\\na,b,c,d\\ =\\ node\\\['a'\\].value(),node\\\['b'\\].value(),node\\\['c'\\].value(),node\\\['d'\\].value()\\n\\ntry:\\n\\ \\ \\ \\ #constants\\ required\\ for\\ solving\\ t\\ and\\ s\\n\\ \\ \\ \\ A=b\\\[0\\]-a\\\[0\\]\\n\\ \\ \\ \\ B=c\\\[0\\]-d\\\[0\\]\\n\\ \\ \\ \\ C=c\\\[0\\]-a\\\[0\\]\\n\\ \\ \\ \\ D=b\\\[1\\]-a\\\[1\\]\\n\\ \\ \\ \\ E=c\\\[1\\]-d\\\[1\\]\\n\\ \\ \\ \\ F=c\\\[1\\]-a\\\[1\\]\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #find\\ t\\ and\\ s\\ using\\ formula\\n\\ \\ \\ \\ t=(C*E-F*B)/(E*A-B*D)\\n\\ \\ \\ \\ s=(D*C-A*F)/(D*B-A*E)\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #accuracy\\n\\ \\ \\ \\ accuracy\\ =\\ \\ abs\\ (\\ (t*(b\\\[2\\]-a\\\[2\\])+s*(c\\\[2\\]-d\\\[2\\]))\\ -\\ (c\\\[2\\]-a\\\[2\\]))\\ \\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #find\\ intersection\\ point\\n\\ \\ \\ \\ pointx\\ =\\ a\\\[0\\]\\ +\\ t*(b\\\[0\\]-a\\\[0\\])\\n\\ \\ \\ \\ pointy\\ =\\ a\\\[1\\]\\ +\\ t*(b\\\[1\\]-a\\\[1\\])\\n\\ \\ \\ \\ pointz\\ =\\ a\\\[2\\]\\ +\\ t*(b\\\[2\\]-a\\\[2\\])\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ ret\\ =\\ pointx\\nexcept\\ ZeroDivisionError:\\n\\ \\ \\ \\ ret\\ =\\ 0]"} {"\[python -execlocal node\\ =\\ nuke.thisNode()\\na,b,c,d\\ =\\ node\\\['a'\\].value(),node\\\['b'\\].value(),node\\\['c'\\].value(),node\\\['d'\\].value()\\n\\ntry:\\n\\ \\ \\ \\ #constants\\ required\\ for\\ solving\\ t\\ and\\ s\\n\\ \\ \\ \\ A=b\\\[0\\]-a\\\[0\\]\\n\\ \\ \\ \\ B=c\\\[0\\]-d\\\[0\\]\\n\\ \\ \\ \\ C=c\\\[0\\]-a\\\[0\\]\\n\\ \\ \\ \\ D=b\\\[1\\]-a\\\[1\\]\\n\\ \\ \\ \\ E=c\\\[1\\]-d\\\[1\\]\\n\\ \\ \\ \\ F=c\\\[1\\]-a\\\[1\\]\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #find\\ t\\ and\\ s\\ using\\ formula\\n\\ \\ \\ \\ t=(C*E-F*B)/(E*A-B*D)\\n\\ \\ \\ \\ s=(D*C-A*F)/(D*B-A*E)\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #accuracy\\n\\ \\ \\ \\ accuracy\\ =\\ \\ abs\\ (\\ (t*(b\\\[2\\]-a\\\[2\\])+s*(c\\\[2\\]-d\\\[2\\]))\\ -\\ (c\\\[2\\]-a\\\[2\\]))\\ \\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #find\\ intersection\\ point\\n\\ \\ \\ \\ pointx\\ =\\ a\\\[0\\]\\ +\\ t*(b\\\[0\\]-a\\\[0\\])\\n\\ \\ \\ \\ pointy\\ =\\ a\\\[1\\]\\ +\\ t*(b\\\[1\\]-a\\\[1\\])\\n\\ \\ \\ \\ pointz\\ =\\ a\\\[2\\]\\ +\\ t*(b\\\[2\\]-a\\\[2\\])\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ ret\\ =\\ pointy\\nexcept\\ ZeroDivisionError:\\n\\ \\ \\ \\ ret\\ =\\ 0]"} {"\[python -execlocal node\\ =\\ nuke.thisNode()\\na,b,c,d\\ =\\ node\\\['a'\\].value(),node\\\['b'\\].value(),node\\\['c'\\].value(),node\\\['d'\\].value()\\n\\ntry:\\n\\ \\ \\ \\ #constants\\ required\\ for\\ solving\\ t\\ and\\ s\\n\\ \\ \\ \\ A=b\\\[0\\]-a\\\[0\\]\\n\\ \\ \\ \\ B=c\\\[0\\]-d\\\[0\\]\\n\\ \\ \\ \\ C=c\\\[0\\]-a\\\[0\\]\\n\\ \\ \\ \\ D=b\\\[1\\]-a\\\[1\\]\\n\\ \\ \\ \\ E=c\\\[1\\]-d\\\[1\\]\\n\\ \\ \\ \\ F=c\\\[1\\]-a\\\[1\\]\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #find\\ t\\ and\\ s\\ using\\ formula\\n\\ \\ \\ \\ t=(C*E-F*B)/(E*A-B*D)\\n\\ \\ \\ \\ s=(D*C-A*F)/(D*B-A*E)\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #accuracy\\n\\ \\ \\ \\ accuracy\\ =\\ \\ abs\\ (\\ (t*(b\\\[2\\]-a\\\[2\\])+s*(c\\\[2\\]-d\\\[2\\]))\\ -\\ (c\\\[2\\]-a\\\[2\\]))\\ \\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #find\\ intersection\\ point\\n\\ \\ \\ \\ pointx\\ =\\ a\\\[0\\]\\ +\\ t*(b\\\[0\\]-a\\\[0\\])\\n\\ \\ \\ \\ pointy\\ =\\ a\\\[1\\]\\ +\\ t*(b\\\[1\\]-a\\\[1\\])\\n\\ \\ \\ \\ pointz\\ =\\ a\\\[2\\]\\ +\\ t*(b\\\[2\\]-a\\\[2\\])\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ ret\\ =\\ pointz\\nexcept\\ ZeroDivisionError:\\n\\ \\ \\ \\ ret\\ =\\ 0]"}}
- addUserKnob {7 accuracy}
- accuracy {{"\[python -execlocal node\\ =\\ nuke.thisNode()\\na,b,c,d\\ =\\ node\\\['a'\\].value(),node\\\['b'\\].value(),node\\\['c'\\].value(),node\\\['d'\\].value()\\n\\ntry:\\n\\ \\ \\ \\ #constants\\ required\\ for\\ solving\\ t\\ and\\ s\\n\\ \\ \\ \\ A=b\\\[0\\]-a\\\[0\\]\\n\\ \\ \\ \\ B=c\\\[0\\]-d\\\[0\\]\\n\\ \\ \\ \\ C=c\\\[0\\]-a\\\[0\\]\\n\\ \\ \\ \\ D=b\\\[1\\]-a\\\[1\\]\\n\\ \\ \\ \\ E=c\\\[1\\]-d\\\[1\\]\\n\\ \\ \\ \\ F=c\\\[1\\]-a\\\[1\\]\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #find\\ t\\ and\\ s\\ using\\ formula\\n\\ \\ \\ \\ t=(C*E-F*B)/(E*A-B*D)\\n\\ \\ \\ \\ s=(D*C-A*F)/(D*B-A*E)\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #accuracy\\n\\ \\ \\ \\ accuracy\\ =\\ \\ abs\\ (\\ (t*(b\\\[2\\]-a\\\[2\\])+s*(c\\\[2\\]-d\\\[2\\]))\\ -\\ (c\\\[2\\]-a\\\[2\\]))\\ \\n\\ \\ \\ \\ \\n\\ \\ \\ \\ #find\\ intersection\\ point\\n\\ \\ \\ \\ pointx\\ =\\ a\\\[0\\]\\ +\\ t*(b\\\[0\\]-a\\\[0\\])\\n\\ \\ \\ \\ pointy\\ =\\ a\\\[1\\]\\ +\\ t*(b\\\[1\\]-a\\\[1\\])\\n\\ \\ \\ \\ pointz\\ =\\ a\\\[2\\]\\ +\\ t*(b\\\[2\\]-a\\\[2\\])\\n\\ \\ \\ \\ \\n\\ \\ \\ \\ ret\\ =\\ accuracy\\nexcept\\ ZeroDivisionError:\\n\\ \\ \\ \\ ret\\ =\\ 0\\n\\ \\ \\ \\ ]"}}
- }
- push $N1728b870
- Axis2 {
- translate {{"tan(radians(CameraMain.FOV*0.5)) * sceneScale * (Position1.u - Input.format.w/2)/(Input.format.w/2)"} {"tan(radians(CameraMain.FOV*0.5)) * sceneScale * (Position1.v - Input.format.h/2)/(Input.format.h/2) * Input.aspect"} {-sceneScale}}
- name Axis1
- label Position1
- xpos 146
- ypos 344
- }
- end_group
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement