//Script by Matt B. (ThatDude33) for export from Maya 6.5+ to Indigo 0.5.3 //Fixed by Arne OOG //Outputs in script window //Copy-Paste results into XML file, run using Ini File. //No edits should be neccesary //Start Writing: string $write = "<?xml version='1.0' standalone=no>\n"; $write += "<!--Exported from Maya-->\n\n"; 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; } //Will have a prompt window, but now uses settings from render globals $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>true</metropolis>\n"; $write += "\t<large_mutation_prob>0.2</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>true</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>true</logging>\n"; $write += "\t<image_save_period>30</image_save_period>\n"; $write += "\t<save_tonemapped_exr>false</save_tonemapped_exr>\n"; $write += "\t<save_untonemapped_exr>false</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"; $write += "<background>\n<radiance>1 1 1</radiance>\n</background>\n\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){ 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</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`; $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) { string $shape[] = `listRelatives -shapes $one`; if (`objectType $one` == "mesh"){ $write += "\n\n<model>\n\t<pos>0 0 0</pos>"; $write += "\n\t<scale>1</scale>"; $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>"; } } $write += "\n</scene>"; print($write); 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;