I've made all the checkboxes work
Code:
//-----------------MAYA TO INDIGO XML CONVERTER------------------ //Credits: //Matt B. (aka MattTheMan or ThatDude33) (converter engine) //Arne OOG (aka arneoog) (interface) //Outputs in script window //Copy-Paste results into XML file, run using Ini File. //No edits should be neccesary //Start Writing: //-----------------VECTOR CONFIG------------------ global proc vector normalize(vector $v){ float $len = sqrt($v.x*$v.x+$v.y*$v.y+$v.z*$v.z); vector $n = <<$v.x/$len, $v.y/$len, $v.z/$len>>; return $n; } //-----------------ABOUT MAYA TO INDIGO------------------ global proc abWin() { window -title "About Maya to Indigo" -h 200 -w 300 About; columnLayout; text -label "About Maya to Indigo" -w 300 -h 40 -backgroundColor 1 1 1 -font "boldLabelFont" -align "center" ; text -label "" -w 300 -align "center"; text -label "Creators:" -w 300 -font "boldLabelFont" -align "center"; text -label "Matt B. " -w 300 -align "center"; text -label "Arne OOG" -w 300 -align "center"; text -label "" -w 300 -align "center"; separator -w 300; text -label "" -w 300 -align "center"; text -label "Copyright © 2006" -w 300 -align "center"; showWindow; } //-----------------MAYA TO INDIGO HELP------------------ global proc helpWin() { window -title "Maya to Indigo Help" -h 220 -w 360 Help; columnLayout; text -label "Maya to Indigo Help" -w 360 -h 40 -backgroundColor 1 1 1 -font "boldLabelFont" -align "center" ; text -label "" -w 360; text -label "Things to remember before you generate the XML code" -w 360 -font "boldLabelFont"; text -label "- You must create a Camera" -w 360; text -label "- You must triangulate every one of you meshes" -w 360; text -label "- You must delet you history" -w 360; text -label "" -w 360 -align "center"; showWindow; } //-----------------ACTIVATE FIELDS------------------ global proc int skylight() { int $state = `checkBox -query -value SkylightCheckBox`; if ($state == 0) floatSliderGrp -edit -enable 0 skylightSlider; else floatSliderGrp -edit -enable 1 skylightSlider; if ($state == 0) floatSliderGrp -edit -enable 0 skylightSliderTwo; else floatSliderGrp -edit -enable 1 skylightSliderTwo; return $state; } global proc string getenv(){ int $state = `checkBox -query -value SkylightCheckBox`; string $retval; if ($state == 1){ return "physical"; } $state = `checkBox -query -value BgCheckBox`; if ($state == 1){ return "skylight"; } $state = `checkBox -query -value HDRCheckBox`; if ($state == 1){ return "hdri"; } if ($state == 0){ return "null"; } } global proc int bglight() { int $state = `checkBox -query -value BgCheckBox`; if ($state == 0) floatSliderGrp -edit -enable 0 bgSlider; else floatSliderGrp -edit -enable 1 bgSlider; return $state; } global proc int hdrlight() { int $state = `checkBox -query -value HDRCheckBox`; if ($state == 0) attrNavigationControlGrp -edit -enable 0 hdrSlider; else attrNavigationControlGrp -edit -enable 1 hdrSlider; return $state; } //-----------------CREATE STUFF------------------ proc sun() {sphere -r 0.5 -n Sun;} proc reclight() { } proc indcamera() {camera -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30; objectMoveCommand; cameraMakeNode 3 "";} //-----------------THE CONTROL PANEL------------------ window -title "Maya to Indigo XML converter - BETA 0.1" -h 600 -w 400 -menuBar true; menu -label "Edit" -tearOff true; menuItem -label "Save Settings"; menuItem -label "Reset Settings"; menuItem -divider true; menuItem -label "Close" -command "closeWindow"; menu -label "Create" -tearOff true; menuItem -label "Materials" -subMenu true; menuItem -label "Diffuse Shader"; menuItem -label "Phong Shader"; menuItem -label "Specular Shader"; menuItem -label "Mesh Light Shader"; menuItem -label "Metal Shader"; setParent -menu ..; menuItem -label "Lights" -subMenu true; menuItem -label "Sky Light" -command "sun"; menuItem -label "Rectangle Light" -command "reclight"; setParent -menu ..; menuItem -label "Misc" -subMenu true; menuItem -label "Camera" -command "indcamera"; menu -label "Window" -tearOff true; menuItem -label "Material Editor" -command "materialEditor"; menuItem -label "Material Browser" -command "materialBrowser"; menu -label "Help" -helpMenu true; menuItem -label "About Maya to Indigo..." -command "abWin"; menuItem -label "Maya to Indigo Help..." -command "helpWin"; columnLayout -columnAlign "center"; picture -image "mayatoindigo.bmp" -backgroundColor 1 1 1; tabLayout; shelfLayout Materials; shelfButton -annotation "Diffuse Shader" -image "indigo_diffuce.bmp" -command "diffuce"; shelfButton -annotation "Phong Shader" -image "indigo_phong.bmp" -command "phong"; shelfButton -annotation "Specular Shader" -image "indigo_specular.bmp" -command "specular"; shelfButton -annotation "Mesh Light Shader" -image "indigo_meshLight.bmp" -command "meshlight"; shelfButton -annotation "Metal Shader" -image "indigo_metal.bmp" -command "metal"; setParent ..; shelfLayout Lights; shelfButton -annotation "Sky Light" -image "indigo_sun.bmp" -command "sun"; shelfButton -annotation "Rectangle Light" -image "commandButton.xpm" -command "reclight"; setParent ..; shelfLayout Misc; shelfButton -annotation "Camera" -image "indigo_camera.bmp" -command "indcamera"; setParent ..; setParent ..; text -label "General settings" -w 400 -align "center" -font "boldLabelFont"; //-----------------SETTINGS------------------ frameLayout -collapsable true -label "Render Setting" -w 400; columnLayout -columnAlign "center"; separator -w 400 -h 10; text -label "Metropolis light transport settings" -w 400 -align "left" -font "boldLabelFont"; checkBox -label "Metropolis" Metrocb; floatSliderGrp -h 25 -label "Large Mutation Prob" -field true -fieldMinValue -10000 -fieldMaxValue 10000 -minValue 0.001 -maxValue 1 -value 0.2 -precision 3 Largecb; floatSliderGrp -h 25 -label "Max Change" -field true -fieldMinValue -10000 -fieldMaxValue 10000 -minValue 0.001 -maxValue 0.1 -value 0.025 -precision 3 MaxCh; separator -w 400 -h 10; text -label "General tracing parameters" -w 400 -align "left" -font "boldLabelFont"; floatSliderGrp -h 25 -label "Russian Roulette Live Prob" -field true -fieldMinValue -10000 -fieldMaxValue 10000 -minValue 0.001 -maxValue 1 -value 0.7 -precision 3; floatSliderGrp -h 25 -label "Max Depth" -field true -fieldMinValue -10000 -fieldMaxValue 10000 -minValue 100 -maxValue 10000 -value 1000 -precision 0; checkBox -label "Bidirectional" Bidircb; separator -w 400 -h 10; text -label "Path tracer settings" -w 400 -align "left" -font "boldLabelFont"; floatSliderGrp -h 25 -label "Strata Width" -field true -fieldMinValue 0.1 -fieldMaxValue 1000 -minValue 0.1 -maxValue 20 -value 10 -precision 1; separator -w 400 -h 10; text -label "Network rendering settings" -w 400 -align "left" -font "boldLabelFont"; floatSliderGrp -h 25 -label "Frame Upload Period" -field true -fieldMinValue 1 -fieldMaxValue 60 -minValue 1 -maxValue 60 -value 20 -precision 0; separator -w 400 -h 10; text -label "Miscellaneous settings" -w 400 -align "left" -font "boldLabelFont"; floatSliderGrp -h 25 -label "Image Save Period" -field true -fieldMinValue 1 -fieldMaxValue 60 -minValue 1 -maxValue 60 -value 30 -precision 0; floatSliderGrp -h 25 -label "Halt Time" -field true -fieldMinValue -5 -fieldMaxValue 5 -minValue -5 -maxValue 5 -value -1 -precision 0; optionMenu -label "What is your Up Axis"; menuItem -label "Y"; menuItem -label "Z"; checkBox -label "Logging" -value 1 Loggicb; checkBox -label "Normal Smoothing" -value 1 Normacb; checkBox -label "Save Tonemapped Exr" SaveTcb; checkBox -label "Save Untonemapped Exr" SaveUcb; setParent ..; setParent ..; frameLayout -collapsable true -label "Tone Mapping" -w 400; columnLayout -columnAlign "center"; floatSliderGrp -h 25 -label "Pre Scale" -field true -fieldMinValue 0 -fieldMaxValue 10 -minValue 0.001 -maxValue 10 -value 2 -precision 3; floatSliderGrp -h 25 -label "Post Scale" -field true -fieldMinValue 0 -fieldMaxValue 10 -minValue 0.001 -maxValue 10 -value 1 -precision 3; separator -w 400 -h 12; colorSliderGrp -h 25 -label "Color Correction" -rgb 1 1 1; setParent ..; setParent ..; frameLayout -collapsable true -label "Camera Setting" -w 400; columnLayout -columnAlign "center"; floatSliderGrp -h 25 -label "F/stop" -field true -fieldMinValue 1 -fieldMaxValue 32 -minValue 1 -maxValue 32 -value 8 -precision 1; separator -w 400 -h 12; optionMenu -label "White Balance"; menuItem -label "E"; menuItem -label "D50"; menuItem -label "D55"; menuItem -label "D60"; menuItem -label "D65"; menuItem -label "D75"; menuItem -label "A"; menuItem -label "B"; menuItem -label "C"; menuItem -label "9300"; menuItem -label "F2"; menuItem -label "F7"; menuItem -label "F11"; setParent ..; setParent ..; frameLayout -collapsable true -label "Environment Setting" -w 400; columnLayout -columnAlign "center"; checkBox -label "Sky Light" -align "center" -value 0 -changeCommand "skylight" SkylightCheckBox; floatSliderGrp -h 25 -label "Turbidity" -field true -fieldMinValue -10000 -fieldMaxValue 10000 -minValue 0.1 -maxValue 5 -value 2 -precision 3 -enable 0 skylightSlider; floatSliderGrp -h 25 -label "Sky Gain" -field true -fieldMinValue -0.0001 -fieldMaxValue 2 -minValue 0.0001 -maxValue 1 -value 0.05 -precision 4 -enable 0 skylightSliderTwo; separator -w 400 -h 12; checkBox -label "Background Light" -align "center" -changeCommand "bglight" BgCheckBox; colorSliderGrp -h 25 -label "Backgroung Light Color" -rgb 0.5 0.5 0.5 -enable 0 bgSlider; separator -w 400 -h 12; checkBox -label "HDR map" -align "center" -changeCommand "hdrlight" HDRCheckBox; attrNavigationControlGrp -l "HDR file" -enable 0 hdrSlider; setParent ..; setParent ..; button -w 400 -h 30 -label "Generate XML code" -align "center" -command "indigoOutput"; showWindow; //-----------------TIEING SCRIPTS------------------ //--SliderGrps-- global proc string getLarge(){ int $larg = `floatSliderGrp -query -value Largecb`; return $larg; } //--CheckBoxes-- global proc string getMetro(){ int $metr = `checkBox -query -value Metrocb`; if ($metr == 0) return "false"; if ($metr == 1) return "true"; } global proc string getBidir(){ int $bidi = `checkBox -query -value Bidircb`; if ($bidi == 0) return "false"; if ($bidi == 1) return "true"; } global proc string getLoggi(){ int $logg = `checkBox -query -value Loggicb`; if ($logg == 0) return "false"; if ($logg == 1) return "true"; } global proc string getNorma(){ int $norm = `checkBox -query -value Normacb`; if ($norm == 0) return "false"; if ($norm == 1) return "true"; } global proc string getSaveT(){ int $savt = `checkBox -query -value SaveTcb`; if ($savt == 0) return "false"; if ($savt == 1) return "true"; } global proc string getSaveU(){ int $savu = `checkBox -query -value SaveUcb`; if ($savu == 0) return "false"; if ($savu == 1) return "true"; } //--OptionMenus-- //-----------------THE XML CONVERTER------------------ global proc int indigoOutput(){ string $metr = getMetro(); string $larg = getLarge(); string $bidi = getBidir(); string $logg = getLoggi(); string $norm = getNorma(); string $savt = getSaveT(); string $savu = getSaveU(); string $write = "<?xml version='1.0' standalone=no>\n"; $write +="<scene>\n"; $write += "\n<renderer_settings>\n"; $write += "\t<width>" + `getAttr defaultResolution.width` +"</width>\n"; $write += "\t<height>" + `getAttr defaultResolution.height` +"</height>\n"; $write += "\t<metropolis>"+$metr+"</metropolis>\n"; $write += "\t<large_mutation_prob>0.200</large_mutation_prob>\n"; $write += "\t<max_change>0.025</max_change>\n"; $write += "\t<russian_roulette_live_prob>0.7</russian_roulette_live_prob>\n"; $write += "\t<max_depth>1000</max_depth>\n"; $write += "\t<bidirectional>"+$bidi+"</bidirectional>\n"; $write += "\t<strata_width>10</strata_width>\n"; $write += "\t<frame_upload_period>20</frame_upload_period>\n"; $write += "\t<halt_time>-1</halt_time>\n"; $write += "\t<logging>"+$logg+"</logging>\n"; $write += "\t<image_save_period>30</image_save_period>\n"; $write += "\t<save_tonemapped_exr>"+$savt+"</save_tonemapped_exr>\n"; $write += "\t<save_untonemapped_exr>"+$savu+"</save_untonemapped_exr>\n"; $write += "</renderer_settings>\n\n"; $write += "\t<tonemapping>\n"; $write += "\t\t<reinhard>\n"; $write += "\t\t\t<pre_scale>2.0</pre_scale>\n"; $write += "\t\t\t<post_scale>1.0</post_scale>\n"; $write += "\t\t</reinhard>\n"; $write += "\n\t\t<colour_correction>1.0 1.0 1.0</colour_correction>\n"; $write += "\t</tonemapping>\n"; if (getenv() == "skylight"){ $write += "<background>\n<radiance>1 1 1</radiance>\n</background>\n\n"; } if (getenv() == "physical"){ float $x = `getAttr Sun.tx`; float $y = `getAttr Sun.ty`; float $z = `getAttr Sun.tz`; vector $sun = <<$x, $y, $z>>; $sun = normalize($sun); $write += "\n<skylight>\n\t<sundir>"+$sun.x+" "+$sun.y+" "+$sun.z+"</sundir>\n\t<turbidity>2.0</turbidity>\n\t<sky_gain>0.02</sky_gain>\n</skylight>\n"; } print("\nenvset1-" +getenv()+"\n"); $write += "\n<camera>\n"; float $px = `getAttr camera1.tx`; float $py = `getAttr camera1.ty`; float $pz = `getAttr camera1.tz`; vector $pos = <<$px, $py, $pz>>; float $tx = `getAttr camera1_aim.tx`; float $ty = `getAttr camera1_aim.ty`; float $tz = `getAttr camera1_aim.tz`; vector $aria-label="User link" rel="noopener noreferrer nofollow" class="giveMeEllipsisa" target= <<$tx, $ty, $tz>>; vector $front = $target-$pos; vector $dist = $front; $front = normalize($front); $write += "\t<pos>"+$px+" "+$py+" "+$pz+"</pos>\n"; float $ux = `getAttr camera1_up.tx`; float $uy = `getAttr camera1_up.ty`; float $uz = `getAttr camera1_up.tz`; vector $up = <<$ux, $uy, $uz>>; $up = $up - $pos; $up = normalize($up); $write += "\t<up>"+$up.x+" "+$up.y+" "+$up.z+"</up>\n"; $write += "\t<forwards>"+$front.x+" "+$front.y+" "+$front.z+"</forwards>\n"; float $fstop = 8; if ($fstop < 1.0){ $fstop = 1.0; } if ($fstop > 22){ $fstop = 22; } float $aprad = 50/$fstop; $aprad = $aprad/200; $write += "\t<aperture_radius>"+$aprad+"</aperture_radius>\n"; float $FD = sqrt($dist.x*$dist.x+$dist.y*$dist.y+$dist.z*$dist.z); $write += "\t<focus_distance>"+$FD+"</focus_distance>\n"; $write += "\t<aspect_ratio>"+`getAttr defaultResolution.deviceAspectRatio`+"</aspect_ratio>\n"; $write += "\t<sensor_width>0.036</sensor_width>\n"; $write += "\t<lens_sensor_dist>0.0523314</lens_sensor_dist>\n"; $write += "\t<white_balance>D65</white_balance>\n"; $write += "</camera>\n\n"; string $mats[] = `ls -mat`; for ($one in $mats){ float $inc[]=`getAttr ($one + ".incandescence")`; if ($inc[0]+$inc[1]+$inc[2] == 0.0){ if (`objectType $one` == "lambert"){ $write+= "\n<material>\n"; if($one == "initialMaterialInfo"){ $one = "lambert1"; } $write += "\t<name>"+$one+"</name>\n"; $write += "\t<diffuse>\n"; float $color[] = `getAttr ($one + ".color")`; $write+="\t\t<colour>"+$color[0]+" "+$color[1]+" "+$color[2]+"</colour>\n"; $write += "\t</diffuse>\n"; $write += "</material>\n"; } if (`objectType $one` == "phong"){ $write += "\n<material>\n"; $write += "\t\t<name>"+$one+"</name>\n"; $write += "\t<phong>\n"; float $col[] = `getAttr ($one + ".color")`; $write += "\t\t<diffuse>"+$col[0]+" "+$col[1]+" "+$col[2]+"</diffuse>\n"; float $reflectivity = `getAttr($one +".reflectivity")`; if ($reflectivity > 0.0){ $write += "\t\t<specular>"+$reflectivity+" "+$reflectivity+" "+$reflectivity+"</specular>\n"; } if ($reflectivity == 0.0){ float $refl[] = `getAttr ($one +".reflectedColor")`; $write += "\t\t<specular>"+$refl[0]+" "+$refl[1]+" "+$refl[2]+"</specular>\n"; } float $exp = `getAttr ($one + ".cosinePower")`; float $exp = $exp * 10; $write += "\t\t<exponent>"+$exp+"</exponent>\n"; $write += "\t\t<fresnel_scale>0.5</fresnel_scale>\n"; $write += "\t</phong>\n"; $write += "</material>\n"; } } } string $shapes[] = `ls -s`; for ($one in $shapes){ if(`objectType $one` == "mesh"){ int $nV[] = `polyEvaluate -v $one`; int $nF[] = `polyEvaluate -f $one`; int $x = 0; $write += "\n<mesh>\n"; $write += "\t<name>"+$one+"</name>\n"; $write += "\t<embedded>\n"; for($x=0;$x < $nV[0];$x++){ string $cv = $one+".vtx["+$x+"]"; float $pos[] = `pointPosition $cv`; $write += "\t\t<vertex pos='"+$pos[0]+" "+$pos[1]+" "+$pos[2]+"'"; float $normal[] = `polyNormalPerVertex -q -xyz $cv`; $normal[0] = -$normal[0]; $normal[1] = -$normal[1]; $normal[2] = -$normal[2]; $write += " normal='"+$normal[0]+" "+$normal[1]+" "+$normal[2]+"'"; string $uv[] = `polyListComponentConversion -fv -tuv $cv`; float $uvcoord[] = `polyEditUV -q $uv`; $write += " uv0='"+$uvcoord[0]+" "+$uvcoord[1]+"'/>\n"; } $write += "\t<triangle_set>\n"; string $sg[] = `listConnections -type shadingEngine $one`; string $mat[] = `listConnections $sg[0]`; //$mat[2] holds the actual material. print(`listConnections $sg[0]`); if ($mat[2] == "initialMaterialInfo"){ $mat[2] = $mat[0]; } if ($mat[2] == "renderPartition"){ $mat[2] = $mat[3]; } $write += "\t<material_name>"+$mat[2]+"</material_name>\n"; for($x = 0;$x < $nF[0];$x++){ string $curface = $one +".f["+$x+"]"; string $vfl[] = `polyListComponentConversion -ff -tvf $curface`; $vfl = `filterExpand -sm 70 $vfl`; $write +="\t\t<tri>"; for ($v in $vfl){ string $vert[]=`polyListComponentConversion -fvf -tv $v`; string $vnum = match("[0-9]+",match("[0-9]+\]",$vert[0])); int $conv = $vnum; $write += $conv + " "; } $write += "</tri>\n"; } $write += "\t</triangle_set>\n"; $write += "\t</embedded>\n"; $write += "</mesh>"; } } //Models string $trans[] =`ls -s`; for ($one in $trans) { if (`objectType $one` == "mesh"){ string $sg[] = `listConnections -t shadingEngine $one`; if ($sg[0] == "initialShadingGroup"){ $sg[0] = "lambert1"; } string $amat[] = `listConnections $sg[0]`; if ($amat[2] == "renderPartition"){ $amat[2] = $amat[3]; } if ($amat[2] == "defaultShaderList1"){ $amat[2] = "lambert1"; } float $inc[] = `getAttr ($amat[2]+".incandescence")`; print($one + "/:con " + $amat[2]+"\n"); if ($inc[1]+$inc[2]+$inc[0] ==0){ $write += "\n\n<model>\n\t<pos>0 0 0</pos>"; $write += "\n\t<scale>1</scale>"; $write += "\n\t<normal_smoothing>"+$norm+"</normal_smoothing>"; $write += "\n\t<rotation><matrix>1 0 0 0 1 0 0 0 1</matrix></rotation>"; $write += "\n\t<mesh_name>"+$one +"</mesh_name>\n</model>"; } if ($inc[1]+$inc[2]+$inc[0] >0){ $write += "\n<meshlight>\n"; $write += "\t<pos>0 0 0</pos>\n"; $write += "\t<scale>1</scale>\n"; $write += "\t<rotation>\n"; $write += "\t\t<matrix>1 0 0 0 1 0 0 0 1</matrix>\n"; $write += "\t</rotation>\n"; $write += "\t<mesh_name>"+$one+"</mesh_name>\n"; $write += "\t<spectrum>\n"; float $rgb[3]; $rgb[0] = 256*$inc[0]*5; $rgb[1] = 256*$inc[1]*5; $rgb[2] = 256*$inc[2]*5; $write += "\t<rgb>\n"; $write += "\t\t<rgb>"+$rgb[0]+" "+$rgb[1]+" "+$rgb[2]+"</rgb>\n"; $write += "\t</rgb>\n"; $write += "\t</spectrum>\n"; $write += "</meshlight>\n"; } } } $write += "\n</scene>"; if (`window -exists indOut`) deleteUI indOut; window -title "Output for Indigo Renderer" indOut; windowPref -wh 500 600 indOut; rowLayout -h 600; scrollField -w 480 -h 560 -editable false -tx $write; showWindow indOut; return 1; }