# include SDV's TCL vector lib... set path [get3DEInstallPath] source $path/user_data/tcl_archive/veclib.tcl open3DEConsole set pg [getSelectedPGroup] if {$pg==0}\ { bell post3DEInfoRequester " \n Error, there is no Pointgroup selected. \n" return } set np [getNoPoints $pg] set name [getPGroupName $pg] if {$np==0}\ { bell post3DEInfoRequester " \n Error, there are no points in pointgroup $name.! \n" return } set fobj [getSelectedFobj] if {$fobj==0}\ { bell post3DEInfoRequester " \n Error, there is no sequence selected! \n" return } set camera [getFobjCamera $fobj] if {$camera==0}\ { bell post3DEInfoRequester " \n Error, the Sequence is not linked to a Camera! \n" return } set tcl_precision 17 set no_frames [getFobjNoFrames $fobj] set fobj_name [getFobjName $fobj] set width [getFobjImageWidth $fobj] set height [getFobjImageHeight $fobj] set cam_hor_angle [getCameraHorizAngle $camera] set aspect [getCameraPixelAspect $camera] set camera_name [getCameraName $camera] #set filename [post3DEFileRequester "Export Combustion workspace (CWS) file..." "*"] #if {$filename!=""}\ # { # if [string match *.cws $filename]\ # { # set file [open $filename w+] # } else\ # { # set file [open $filename.cws w+] # } set filename [post3DEFileRequester "Export Combustion workspace (CWS) file..." "*"] if {$filename!=""}\ { if {[string range $filename end end]=="\/"}\ { set filename "~\/3DE_comb_exp" set file [open 3DE_comb_exp.cws w+] } elseif [string match *.cws $filename]\ { set file [open $filename w+] } else\ { set file [open $filename.cws w+] } # Header puts $file "\/\/ 3DE's Combustion export" puts $file "" puts $file "ScriptInfo 1 0 1" puts $file "" puts $file "SetDefaultInterpolation 6" puts $file "" puts $file "NewOperator 0x6ed73e76 0x32505a4d 1 // Composite" puts $file "" puts $file "NewOperator 0x764521a0 0x2b271cba 2 // Footage" puts $file "" puts $file "SetCurrentOperator 1" puts $file " OperatorEnabled on" puts $file " SetOperatorName \"Composite\"" set fps [post3DEPromptRequester "Enter Frame Rate (fps):\n Default = 25 fps\n"] if {$fps==""}\ { set fps 25 print3DEConsole "\nFrame Rate is 25 fps!\n\n" } puts $file " CompositionSettings $width $height $aspect $fps $no_frames" puts $file "" puts $file " NewLayer 2" puts $file " SetName $name" puts $file " ObjectVisible on" puts $file " LayerTrim 0 0 -1" # Image plane z-pos for {set frame 1} {$frame<=$no_frames} {set frame [expr $frame+1]} \ { set zoom_factor [getFobjZoomFactor $fobj $frame] if {$frame==1}\ { puts $file " ResetChannel ~1/~3 [expr $zoom_factor*($aspect*(($width/2)/(tan($cam_hor_angle/2))))] on 0 0" puts -nonewline $file " SetChannelKeys ~1/~3 " } set i [expr $frame-1] puts -nonewline $file "$i [expr $zoom_factor*($aspect*(($width/2)/(tan($cam_hor_angle/2))))] " } puts $file "" puts $file " ResetChannel ~1/~56 1 off 0 0" puts $file " ResetChannel ~1/~57 1 off 0 0" puts $file " ResetChannel ~1/~58 1 off 0 0\n" # Point positions set i 2 for {set point [getFirstPoint $pg]} {$point!=0} {set point [getNextPoint $pg $point]} \ { if {[isPointCalculated3D $pg $point]} \ { set point_name [getPointName $pg $point] set point_pos_3d [getPointCalcPosition3D $pg $point] set x [lindex $point_pos_3d 0] set y [lindex $point_pos_3d 1] set z [lindex $point_pos_3d 2] set i [expr $i + 1] puts $file " NewNull $i" puts $file " SetName \"$point_name\"" puts $file " ObjectVisible on" puts $file " ResetChannel ~1/~1 $x on 0 0" puts $file " ResetChannel ~1/~2 $y on 0 0" puts $file " ResetChannel ~1/~3 [expr -$z] on 0 0" puts $file " ResetChannel ~1/~7 0.01 on 0 0" puts $file " ResetChannel ~1/~8 0.01 on 0 0" puts $file " ResetChannel ~1/~9 0.01 on 0 0\n" } } # Camera Position puts $file " NewCamera 1" set fobj_camera_id [getFobjCamera $fobj] set camera_name [getCameraName $fobj_camera_id] puts $file " SetName $camera_name" # x-pos for {set frame 1} {$frame<=$no_frames} {set frame [expr $frame+1]} \ { set cam_pos_3d [getPGroupPosition3D $pg $fobj $frame] set x_cam_pos_3d [lindex $cam_pos_3d 0] if {$frame==1}\ { puts $file " ResetChannel ~1/~1 $x_cam_pos_3d on 0 0" puts -nonewline $file " SetChannelKeys ~1/~1 " } set i [expr $frame-1] puts -nonewline $file "$i $x_cam_pos_3d " } puts $file "" # y-pos for {set frame 1} {$frame<=$no_frames} {set frame [expr $frame+1]} \ { set cam_pos_3d [getPGroupPosition3D $pg $fobj $frame] set y_cam_pos_3d [lindex $cam_pos_3d 1] if {$frame==1}\ { puts $file " ResetChannel ~1/~2 $y_cam_pos_3d on 0 0" puts -nonewline $file " SetChannelKeys ~1/~2 " } set i [expr $frame-1] puts -nonewline $file "$i $y_cam_pos_3d " } puts $file "" # z-pos for {set frame 1} {$frame<=$no_frames} {set frame [expr $frame+1]} \ { set cam_pos_3d [getPGroupPosition3D $pg $fobj $frame] set z_cam_pos_3d [lindex $cam_pos_3d 2] if {$frame==1}\ { puts $file " ResetChannel ~1/~3 [expr -$z_cam_pos_3d] on 0 0" puts -nonewline $file " SetChannelKeys ~1/~3 " } set i [expr $frame-1] puts -nonewline $file "$i [expr -$z_cam_pos_3d] " } puts $file "" # mat3rotangles poarameter (a; b; c) - a permutation of (0; 1; 2) set a 1 set b 0 set c 2 # y-rot for {set frame 1} {$frame<=$no_frames} {set frame [expr $frame+1]} \ { set mtx3d [getPGroupRotation3D $pg $fobj $frame] set rot_vec3d [mat3rotangles $mtx3d $a $b $c] set y_cam_rot_3d [lindex $rot_vec3d 0] if {$frame==1}\ { puts $file " ResetChannel ~1/~4 [expr -$y_cam_rot_3d] on 0 0" puts -nonewline $file " SetChannelKeys ~1/~4 " } set i [expr $frame-1] puts -nonewline $file "$i [expr -$y_cam_rot_3d] " } puts $file "" # x-rot for {set frame 1} {$frame<=$no_frames} {set frame [expr $frame+1]} \ { set mtx3d [getPGroupRotation3D $pg $fobj $frame] set rot_vec3d [mat3rotangles $mtx3d $a $b $c] set x_cam_rot_3d [lindex $rot_vec3d 1] if {$frame==1}\ { puts $file " ResetChannel ~1/~5 [expr -$x_cam_rot_3d] on 0 0" puts -nonewline $file " SetChannelKeys ~1/~5 " } set i [expr $frame-1] puts -nonewline $file "$i [expr -$x_cam_rot_3d] " } puts $file "" # z-rot for {set frame 1} {$frame<=$no_frames} {set frame [expr $frame+1]} \ { set mtx3d [getPGroupRotation3D $pg $fobj $frame] set rot_vec3d [mat3rotangles $mtx3d $a $b $c] set z_cam_rot_3d [lindex $rot_vec3d 2] if {$frame==1}\ { puts $file " ResetChannel ~1/~6 $z_cam_rot_3d on 0 0" puts -nonewline $file " SetChannelKeys ~1/~6 " } set i [expr $frame-1] puts -nonewline $file "$i $z_cam_rot_3d " } puts $file "" # camera - horizontal angle for {set frame 1} {$frame<=$no_frames} {set frame [expr $frame+1]} \ { set zoom_factor [getFobjZoomFactor $fobj $frame] set zoom [expr 2*(atan (tan ($cam_hor_angle/2)/$zoom_factor))] if {$frame==1}\ { puts $file " ResetChannel ~6/~2 $zoom on 0 0" puts -nonewline $file " SetChannelKeys ~6/~2 " } set i [expr $frame-1] puts -nonewline $file "$i $zoom " } puts $file "\n" # close & exit puts $file " SetCurrentObject 2" puts $file " Parent 1" puts $file "" puts $file "SetCurrentOperator 2" puts $file " OperatorEnabled on" puts $file " SetOperatorName \"footage\"" puts $file " SetCurrentClip 0" # set fobj_path [getFobjPath $fobj] # puts $file " Filename \/$fobj_path 1 0" puts $file " SolidLayer $width $height" puts $file " ResetChannel ~1 0 off 0 0" puts $file " ResetChannel ~13 25 off 0 0" puts $file " ResetChannel ~14 $aspect off 0 0" puts $file " ResetChannel ~18 0 off 0 0" puts $file " ResetChannel ~19 [expr $no_frames-1] off 0 0\n" puts $file "SetCurrentOperator 1" puts $file " MakeConnection 0 0\n" puts $file "SetCurrentOperator 2" puts $file " MakeConnection 1 2\n" puts $file "CurrentFrame 0" set start_end [getFobjSequenceAttr $fobj] puts -nonewline $file "PlayRange [lindex $start_end 0] [lindex $start_end 1]" # puts -nonewline $file "PlayRange 0 [expr $no_frames-1]" close $file if [string match *.cws $filename]\ { post3DEInfoRequester "\n Combustion data sucessfully written in file \n\n \"$filename\"\n" } else\ { post3DEInfoRequester "\n Combustion data sucessfully written in file \n\n \"$filename.cws\"\n" } }