Agree. Most of the snap3d functions could benefit from taking a format argument (and default to the root format if not specified). They could also use a context argument, so they can be evaluated for different frames/view.
And, while on the subject, if any changes are to be done to the snap3d module, please fix the return of snap3d.cameraProjectionMatrix() There should be a bug ID for it, but I can't find it anymore. I believe the problem is the order in which snap3d.cameraProjectionMatrix() multiplies all the matrices that produce the final camera matrix. As it is, the return is: s * t * p * m * camTransform --------- (NDC-to-pixels * offset-NDC-to-unit square * projection * win_scale & offset * camera transform) Whereas it should be: s * t * m * p * camTransform ------ (That is, win_scale & offset needs to be multiplied BEFORE the projection matrix instead of AFTER) You can check this by using either Frank's or Jose's examples with a camera that has window_translate values other than 0. Attached is a script that shows the problem, along with a modified version of that function that produces the desired output. Thanks, Ivan On Thu, Jul 19, 2012 at 10:53 AM, Jose Fernandez de Castro < [email protected]> wrote: > As a side note the problem with both alternate approaches that we showed > (which do the same thing) is that the snap 3d function does not take a > format argument, and only returns the values for the root format, so the > result is only correct for that format. Maybe we should put in a request > for the function to take in a format/resolution argument? > > > On Wed, Jul 18, 2012 at 10:12 PM, Jan Dubberke <[email protected]> wrote: > >> yeh thanks for that again: it works just fine. it does choke a wee bit in >> the gui every now and then but it totally does what I was aiming for. >> >> I also liked Jose's approach so thanks for that too - very creative! >> >> I guess I'll just wait for new releases then and hope it gets >> incorporated as a one stop solution? question mark >> >> cheers everyone >> >> >> >> >> that's what I did to work around this. Fairly rough and untested though: >>> >>> CheckerBoard2 { >>> inputs 0 >>> name CheckerBoard1 >>> selected true >>> xpos -148 >>> ypos -140 >>> } >>> Transform { >>> translate {{"\[python -execlocal cam\\ =\\ >>> nuke.toNode('Camera1')\\naxis\**\ =\\ nuke.toNode('Axis1')\\nwm\\ =\\ >>> axis\\\['world_matrix'\\].**valueAt(nuke.frame())\\nxform\**\ =\\ >>> nuke.math.Vector3(wm\\\[3\\],\**\ wm\\\[7\\],\\ wm\\\[11\\])\\nret\\ =\\ >>> nukescripts.snap3d.**projectPoint(cam,\\ xform).x]"} {"\[python >>> -execlocal cam\\ =\\ nuke.toNode('Camera1')\\naxis\**\ =\\ >>> nuke.toNode('Axis1')\\nwm\\ =\\ >>> axis\\\['world_matrix'\\].**valueAt(nuke.frame())\\nxform\**\ =\\ >>> nuke.math.Vector3(wm\\\[3\\],\**\ wm\\\[7\\],\\ wm\\\[11\\])\\nret\\ =\\ >>> nukescripts.snap3d.**projectPoint(cam,\\ xform).y]"}} >>> center {1024 778} >>> name Transform1 >>> selected true >>> xpos -148 >>> ypos -68 >>> } >>> Camera2 { >>> inputs 0 >>> name Camera1 >>> selected true >>> xpos -420 >>> ypos -70 >>> } >>> push $cut_paste_input >>> Axis2 { >>> rotate {0 -4 0} >>> name parentAxis >>> selected true >>> xpos -366 >>> ypos -323 >>> } >>> Axis2 { >>> translate {-0.392 -0.04399999976 -2.140000105} >>> name Axis1 >>> selected true >>> xpos -293 >>> ypos -238 >>> } >>> Scene { >>> name Scene1 >>> selected true >>> xpos -293 >>> ypos -129 >>> } >>> push 0 >>> ScanlineRender { >>> inputs 3 >>> output_motion_vectors_type accurate >>> name ScanlineRender1 >>> selected true >>> xpos -303 >>> ypos -16 >>> } >>> Merge2 { >>> inputs 2 >>> name Merge1 >>> selected true >>> xpos -148 >>> ypos -16 >>> } >>> >>> >>> >>> >>> >>> >>> >>> On 19/07/12 2:37 PM, Jose Fernandez de Castro wrote: >>> >>>> I'm wondering if anyone has used the snap3d.project points >>>> successfully to achieve this (I mean, if it's actually stable and >>>> usable). For starters it seems like it only takes the root format of the >>>> script, but it might be possible to cheat it through the win_scale u v. >>>> Anyway, just curious, an example setup: >>>> >>>> set cut_paste_input [stack 0] >>>> version 6.3 v8 >>>> Axis2 { >>>> inputs 0 >>>> translate {{curve i x1048 -1.396000028 x1088 -0.9840000272 x1108 >>>> -0.1986213923 x1119 0.3740000129} {curve i x1048 0.5559999943 x1088 >>>> 0.3759999871 x1102 0.41049599 x1108 0.4199999869 x1119 -0.5339999795} >>>> {curve i x1048 0 x1088 0 x1108 0 x1119 0}} >>>> name Axis3 >>>> selected true >>>> xpos 236 >>>> ypos 21 >>>> } >>>> push $cut_paste_input >>>> Camera2 { >>>> translate {{curve x1104 0} {curve x1080 0.3 x1104 0} {curve x1104 >>>> 7.050000191}} >>>> rotate {0 5 0} >>>> focal 13.5 >>>> name Camera3 >>>> selected true >>>> xpos -25 >>>> ypos 68 >>>> addUserKnob {20 ProjectFrame l "Project Frame"} >>>> addUserKnob {3 frameproj l "Projection Frame"} >>>> frameproj 1000 >>>> addUserKnob {6 currFrame l "Set to current frame" +STARTLINE} >>>> addUserKnob {22 setFrame l "Set Projection Frame" T >>>> "\nknoblist=\[]\nknoblistPre=\**[\"translate\",\"rotate\",\"** >>>> pivot\",\"scaling\",\"uniform_**scale\",\"skew\",\"focal\",\"** >>>> haperture\",\"vaperture\",\"**far\",\"near\",\"win_scale\",\** >>>> "win_translate\",\"winroll\",\**"focal_point\",\"fstop\"]\nfor name in >>>> knoblistPre:\n knoblist.append(name)\n knoblist.append(name+\"_r\")\n >>>> knoblist.append(name+\"_l\")\n \ntry:\n nuke.thisNode().knob(\"read_ >>>> **from_file\").setValue(False)\**nexcept(AttributeError):\n >>>> pass\nanimation=False\n\nfor i in knoblist:\n >>>> knob=nuke.thisNode().knob(i)\n if knob:\n if >>>> knob.hasExpression():\n animation=True\n >>>> newexpression=knob.toScript().**split(\"\{\")\[1].split(\"\}\"**)\[0]\n >>>> if \"(frameproj)\" not in newexpression:\n >>>> knob.setExpression(\"%s(**frameproj)\"%(newexpression))\**n \n >>>> elif knob.isAnimated():\n print \"this ran\"\n >>>> animation=True\n knob.setExpression(\"curve(**frameproj)\")\n\n\nif >>>> nuke.thisNode().knob(\"**currFrame\").value():\n >>>> nuke.thisNode().knob(\"**frameproj\").setValue(nuke.**frame())\nif >>>> animation==True:\n >>>> previouslabel=nuke.thisNode().**knob(\"label\").value()\n >>>> previouslabel=previouslabel.**replace(\"\\nProjection frame: \[value >>>> frameproj]\",\"\")\n newlabel=previouslabel+\"\\**nProjection frame: >>>> \[value frameproj]\"\n >>>> nuke.thisNode().knob(\"label\"**).setValue(newlabel)\n" >>>> +STARTLINE} >>>> addUserKnob {22 unsetFrame l "Unset Projection Frame" T >>>> "\nknoblist=\[]\nknoblistPre=\**[\"translate\",\"rotate\",\"** >>>> pivot\",\"scaling\",\"uniform_**scale\",\"skew\",\"focal\",\"** >>>> haperture\",\"vaperture\",\"**far\",\"near\",\"win_scale\",\** >>>> "win_translate\",\"winroll\",\**"focal_point\",\"fstop\"]\nfor name in >>>> knoblistPre:\n knoblist.append(name)\n knoblist.append(name+\"_r\")\n >>>> knoblist.append(name+\"_l\")\**nfor i in knoblist:\n >>>> knob=nuke.thisNode().knob(i)\n if knob:\n if >>>> knob.hasExpression():\n newexpression=knob.toScript().** >>>> split(\"\{\")\[1].split(\"\}\"**)\[0].replace(\"(frameproj)\",**\"\")\n >>>> if \"curve\" in newexpression:\n knob.setExpression(\"curve\")\ >>>> **n else:\n knob.setExpression(**newexpression)\n\n\* >>>> *npreviouslabel= nuke.thisNode().knob(\"label\"** >>>> ).value()\npreviouslabel=**previouslabel.replace(\"\\**nProjection >>>> frame: \[value >>>> frameproj]\",\"\")\nnuke.**thisNode().knob(\"label\").**setValue(previouslabel)\n" >>>> +STARTLINE} >>>> } >>>> set Ne20aad70 [stack 0] >>>> Scene { >>>> inputs 2 >>>> name Scene3 >>>> selected true >>>> xpos 236 >>>> ypos 249 >>>> } >>>> push $Ne20aad70 >>>> CheckerBoard2 { >>>> inputs 0 >>>> format "1920 1080 0 0 1920 1080 1 HD" >>>> name CheckerBoard3 >>>> selected true >>>> xpos -175 >>>> ypos 10 >>>> } >>>> Group { >>>> inputs 2 >>>> name project_point2 >>>> selected true >>>> xpos -109 >>>> ypos 310 >>>> addUserKnob {20 User} >>>> addUserKnob {13 point3d} >>>> point3d {{parent.Axis3.translate.left} {parent.Axis3.translate.left} >>>> {parent.Axis3.translate.left}} >>>> addUserKnob {12 point2d} >>>> point2d {{"\[python -execlocal n=nuke.thisNode()\\nret=** >>>> nukescripts.snap3d.**projectPoint(camera=n.input(1)** >>>> ,point=(n\\\[\\\"point3d\\\"\\**].value(0),n\\\[\\\"point3d\\\** >>>> "\\].value(1),n\\\[\\\"**point3d\\\"\\].value(2)))\\\[**0\\]]" x1048 >>>> 1400} {"\[python -execlocal n=nuke.thisNode()\\nret=** >>>> nukescripts.snap3d.**projectPoint(camera=n.input(1)** >>>> ,point=(n\\\[\\\"point3d\\\"\\**].value(0),n\\\[\\\"point3d\\\** >>>> "\\].value(1),n\\\[\\\"**point3d\\\"\\].value(2)))\\\[**1\\]]" x1048 >>>> 698}} >>>> } >>>> Input { >>>> inputs 0 >>>> name IMAGE >>>> xpos -50 >>>> ypos -94 >>>> } >>>> Output { >>>> name Output1 >>>> xpos -50 >>>> ypos 10 >>>> } >>>> Input { >>>> inputs 0 >>>> name CAMERA >>>> selected true >>>> xpos 145 >>>> ypos -111 >>>> number 1 >>>> } >>>> end_group >>>> >>>> >>>> >>>> ______________________________**_________________ >>>> Nuke-users mailing list >>>> [email protected].**co.uk<[email protected]>, >>>> http://forums.thefoundry.co.**uk/ <http://forums.thefoundry.co.uk/> >>>> http://support.thefoundry.co.**uk/cgi-bin/mailman/listinfo/**nuke-users<http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users> >>>> >>> >> >> ______________________________**_________________ >> Nuke-users mailing list >> [email protected].**co.uk<[email protected]>, >> http://forums.thefoundry.co.**uk/ <http://forums.thefoundry.co.uk/> >> http://support.thefoundry.co.**uk/cgi-bin/mailman/listinfo/**nuke-users<http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users> >> > > > > -- > Jose Fernandez de Castro > > _______________________________________________ > Nuke-users mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users >
snap3d_cameraProjectionMatrix_bug2.nk
Description: Binary data
_______________________________________________ Nuke-users mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
