i've been working on a script for that, though i havent had time to
test it out much, and i am still working on getting the field of view
in there. But this gets the translation and rotation. Just select your
exr reader and run the script...
oh, i've only tested on vray.
--------------
node = nuke.selectedNode()
print ("this is %s a test" % node.name())
import nuke
import math
def createPanel():
cp = nuke.Panel("create camera from exr ", 500)
result = cp.show()
if result == 1:
node = nuke.selectedNode()
basecam = nuke.createNode("Camera")
basecam['useMatrix'].setValue( True )
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[0]*-1}]" % node.name(),0)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[8]}]" % node.name(),1)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[4]}]" % node.name(),2)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[12]}]" % node.name(),3)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[1]*-1}]" % node.name(),4)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[9]*-1}]" % node.name(),5)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[5]}]" % node.name(),6)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[13]}]" % node.name(),7)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[2]*-1}]" % node.name(),8)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[10]}]" % node.name(),9)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[6]}]" % node.name(),10)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[14]}]" % node.name(),11)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[3]}]" % node.name(),12)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[11]}]" % node.name(),13)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[7]}]" % node.name(),14)
basecam['matrix'].setExpression("[python {nuke.toNode( '%s'
).metadata('exr/cameraTransform')[15]}]" % node.name(),15)
n = basecam
targetcam = nuke.createNode("Camera")
n2 = targetcam
n2['rotate'].setAnimated()
n2['translate'].setAnimated()
temp = nuke.nodes.CurveTool()
firstF = nuke.Root().firstFrame()
lastF = nuke.Root().lastFrame()
for fr in range(firstF, lastF+1):
nuke.frame(fr)
nuke.execute(temp, fr, fr)
mtx = nuke.math.Matrix4()
k =n['world_matrix']
# fill in the matrix object with values from the world_matrix knob
for y in range(k.height()):
for x in range(k.width()):
mtx[x+(y*k.width())] = k.value(x,y)
# And then your "ZXY" rotations would be
rotations = [math.degrees(x) for x in mtx.rotationsZXY()]
n2['rotate'].setValue(rotations)
n2['translate'].setValue([mtx[12], mtx[13], mtx[14]])
k2 =n2['translate']
k2.setFlag(nuke.KNOB_CHANGED_RECURSIVE)
k2.clearFlag(nuke.KNOB_CHANGED_RECURSIVE)
def mainfunc():
createPanel()
mainfunc()
------------------------------
On Fri, Apr 27, 2012 at 9:00 AM, Darren Coombes
<[email protected]> wrote:
> How can you read the camera data from the exr files?
>
>
> Darren Coombes
>
> Tel: +61 2 9520 3633
> Mob: +61 418 631 079
> Skype: darrencoombes
>
> iDisk: https://public.me.com/darren.coombes
>
> On 27/04/2012, at 4:14 PM, adam jones <[email protected]> wrote:
>
> I don't know if is the same for maya, but *.exr files rendered out of vray
> carry camera data. Chan files do have some short comings
>
> Sent from my iPhone
>
> On 27/04/2012, at 16:04, Darren Coombes <[email protected]>
> wrote:
>
> Hi, I have a maya scene file, which we have been using in after effects, but
> I want to try to use the camera from this in nuke.
>
> 1) is this possible?
> 2) if not, is .chan the best file to export from maya to nuke for importing
> cameras?
>
> Thanks.
> Darren.
>
> Darren Coombes
>
> Tel: +61 2 9520 3633
> Mob: +61 418 631 079
> Skype: darrencoombes
>
> iDisk: https://public.me.com/darren.coombes
>
> _______________________________________________
> 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
>
>
> _______________________________________________
> 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