-- ----------------------------------------------------------------------- -- MAXScript NukeToMax -- NukeToMax_v0.1.ms -- ----------------------------------------------------------------------- -- AUTHOR: Markus Boos -- CONTACT: relief@projectgemini.net -- COMPANY: project|gemini -- COPYRIGHT: 2010. All rights reserved. -- CREATION DATE: 2010-02-15 (YYYY-MM-DD) -- ----------------------------------------------------------------------- -- allows import of nuke camera .chan files (back) into max /* ------------------------ VERSION HISTORY ------------------------ Version 0.1 2010-02-15 - Markus Boos - relief7@projectgemini.net -main skeleton program for importing .chan files into max ------------------------ BUGS / KNOWN ISSUES ------------------------ -proper reading of camera parameter (fov, focal length, aperture) not yet supported */ ( -- open file dialog local strFile = getOpenFileName caption:"Import Animation" filename: "*.chan" types:"nuke chan file (*.chan)|*.chan" if ( strFile != undefined ) then ( try ( -- open file handle local fsIn = openFile strFile mode:"r" -- create new free camera local objCam = freeCamera name:"cam_chan_file" local ssLine while ( not( eof fsIn ) ) do ( -- read frame, position, rotation and fov values local f = readValue fsIn local fPosX = readValue fsIn local fPosY = readValue fsIn local fPosZ = readValue fsIn local fRotX = readValue fsIn local fRotY = readValue fsIn local fRotZ = readValue fsIn -- this is not working yet local fFOV = readValue fsIn -- set keyframes animate on ( at time f ( format "reading frame %...\n" f -- init zero rotation objCam.rotation = (quat 0 0 0 1) -- set rotation in coordsys local ( rotate objCam ( eulerangles fRotX fRotY fRotZ ) ) -- set position objCam.position = [ fPosX, fPosY, fPosZ ] -- post rotate transformation matrix by 90 degrees around x to convert from y-up to z-up -- rotateXMatrix 90 = ( matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0] ) --[ 1 0 0 ] --[ 0 0 -1 ] --[ 0 1 0 ] local mYToZUp = matrix3 [ 1, 0, 0 ] [ 0, 0, 1 ] [ 0, -1, 0 ] [ 0, 0, 0 ] objCam.transform = objCam.transform * mYToZUp ) ) ) ) catch ( errorMsg ( "Error reading file. \"" + strFile + "\"" ) ) ) )