Camera {
 projection_mode {{"\[value the_cam]projection_mode"}}
 focal {{"\[value \[value the_cam]focal]"}}
 haperture {{"\[value \[value the_cam]haperture]"}}
 vaperture {{"\[value \[value the_cam]vaperture]"}}
 near {{"\[value \[value the_cam]near]"}}
 far {{"\[value \[value the_cam]far]"}}
 win_translate {{"\[lindex \[value \[value the_cam]win_translate] 0]"} {"\[lindex \[value \[value the_cam]win_translate] 1]"}}
 win_scale {{"\[lindex \[value \[value the_cam]win_scale] 0]"} {"\[lindex \[value \[value the_cam]win_scale] 1]"}}
 winroll {{"\[value \[value the_cam]winroll]"}}
 focal_point {{"\[value \[value the_cam]focal_point]"}}
 fstop {{"\[value \[value the_cam]fstop]"}}
 name DummyCam
 help "DummyCam by Adrian Pueyo\n\nCamera that apart from the matrices also grabs all the \"Projection\" values from the upstream camera that it's connected to. Turns into a default Camera if not Camera connected.\n\nCan also be used inside of groups and gizmos, as many levels deep as you want :D\n\nAll using live and super fast TCL.\n\nadrianpueyo.com, 2019"
 onCreate "n = nuke.thisNode()\nfor k in \[\"projection_mode\",\"focal\",\"haperture\",\"vaperture\",\"near\",\"far\",\"win_translate\",\"win_scale\",\"winroll\",\"focal_point\",\"fstop\"]:\n    n\[k].setFlag(0x0000000010000000)"
 addUserKnob {20 DummyCam l Defaults}
 addUserKnob {43 the_cam +INVISIBLE}
 the_cam "\[\nset the_knob \"focal\"\nset knob_index 0\nset starting_point \"this.input0\"\nset default \"this\"\nset default \[append default \".d_\"]\n\n# If cam has no inputs, return the default...\nif \{\[exists \$starting_point]\} \{\n    set x \[node \$starting_point]\n\} \{ \n    return \$default\n\}\n\nset finished 0\nwhile \{\$finished != 1\} \{\n\n    # First look for a Cam or Input or topnode.\n    while \{\[class \$x] != \"Camera2\" && \[class \$x] != \"Camera\" && \[class \$x] != \"Input\" && \$x != \[topnode \$x]\} \{\n        set x \[node \$x.input0]\n    \}\n\n    # Then, check if node is a cam (and return), and otherwise, if it's an input, see if the parent exists and move to it.\n    if \{\[class \$x]==\"Camera2\"||\[class \$x]==\"Camera\"\} \{\n        set x \[append x \".\"]\n        return \$x\n    \} \{ \n        if \{\[class \$x]==\"Input\"\} \{ \n            set inp \"\$x.parent.input\"\n            set inputNum \[value \$x.number]\n            set inp \[append inp \$inputNum]\n            if \{\[exists \$inp]\} \{\n                set x \[node \$inp]\n            \} \{ \n                set finished 1\n            \}\n        \} \{ \n            set finished 1\n        \}\n    \}\n\}\nreturn \$default\n]"
 addUserKnob {4 d_projection_mode l projection M {perspective orthographic uv spherical ""}}
 addUserKnob {7 d_focal l focal R 0 100}
 d_focal 60
 addUserKnob {7 d_haperture l "horiz aperture" R 0 50}
 d_haperture 24.576
 addUserKnob {7 d_vaperture l "vert aperture" R 0 50}
 d_vaperture 18.672
 addUserKnob {7 d_near l near R 0 10}
 d_near 0.1
 addUserKnob {7 d_far l far R 0 10000}
 d_far 10000
 addUserKnob {12 d_win_translate l "window translate"}
 addUserKnob {12 d_win_scale l "window scale"}
 d_win_scale {1 1}
 addUserKnob {7 d_winroll l "window roll" R 0 45}
 addUserKnob {7 d_focal_point l "focal distance" R 0 10}
 d_focal_point 2
 addUserKnob {7 d_fstop l fstop R 0 30}
 d_fstop 16
 addUserKnob {26 text l " " T "<span style=\"color:#666\"><br/><b>DummyCam v1.0</b> - <a href=\"http://www.adrianpueyo.com\" style=\"color:#666;text-decoration: none;\">adrianpueyo.com</a>, 2019</span>"}
}
