/*************************** Coded by Am!t, Released Jan 30th 2006 Cam2Vista-1.2 Webpage:http://vistools.npaci.edu/VISTA/cam2vista.htm Bug-report to amit@sdsc.edu ***************************/ global proc warnFeedback_c2v(string $message) { $col=(0.65 +`rand 0.2`); string $showMessage="Warning: " + $message; print ("C2V_" + $showMessage + "\n"); text -e -vis 0 feedback_general; text -e -w 200 -al "center" -vis 1 -bgc 0.6 $col 0.6 -l $showMessage feedback_general; } global proc errorFeedback_c2v(string $message) { $col=(0.8 +`rand 0.2`); string $showMessage="Error: " + $message; print ("C2V_" + $showMessage + "\n"); text -e -vis 0 feedback_general; text -e -w 200 -al "center" -vis 1 -bgc $col 0.6 0.6 -l $showMessage feedback_general; } global proc sucessFeedback_c2v(string $message) { $col=(0.65 +`rand 0.2`); string $showMessage="Sucess: " + $message; print ("C2V_" + $showMessage + "\n"); text -e -vis 0 feedback_general; text -e -w 200 -al "center" -vis 1 -bgc 0.6 0.6 $col -l $showMessage feedback_general; } global proc int vista_cam1_Exists_c2v() { string $test[]=`ls vista_cam1`; if(size($test)==0) { errorFeedback_c2v("\"vista_cam1\" camera not found\nNothing to process"); return 0; } return 1; } global proc openHelpPage_c2v() { string $url="http://vistools.npaci.edu/VISTA/cam2vista.htm"; showHelp -a $url; } global proc openAbout_c2v() { if(`window -exists aboutCam2VistaWindow`) deleteUI aboutCam2VistaWindow; if(!`window -exists aboutCam2VistaWindow`) { window -title "Cam2Vista-1.2" -resizeToFitChildren true aboutCam2VistaWindow; //Create layout columnLayout "aboutCam2Vista_layout"; text -w 200 -l "\nCam2Vista-1.2, Jan 30th 2006\nImplemented by Am!t"; text -w 200 -l "\nVisualization Services\nSan Diego Supercomputer Center"; text -w 200 -l "\nSend bug-report to amit@sdsc.edu\n"; } showWindow aboutCam2VistaWindow; } global proc importCamFile_c2v(string $fileName) { //Open the file as read only (Camera file) //$fileName = "c://123.cam" ; $fileId=`fopen $fileName "r"`; //Check if meshviewer_cam1 exits then delete it $test=`ls meshviewer_cam1`; if(size($test)==1) delete meshviewer_cam1; //now create the camera camera -n "meshviewer_cam" -p 0.0 0.0 1.0 ; viewPlace -p -fov 45.0 meshviewer_camShape2; //Set FOV =45 setAttr "meshviewer_cam1.sx" 0.3; setAttr "meshviewer_cam1.sy" 0.3; setAttr "meshviewer_cam1.sz" 0.3; //Start counting time int $t=1; string $nextWord[]; //for temp tokenization float $master[16];//array for holding the vertices // Now read Camera file one line at a time $nextLine=`fgetline $fileId`; while ( size($nextLine)>0 ) { tokenize $nextLine $nextWord; //Process lines only if it has a camera matrix if($nextWord[0] == "CameraMatrix:") { $master[0]= $nextWord[1]; $master[1]= $nextWord[2]; $master[2]= $nextWord[3]; $master[3]= $nextWord[4]; $master[4]= $nextWord[5]; $master[5]= $nextWord[6]; $master[6]= $nextWord[7]; $master[7]= $nextWord[8]; $master[8]= $nextWord[9]; $master[9]= $nextWord[10]; $master[10]= $nextWord[11]; $master[11]= $nextWord[12]; $master[12]= $nextWord[13]; $master[13]= $nextWord[14]; $master[14]= $nextWord[15]; $master[15]= $nextWord[16]; currentTime $t; select -r meshviewer_cam1; xform -ws -m $master[0] $master[1] $master[2] $master[3] $master[4] $master[5] $master[6] $master[7] $master[8] $master[9] $master[10] $master[11] $master[12] $master[13] $master[14] $master[15] meshviewer_cam1; setKeyframe; clear $master; clear $nextWord; select -cl; $t++; //increment time } //loop increments $nextLine=`fgetline $fileId`; } //End while "nextLine" fclose $fileId; //coordinate file print "\nCamera file imported\n"; print "\nCamera Created\n"; //print ("t=" + $t + "\n"); //Check if camCurve exits then delete it $test=`ls camCurve`; if(size($test)==1) delete camCurve; float $x[],$y[],$z[]; $x[0]=$y[0]=$z[0]=-1.0; //Make sure the array would be float int $i=1; while($i<$t) { currentTime $i; select -r meshviewer_cam1; float $xyz[]=`getAttr meshviewer_cam1.t`; $x[$i]=$xyz[0]; $y[$i]=$xyz[1]; $z[$i]=$xyz[2]; //create the cv's for the curve if($i==1) curve -n "camCurve" -ws -d 1 -p $xyz[0] $xyz[1] $xyz[2] ; else curve -a -ws -p $xyz[0] $xyz[1] $xyz[2] camCurve; $i++; } /* int $k=1; if($t>2 && $t<4) //Linear curve { curve -n "camCurve" -ws -d 1 -p $x[1] $y[1] $z[1] -p $x[2] $y[2] $z[2] ; } $k=3; if($t>3 && $t<5) //Quadratic curve { while($k<$t) { if($k==3) curve -n "camCurve" -ws -d 2 -p $x[1] $y[1] $z[1] -p $x[2] $y[2] $z[2] -p $x[3] $y[3] $z[3]; else curve -a -ws -d 1 -p $x[$k] $y[$k] $z[$k] camCurve ; $k++; } } $k=4; if($t>=5) //Cubic curve { while($k<$t) { if($k==4) curve -n "camCurve" -ws -d 3 -p $x[1] $y[1] $z[1] -p $x[2] $y[2] $z[2] -p $x[3] $y[3] $z[3] -p $x[4] $y[4] $z[4]; else curve -a -ws -d 1 -p $x[$k] $y[$k] $z[$k] camCurve ; $k++; } } */ //print ("i=" + $i + "\n"); print "\nCamera Path Created\n"; select -cl; } global proc drawTestSpiral_c2v() { //Check if cam2vista_test_spiral exits then delete it string $test[]=`ls cam2vista_test_spiral`; if(size($test)==1) delete cam2vista_test_spiral; int $i; for ( $i=0; $i<760; $i++ ) { float $temp=$i; float $k=0.9*$i/180;//1 - (360-$i)/360; float $rad=deg_to_rad($i); float $s=$k*sin($rad); float $c=$k*cos(deg_to_rad($i)); //float $h=$temp/360/3; float $h=$temp/1080; //create the cv's for the curve if($i==0)curve -n "cam2vista_test_spiral" -p $s $h $c ; else curve -a -p $s $h $c cam2vista_test_spiral; } sucessFeedback_c2v("Test Spiral Created:\nName \"cam2vista_test_spiral\""); } global proc createCam_c2v() { int $dome_mode= `radioButtonGrp -q -select camMode`; if($dome_mode==1)//Single Camera {//Check if vista_cam1 exits then delete it string $test[]=`ls vista_cam1`; if(size($test)==1) delete vista_cam1; //now create the camera camera -n "vista_cam" -p 0.0 0.0 1.0 ; setAttr "vista_cam1.sx" 0.3; setAttr "vista_cam1.sy" 0.3; setAttr "vista_cam1.sz" 0.3; sucessFeedback_c2v("Camera Created:\nName \"vista_cam1\""); } else // 5 Cameras Dome setup {//Check if vista_cam1 exits then delete parent string $test[]=`ls vista_cam1`; if(size($test)==1) delete vista_cam1; camera -n "vista_cam" -p 0.0 0.0 0.0 -rot 90 0 0; camera -n "vista_camRight" -p 0.0 0.0 0.0 -rot 0 -90 0; camera -n "vista_camLeft" -p 0.0 0.0 0.0 -rot 0 90 0; camera -n "vista_camFront" -p 0.0 0.0 0.0 -rot 0 0 0; camera -n "vista_camBack" -p 0.0 0.0 0.0 -rot 0 180 0; //Parent them under vista_cam1 parent vista_camFront1 vista_camBack1 vista_camLeft1 vista_camRight1 vista_cam1; } //Set FOV setFOV_c2v(); select -cl; sucessFeedback_c2v("Camera Created:\nName \"vista_cam1\""); } global proc cam2VistaScale_c2v() { float $s=`floatSlider -q -v camScaleSlider`; setAttr "vista_cam1.sx" $s; setAttr "vista_cam1.sy" $s; setAttr "vista_cam1.sz" $s; //if the locator exists scale that too string $test[]=`ls cam_aim_locator`; if(size($test)==1) {setAttr "cam_aim_locator.sx" $s;setAttr "cam_aim_locator.sy" $s;setAttr "cam_aim_locator.sz" $s;} } global proc setCameraAim_c2v(int $i) { //Set aim only when camera exists string $test[]=`ls vista_cam1`; if(size($test)==1) { currentTime $i; int $look=`radioButtonGrp -q -select lookflag`; //Default look at for camera is always normal to curve so change it as required for getting the correct matrix //Note: Even though we change lookat point but in Maya the camera will go back to default except for last frame set //An expression is running to correct this problm when previewing //Looking at a point if($look==1) { float $a[]=`floatFieldGrp -q -v lookatpoint_floatfieldgrp`; float $p[]=`getAttr "vista_cam1.t"`; //If position and aim are not same points change aim if( !( ($a[0]==$p[0])&&($a[0]==$p[1])&&($a[0]==$p[2]) ) ) viewLookAt -pos $a[0] $a[1] $a[2] vista_camShape2; else print "Warning:Camera position and look at point are same\n"; } //If $look==2 Camera is aiming as Set in Keyframe, So nothing needs to be done here //If $look=3 then camera is looking normal to the path nothing needs to be set here as this is the default behaviour //Looking at the camera aim path if($look==4) { $test=`ls cam_aim_locator`; if (size($test)==1) { float $lx=`getAttr "cam_aim_locator.tx"`; float $ly=`getAttr "cam_aim_locator.ty"`; float $lz=`getAttr "cam_aim_locator.tz"`; float $p[]=`getAttr "vista_cam1.t"`; //If position and aim are not same points change aim if( !( ($lx==$p[0])&&($ly==$p[1])&&($lz==$p[2]) ) ) viewLookAt -pos $lx $ly $lz vista_camShape2; else print "Warning:Camera position and look at point are same\n"; } //else print "Defaulting: No Camera Aim Path found\nUsing normal to path as aim direction\n"; } } } global proc string setFOV_c2v() { float $fov=`floatFieldGrp -q -v1 fov_floatfieldgrp`; float $aspect=`floatFieldGrp -q -v2 fov_floatfieldgrp`; //Sanity checks if( ($fov<=0)||($fov>180) ) { warnFeedback_c2v("FOV should be >0 & <180\nDefaulting to FOV=45.0"); floatFieldGrp -e -v1 45.0 fov_floatfieldgrp; $fov=45.0; } if($fov==180.0) { warnFeedback_c2v("FOV converted\nto FOV=179.9999"); floatFieldGrp -e -v1 179.9999 fov_floatfieldgrp; $fov=179.9999; } if($aspect==0) { warnFeedback_c2v("Aspect cannot be 0.0\nDefaulting to 1.33333333"); floatFieldGrp -e -v2 1.33333333 fov_floatfieldgrp; $aspect=1.33333333; } float $nearclip=0.1; float $l= -1.0*(tand($fov/2)) * $nearclip; float $r= (tand($fov/2)) * $nearclip; float $t= $r/$aspect; float $b= $l/$aspect; //Set Aperture //setAttr "vista_camShape2.horizontalFilmAperture" ($r*2.0); //setAttr "vista_camShape2.verticalFilmAperture" ($t*2.0); //Set FOV int $dome_mode= `radioButtonGrp -q -select camMode`; if($dome_mode==1) viewPlace -p -fov $fov vista_camShape2; else {viewPlace -p -fov $fov vista_camShape2; viewPlace -p -fov $fov vista_camFront1; viewPlace -p -fov $fov vista_camBack1; viewPlace -p -fov $fov vista_camLeft1; viewPlace -p -fov $fov vista_camRight1; } print ("FOV: " + $fov +"\n"); print ("Aspect Ratio =" + $aspect +"\n"); string $cw=("CameraWindow: " + $l + " " + $r + " " + $t + " " + $b +"\n"); print $cw; return $cw; } global proc selectPathCurve_c2v(string $curveName) { select -cl; select -r "vista_cam1"; select -tgl $curveName; } global proc attach2MotionPath_c2v(int $noOfFrames, string $name) { playbackOptions -e -minTime 0; playbackOptions -e -maxTime ($noOfFrames-1); pathAnimation -n $name -fractionMode true -follow true -followAxis x -upAxis y -worldUpType "vector" -worldUpVector 0 1 0 -inverseUp false -inverseFront false -bank false -startTimeU `playbackOptions -query -minTime` -endTimeU `playbackOptions -query -maxTime`; } global proc aimTrigger_c2v() { string $sel[]=`ls -sl`; if(size($sel)== 0) { errorFeedback_c2v("Nothing Selected.\n Please select only one AIM CURVE"); } if(size($sel) > 1) { select -cl; errorFeedback_c2v("More than one curve selected.\n Please select only one AIM CURVE"); } string $selection=$sel[0]; if(size($sel)== 1) { select -cl; //Make sure the locator does not exist string $test[]=`ls cam_aim_locator`; if(size($test)==1) delete cam_aim_locator; //Now create the Locator spaceLocator -n cam_aim_locator; setAttr "cam_aim_locator.sx" 0.3; setAttr "cam_aim_locator.sy" 0.3; setAttr "cam_aim_locator.sz" 0.3; select -tgl $selection; int $noOfFrames=`intField -q -value framenos`; attach2MotionPath_c2v($noOfFrames,"vista_cam_aim_path"); sucessFeedback_c2v("Camera AIM attached\nto selected curve"); //Change aim selection to chosen path if it was looking at a point int $look=`radioButtonGrp -q -select lookflag`; if ($look==1) {radioButtonGrp -e -select 3 lookflag;} } select -cl; } global proc pathTrigger_c2v() { string $sel[]=`ls -sl`; if(size($sel)== 0) {errorFeedback_c2v("Nothing Selected. Please select\nonly one MOTION PATH CURVE"); } if(size($sel) > 1) {select -cl;errorFeedback_c2v("More than one selected. Please select\nonly one MOTION PATH CURVE"); } string $selection=$sel[0]; if(size($sel)== 1) { createCam_c2v(); selectPathCurve_c2v($selection); int $noOfFrames=`intField -q -value framenos`; attach2MotionPath_c2v($noOfFrames,"vista_cam_motion_path"); sucessFeedback_c2v("Camera MOTIONPATH attached\nto selected curve"); } } global proc reApply_c2v() { string $campath; int $nof=`intField -q -value framenos`; playbackOptions -e -minTime 0; playbackOptions -e -maxTime ($nof-1); print ("Total no of frames =" + $nof + "\n"); //Check for camera motion path existence and if so reApply_c2v string $test[]=`ls -type motionPath vista_cam_motion_path`; if(size($test)==1) {//Find what is the motion path attached to camera select -r "vista_cam1"; $campath=`pathAnimation -q -c vista_cam1`; //Select the camera motion path curve select -r $campath; pathTrigger_c2v(); //apply motion path } else print "No existing camera motion path found\nUse keyframed path if checked\n"; //Check for camera aim path existence and if so reApply_c2v $test=`ls -type motionPath vista_cam_aim_path`; if(size($test)==1) {//Find what is the aim path attached to locator select -r cam_aim_locator; $aimpath=`pathAnimation -q -c cam_aim_locator`; //Select the camera aim path curve select -r $aimpath; aimTrigger_c2v(); } else print "No existing camera aim path found\nUse keyframed camera aim if checked\n"; sucessFeedback_c2v("Total frame=" + $nof + "\nFrom 0 to " + ($nof-1) + " (Start&end are inclusive)"); } global proc int importCam_c2v( string $fileName, string $fileType ) { importCamFile_c2v($fileName); return 1; } global proc int saveCam_c2v( string $fileName, string $fileType ) { int $noOfFrames=`playbackOptions -q -maxTime`; //Sanity check for file exsistence if(!`gmatch $fileName "*.cam"`) {//Append ".cam" to filename entry only when not typed in $fileName=$fileName + ".cam"; //Ask for confirm overwrite when file exists int $exist=`filetest -f $fileName`; if($exist) { string $q=`confirmDialog -title "Confirm" -message "Replace existing file?" -button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`; if($q!="Yes") return 0; //Return if chosen no or dismissed dailog box } } return writeCamFile_c2v($fileName, $noOfFrames, 0); } global proc int saveRevCam_c2v( string $fileName, string $fileType ) { int $noOfFrames=`playbackOptions -q -maxTime`; if(!`gmatch $fileName "*.cam"`) {//Append ".cam" to filename entry only when not typed in $fileName=$fileName + ".cam"; //Ask for confirm overwrite when file exists int $exist=`filetest -f $fileName`; if($exist) { string $q=`confirmDialog -title "Confirm" -message "Replace existing file?" -button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`; if($q!="Yes") return 0; //Return if chosen no or dismissed dailog box } } return writeCamFile_c2v($fileName, $noOfFrames, 1); } global proc int writeCamFile_c2v(string $fileName, int $noOfFrames, int $rev) {//If no motion path or aim path then just write one line string $test[]=`ls -type "motionPath"`; int $flag=0; int $look=`radioButtonGrp -q -select lookflag`; int $keyframedflag=`checkBox -q -v keyframedcam`; //If using keyframed camera write all frames if( $keyframedflag==1 ) $flag=1; for($item in $test) {//If only motion path exists and camera looking anywhere write all frames if ($item=="vista_cam_motion_path") $flag=1; //If only aimpath exists and camera is looking to aimpath write all frames if ( ($item=="vista_cam_aim_path")&&($look==4) ) $flag=1; } //If no path or aim path then just write one line if( $flag==0) $noOfFrames=0; int $dome_mode= `radioButtonGrp -q -select camMode`; float $fov=`floatFieldGrp -q -v1 fov_floatfieldgrp`; float $aspect=`floatFieldGrp -q -v2 fov_floatfieldgrp`; float $clipingplanes[]=`viewClipPlane -q -acp vista_camShape2`; string $cam_window =setFOV_c2v(); string $camlist[]={"vista_cam1", "vista_camFront1", "vista_camBack1", "vista_camLeft1", "vista_camRight1"}; int $ple=`checkBox -q -v mayaple`; //Create the camera file and write to it if not using Maya PLE if($ple==0) $fileId=`fopen $fileName "w"`; //If file open fails provide error feedback to user if($ple==0) { if ($fileId==0) {errorFeedback_c2v("File could not be opened for writing"); return 0; } //Start Writing to file fprint $fileId "#Created by Cam2Vista \n"; if($dome_mode==2) { fprint $fileId ("# FOV = " + $fov + " \n"); fprint $fileId "#Camera order is: Up, Front, Back, Left, Right \n"; } else fprint $fileId ("# FOV = " + $fov +" \n"); //fprint $fileId ("# Aspect Ratio = " + $aspect +" \n"); fprint $fileId $cam_window; //fprint $fileId "CameraWindow: -0.0414 0.0414 0.03105 -0.03105\n"; fprint $fileId ("CameraClipping: 0.1 0.2 " + $clipingplanes[1] + "\n"); } //From start frame to end frame if($rev==0) {int $i; print ("nof=" + ($noOfFrames + 1) +"\n"); //int $ple=`checkBox -q -v mayaple`; print ("PLE is " + $ple); for ($i=0; $i<=$noOfFrames; $i++ ) { setCameraAim_c2v($i);//This is also set by expression running in backgroud but cannot be used here int $dome_mode= `radioButtonGrp -q -select camMode`; if($dome_mode==1) //Single Camera {//Grab the camera matrix float $a1[]=`xform -q -ws -m vista_cam1`; //Format the camera matrix for printing string $t=" "; string $j; for($j in $a1) {$t = $t + $j + " "; } //Dont print more than n lines if(($i<15) && ($ple==0) ) {print "CameraMatrix: "; print ( $t + "\n"); } if ($ple==1) {print "CameraMatrix: "; print ( $t + "\n"); } //write camera matrix to file for each frame if($ple==0) { fprint $fileId "CameraMatrix: "; if($i==$noOfFrames) fprint $fileId ( $t); //no new line when writing last line else fprint $fileId ( $t + "\n"); } } else // 5 Camera dome mode { for($item in $camlist) {//Grab the camera matrix float $a1[]=`xform -q -ws -m $item`; //Format the camera matrix for printing string $t=" "; string $j; for($j in $a1) {$t = $t + $j + " "; } //Dont print more than n lines if ( ($i<3)&&( $ple==0) ) {print "DomeCameraMatrix: "; print ( $t + "\n"); } if ($ple==1) {print "CameraMatrix: "; print ( $t + "\n"); } //write camera matrix to file for each frame if($ple==0) { fprint $fileId "CameraMatrix: "; if( ($i== $noOfFrames)&&($item=="vista_camRight1") ) fprint $fileId ( $t); //no new line when writing last line else fprint $fileId ( $t + "\n"); } } } } sucessFeedback_c2v("Camera File Saved"); } else //From end frame to start frame {int $i; print ("Rev nof=" + ($noOfFrames + 1) +"\n"); for ($i=($noOfFrames); $i>=0; $i-- ) { setCameraAim_c2v($i);//This is also set by expression running in backgroud but cannot be used here int $dome_mode= `radioButtonGrp -q -select camMode`; if($dome_mode==1) //Single Camera {//Grab the camera matrix float $a1[]=`xform -q -ws -m vista_cam1`; //Format the camera matrix for printing string $t=" "; string $j; for($j in $a1) {$t = $t + $j + " "; } //Dont print more than n lines if(($i<15) && ($ple==0) ) {print "CameraMatrix: "; print ( $t + "\n"); } if ($ple==1) {print "CameraMatrix: "; print ( $t + "\n"); } //write camera matrix to file for each frame if($ple==0) { fprint $fileId "CameraMatrix: "; if($i==0) fprint $fileId ($t); //no new line when writing last line else fprint $fileId ( $t + "\n"); } } else // 5 Camera dome mode { for($item in $camlist) {//Grab the camera matrix float $a1[]=`xform -q -ws -m $item`; //Format the camera matrix for printing string $t=" "; string $j; for($j in $a1) {$t = $t + $j + " "; } //Dont print more than n lines if ( ($i<3)&&( $ple==0) ) {print "DomeCameraMatrix: "; print ( $t + "\n"); } if ($ple==1) {print "CameraMatrix: "; print ( $t + "\n"); } //write camera matrix to file for each frame if($ple==0) { fprint $fileId "CameraMatrix: "; if( ($i==0)&&($item=="vista_camRight1") ) fprint $fileId ( $t); //no new line when writing last line else fprint $fileId ( $t + "\n"); } } } } sucessFeedback_c2v("Reversed Camera File Saved"); } //Close camera file fflush $fileId; fclose $fileId; if ($ple==0) print "Printed Only first 15 lines of camerafile\n"; $test=`ls cam_aim_locator`; $look=`radioButtonGrp -q -select lookflag`; if (size($test)==0 && ($look==3)) {warnFeedback_c2v("Recheck Step 2\nNo Camera Aim Path found.\nUsing normal to path as aim direction");} select -cl; return 1; } global proc showMyWindow_c2v() { //Set Developing to false when releasing int $developing =false; if($developing && `window -exists cam2VistaWindow`) deleteUI cam2VistaWindow; if(!`window -exists cam2VistaWindow`) { window -title "Cam2Vista-1.1" -resizeToFitChildren true -menuBar true cam2VistaWindow; menu -label "File"; menuItem -label "Import" -ann "Imports a camera file" -c "fileBrowser \"importCam_c2v\" \"Import_Cam\" \"\" 0" ; menuItem -divider true; menuItem -label "Quit" -c "deleteUI cam2VistaWindow"; menu -label "View"; menuItem -label "Look Thru Cam" -annotation "Look thru \"vista_cam1\" camera" -command "setCameraAim_c2v(`currentTime -q`);if(`vista_cam1_Exists_c2v`){ setFOV_c2v();lookThru perspView vista_camShape2;}" preview_button; menuItem -label "Default Cam" -annotation "Look thru default persp camera" -command " lookThru perspView persp;" default_preview_button; menuItem -label "ResGate" -annotation "Turn on/off Resolution Gate for Camera" -command "if(`vista_cam1_Exists_c2v`) {int $t=(!`camera -q -displayResolution vista_camShape2`); camera -e -displayResolution $t vista_camShape2;}" toggle_resgate_button; menu -label "Tools"; menuItem -label "fitBspline" -c "fitBspline; sucessFeedback_c2v(\"Fitted Bspline\");"; menuItem -label "rebuild curve 1" -c "rebuildCurve -rpo 0"; menuItem -label "rebuild curve 2" -c "rebuildCurve -rpo 0 -kcp 1"; menu -label "Help" -helpMenu true; menuItem -label "Help" -c "openHelpPage_c2v()"; menuItem -label "About Application..." -c "openAbout_c2v()"; if (`columnLayout -exists "cam2Vista_layout"`) deleteUI "cam2Vista_layout"; //Create fresh layout columnLayout "cam2Vista_layout"; //Header text -w 200 -l "Look Here For\nWarning/Error/Feedback MESSAGES" feedback_general; separator -style none -h 5; //Step 1 text -bgc 0.7 0.7 0.7 -w 200 -al "left" -fn "boldLabelFont" -l "Step 1:Choose camera setup"; //Keyframe button checkBox -align left -annotation "Check this box if using Maya PLE" -l "Maya PLE (Only if using Maya PLE)" -v false -onc "sucessFeedback_c2v(\"Output displayed on script editor\\n Maya PLE does not allow saving files\")" mayaple; radioButtonGrp -numberOfRadioButtons 4 -columnWidth4 48 48 50 54 -en3 0 -en4 0 -annotation "Selects the Camera Setup" -labelArray4 "1Cam" "5Cam" "7Cam" "11Cam" -cc1 "floatFieldGrp -e -v1 45.0 fov_floatfieldgrp; sucessFeedback_c2v(\"Single Camera Mode set.\\nSet FOV=45.0 \");" -cc2 "floatFieldGrp -e -v1 90.0 fov_floatfieldgrp; sucessFeedback_c2v(\"5 Camera Dome Mode set.\\nSet FOV=90.0 \");" -cc3 "floatFieldGrp -e -v1 90.0 fov_floatfieldgrp; sucessFeedback_c2v(\"7 Camera Dome Mode set.\\nSet FOV=90.0 \");" -cc4 "floatFieldGrp -e -v1 90.0 fov_floatfieldgrp; sucessFeedback_c2v(\"11 Camera Dome Mode set.\\nSet FOV=90.0 \");" -select 1 camMode; separator -style none -h 5; //Step 2 text -bgc 0.7 0.7 0.7 -w 200 -al "left" -fn "boldLabelFont" -l "Step 2:Set Camera Aim and FOV"; //Create Lookat radio selection radioButtonGrp -numberOfRadioButtons 4 -columnWidth4 45 40 75 40 -annotation "Selects the Camera Aim Direction, Auto uses keyframed camera" -labelArray4 "Point" "Auto" "Norm2Path" "Path" -cc1 "floatFieldGrp -e -en 1 lookatpoint_floatfieldgrp;setCameraAim_c2v(`currentTime -q`); sucessFeedback_c2v(\"Camera aim is set at the \\n specified point.\");" -cc2 "floatFieldGrp -e -en 0 lookatpoint_floatfieldgrp;setCameraAim_c2v(`currentTime -q`); sucessFeedback_c2v(\"Camera aim would be used \\n from the Camera Keyframes.\");" -cc3 "floatFieldGrp -e -en 0 lookatpoint_floatfieldgrp;setCameraAim_c2v(`currentTime -q`); sucessFeedback_c2v(\"Camera aim is set Normal \\n to the camera motion path.\");" -cc4 "floatFieldGrp -e -en 0 lookatpoint_floatfieldgrp;setCameraAim_c2v(`currentTime -q`); sucessFeedback_c2v(\"Camera aim is set to the \\n camera aim path.\");" -select 2 lookflag; separator -style none -h 5; floatFieldGrp -numberOfFields 3 -label "Look at xyz" -pre 4 -cw4 65 45 45 45 -w 200 -annotation "Enter x,y,z to alook at" -value1 0.0 -value2 0.0 -value3 0.0 -cc "float $v[]=`floatFieldGrp -q -v lookatpoint_floatfieldgrp`;setCameraAim_c2v(`currentTime -q`)" lookatpoint_floatfieldgrp; separator -style none -h 5; floatFieldGrp -en2 0 -numberOfFields 2 -label "FOV" -extraLabel "Aspect" -pre 4 -w 200 -cw4 65 45 45 45 -annotation "Enter Field of View for Camera" -v1 45.0 -v2 1.33333333 -cc "float $v[]=`floatFieldGrp -q -v fov_floatfieldgrp`; setFOV_c2v();" fov_floatfieldgrp; separator -style none -h 5; //Step 3 text -bgc 0.7 0.7 0.7 -w 200 -al "left" -fn "boldLabelFont" -l "Step 3 (optional-if Keyframing Cam)"; rowColumnLayout -cw 1 80 -cw 2 60 -cw 3 60 -nc 3; //row1 //Create spiral button text -fn "boldLabelFont" -al "center" -l "DrawCurve or"; button -l "DrawSpiral" -annotation "Creates a test spiral at origin" -command "drawTestSpiral_c2v();" testSpiralButton; button -l "DelSpiral" -annotation "Deletes the test spiral" -command "delete cam2vista_test_spiral"; //row2 button -l "Del Locator" -annotation "Deletes cam_aim_locator" -command "delete cam_aim_locator"; button -l "CreateCam" -annotation "Creates cam2vista camera at (0,0,1)" -command "createCam_c2v"; button -l "Del Cam" -annotation "Deletes cam2vista camera" -command "delete vista_cam1"; setParent..;//Go back to Parent layout separator -style none -h 5; //Step 4 text -bgc 0.7 0.7 0.7 -w 200 -al "left" -fn "boldLabelFont" -l "Step 4"; rowColumnLayout -cw 1 40 -cw 2 85 -cw 3 75 -nc 3; //Create no of frames intField intField -w 40 -v (`playbackOptions -q -maxTime`+1) -annotation "Type the no of frames required on camera motion path" -cc "reApply_c2v()" framenos; text -l ""; /* checkBoxGrp -cal 1 left -numberOfCheckBoxes 1 -annotation "When checked Hit ENTER after typing no of frames" -l1 "Instant Apply" -v1 false -on1 "intField -e -cc \"if(`vista_cam1_Exists_c2v`) reApply_c2v\" framenos;reApply_c2v" -of1 "intField -e -cc \"\" framenos" instantApply_checkBoxGrp; */ button -w 70 -l "ReApply" -annotation "Revises the no of frames on EXISTING camera motion/aim curves" -c "if(`vista_cam1_Exists_c2v`) reApply_c2v()" reApply_c2vNOF; setParent..;//Go back to Parent layout rowColumnLayout -cw 1 130 -cw 2 70 -nc 2; text -l "Enter no of frames Req."; text -w 75 -al "center" -l "no Of Frames"; setParent..;//Go back to Parent layout /* rowColumnLayout -cw 1 60 -cw 2 30 -cw 3 20 -cw 4 30 -cw 5 60 -nc 5; //Create no of frames intField int $sframe=`playbackOptions -q -minTime`; int $eframe=`playbackOptions -q -maxTime`; text -l "Start Frame"; intField -w 50 -v $sframe -annotation "Type the start frame for camera motion path" -cc "reApply_c2v()" startframe; text -l ""; intField -w 50 -v $eframe -annotation "Type the end frame of camera motion path" -cc "reApply_c2v()" endframe; text -l "End Frame"; */ /* checkBoxGrp -cal 1 left -numberOfCheckBoxes 1 -annotation "When checked Hit ENTER after typing no of frames" -l1 "Instant Apply" -v1 false -on1 "intField -e -cc \"if(`vista_cam1_Exists_c2v`) reApply_c2v\" framenos;reApply_c2v" -of1 "intField -e -cc \"\" framenos" instantApply_checkBoxGrp; */ separator -style none -h 5; //Step 5 text -bgc 0.7 0.7 0.7 -w 200 -al "left" -fn "boldLabelFont" -l "Step 5 (optional-if Keyframing Cam)"; //Create Aim curve selected button button -w 200 -l "Selected Aim Curve" -annotation "Binds the curve as camera aim" -command "aimTrigger_c2v()" selAimCurveButton; text -w 200 -al "center" -l "Click after selecting camera aim curve" text_selAimCurveButton; separator -style none -h 5; //Step 6 text -bgc 0.7 0.7 0.7 -w 200 -al "left" -fn "boldLabelFont" -l "Step 6"; //Keyframe button checkBox -align left -annotation "Use set Keyframes" -l "Use Set Keyframes" -v false -onc "sucessFeedback_c2v(\"Use Set Keyframes\\n\")" keyframedcam; text -fn "boldLabelFont" -l "OR"; //Create Path curve selected button button -w 200 -l "Selected Motion Path Curve" -annotation "Creates a camera and binds it to selected curve as camera motion path" -command "pathTrigger_c2v();" selPathCurveButton; text -w 200 -al "center" -l "Click after selecting cam motionpath curve" text_selPathCurveButton; separator -style none -h 10; floatSlider -min 0.0 -max 1.0 -value 0.3 -step 0.05 -w 200 -annotation "Slide to change vista_cam1 size" -cc "if(`vista_cam1_Exists_c2v`) cam2VistaScale_c2v() " camScaleSlider; text -w 200 -al "center" -l "Scale camera size"; //separator -style none -h 5; //Step 7 text -bgc 0.7 0.7 0.7 -w 200 -al "left" -fn "boldLabelFont" -l "Step 7"; text -fn "boldLabelFont" -w 200 -al "center" -l "Check Step 2 has correct Cam Aim "; rowColumnLayout -cw 1 80 -cw 2 120 -nc 2; //Row 1 //Create save button for camera file button -vis 1 -l "Save CamFile" -annotation "Opens dialog box for saving file" //for portability use fileBrowser in mayainstall/scripts/others/fileBrowser.mel //fileBrowser inputs are action title filetype read/writemode (ie fileBrowser string string string int) -command "if(`vista_cam1_Exists_c2v`) fileBrowser \"saveCam_c2v\" \"Save_Cam\" \"\" 1" saveButton; //Windows only //-command "if(`vista_cam1_Exists_c2v`) fileBrowserDialog -m 1 -fc \"saveCam_c2v\" -an \"Save_Cam\"; "saveButton; button -vis 1 -l "SaveReversed CamFile" -annotation "Opens dialog box for saving file" //for portability use fileBrowser in mayainstall/scripts/others/fileBrowser.mel //fileBrowser inputs are action title filetype read/writemode (ie fileBrowser string string string int) -command "if(`vista_cam1_Exists_c2v`) fileBrowser \"saveRevCam_c2v\" \"Save_Cam\" \"\" 1" saveRevButton; //Windows only //-command "if(`vista_cam1_Exists_c2v`) fileBrowserDialog -m 1 -fc \"saveRevCam_c2v\" -an \"Save_Cam\"; " saveRevButton; setParent..;//Go back to Parent layout text -w 200 -al "center" -l "Click to save Camera File" saveTextLabel; separator -style none -h 5; //Step 8 text -bgc 0.7 0.7 0.7 -w 200 -al "left" -fn "boldLabelFont" -l "Step 8:Preview CamPath & CamAim"; rowColumnLayout -w 200 -cw 1 80 -cw 2 70 -cw 3 50 -numberOfColumns 3; button -l "LookthruCam" -annotation "Look thru \"vista_cam1\" camera" -command "setCameraAim_c2v(`currentTime -q`);if(`vista_cam1_Exists_c2v`){ setFOV_c2v();lookThru perspView vista_camShape2;}" preview_button; button -l "DefaultCam" -annotation "Look thru default persp camera" -command " lookThru perspView persp;" default_preview_button; button -l "ResGate" -annotation "Turn on/off Resolution Gate for Camera" -command "if(`vista_cam1_Exists_c2v`) {int $t=(!`camera -q -displayResolution vista_camShape2`); camera -e -displayResolution $t vista_camShape2;}" toggle_resgate_button; setParent ..;//Go back to Parent layout separator -style none -h 5; columnLayout -adj 1 -cal "center"; timePort -w 195 -h 30 editorTimeLine; setParent ..;//Go back to Parent layout text -fn "tinyBoldLabelFont" -w 200 -al "center" -l "Check Step 2 has correct Cam Aim "; rowColumnLayout -numberOfColumns 8 -columnWidth 1 25 -columnWidth 2 25 -columnWidth 3 25 -columnWidth 4 25 -columnWidth 5 25 -columnWidth 6 25 -columnWidth 7 25 -columnWidth 8 25 ; symbolButton -image "timerew.xpm" -c "playButtonStart" -annotation "Go to start of playback range"; symbolButton -image "timeend.xpm" -c "playButtonStepBackward" -annotation "Step backward one frame"; symbolButton -w 32 -image "timeprev.xpm" -c "findKeyframe -timeSlider -which previous`" -annotation "Step backward one key"; symbolButton -w 32 -image "timerev.xpm" -c "playButtonBackward" -annotation "Plays forward, press again to stop"; symbolButton -w 32 -image "timeplay.xpm" -c "playButtonForward" -annotation "Plays backward, press again to stop"; symbolButton -w 32 -image "timenext.xpm" -c "currentTime -edit `findKeyframe -timeSlider -which next`" -annotation "Step forward one key"; symbolButton -w 32 -image "timestart.xpm" -c "playButtonStepForward " -annotation "Step forward one frame"; symbolButton -w 32 -image "timefwd.xpm" -c "playButtonEnd " -annotation "Go to end of playback range"; setParent ..;//Go back to Parent layout //Footer separator -style none -h 10; rowColumnLayout -cw 1 120 -cw 2 80 -nc 2; text -fn "boldLabelFont" -w 150 -l "Rollover for tool tips" -al "center"; button -l "HelpWebPage" -h 15 -c "openHelpPage_c2v" help_button; setParent..;//Go back to Parent layout setParent ..;//Go back to Parent window //Delete previous expresion if any and Create new expression to track look at for preview string $test[]=`ls -type expression vista2camDaemon`; if(size($test)==1) delete $test; expression -name "vista2camDaemon" -string "setCameraAim_c2v(`currentTime -q`)"; //Delete the expression when "cam2VistaWindow" is closed scriptJob -uiDeleted "cam2VistaWindow" "delete vista2camDaemon"; select -cl; } showWindow cam2VistaWindow; } showMyWindow_c2v;