I don't know if this is any help, but this is something I knocked together
a while back that decomposes rotation values on-the-fly from an Axis/Camera
world_matrix knob. It's python code defining a function that's been stuffed
into the expression field of a custom knob (called "DEF_FUNCTION"), and
then that function is being accessed by a custom 3d position knob
("matrixRotnRad") to return the matrix rotation value in radians. This is
then being converted to degrees in the "matrixRotnDeg" knob, using a
regular Nuke expression. You'll find that if you edit the regular rotation
knob of this node that the values as defined in the matrix will be
interpreted by the Python function and round-trip back to the same values
in the "matrixRotnDeg" knob.

I actually just stole the code from snippets that are in Ivan Busquet's
great nuke.math tutorial on Nukepedia, and based on those examples showing
how the nuke.math "decompose matrix" functions work, you could extrapolate
how to add in translation and scale knobs. This "live" method, as opposed
to scripted python, isn't necessarily the best way to do it, but it's an
interesting test.

Here's that Axis node pasted for your reference:

set cut_paste_input [stack 0]
version 6.3 v8
push $cut_paste_input
Axis2 {
 rotate {3 4 5}
 name Axis2
 selected true
 xpos -132
 ypos -161
 addUserKnob {20 User}
 addUserKnob {3 DEF_FUNCTION}
 DEF_FUNCTION {{"\[python -execlocal import\\ math\\n\\nglobal\\
getMatrixRotn\\n\\nn=nuke.thisNode()\\n\\ndef\\ getMatrixRotn(n):\\n\\n\\
\\ \\ \\ k\\ =\\ n\\\['world_matrix'\\]\\n\\ \\ \\ \\ m\\ =\\
nuke.math.Matrix4()\\n\\n\\ \\ \\ \\ for\\ y\\ in\\ range(k.height()):\\n\\
\\ \\ \\ \\ \\ \\ \\ for\\ x\\ in\\ range(k.width()):\\n\\ \\ \\ \\ \\ \\
\\ \\ \\ \\ \\ \\ m\\\[x+(y*k.width())\\]\\ =\\ k.value(x,y)\\n\\n\\ \\ \\
\\ rotM\\ =\\ nuke.math.Matrix4(m)\\n\\ \\ \\ \\ rotM.rotationOnly()\\n\\
\\ \\ \\ \\n\\ \\ \\ \\ rot\\ =\\ rotM.rotationsZXY()\\n\\n\\ \\ \\ \\
return\\ rot\\n\\nret=0\\n]"}}
 addUserKnob {13 matrixRotn l matrixRotnRad}
 matrixRotn {{"\[python getMatrixRotn(nuke.thisNode())\\\[0\\]]"}
{"\[python getMatrixRotn(nuke.thisNode())\\\[1\\]]"} {"\[python
getMatrixRotn(nuke.thisNode())\\\[2\\]]"}}
 addUserKnob {13 matrixRotnDeg}
 matrixRotnDeg {{degrees(matrixRotn)} {degrees(matrixRotn)}
{degrees(matrixRotn)}}
}




On 3 August 2012 05:53, David Harter <[email protected]> wrote:

> Hey everybody,
>
> I am having a Little Problem here: i want Export a Chan file of an
> animated nuke Camera, but the Animation Data is stored in the Matrix knob
> and therefore i can't Export the chan file! I would need to convert the
> data from the matrix knob back into the translation, rotation, scale
> knobs!Does anyone have a little Python Script for that?
>
> Much appreciated,
> David_______________________________________________
> Nuke-users mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

Reply via email to