Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 106 22-07-2006 , 11:32 AM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
oops, now it should come user added image
I've made all the checkboxes work user added image
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;
}


Last edited by arneoog; 22-07-2006 at 11:38 AM.
# 107 24-07-2006 , 09:53 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Did some tiny adjustments, and made a new Zip file
maya_to_indigo_xml_converter_beta0.2.zip

Matt, you need to come back from where ever your parents have dragged you :p !
I can't get it to read the values of the sliders user added image


Last edited by arneoog; 24-07-2006 at 10:58 PM.
# 108 28-07-2006 , 05:45 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
I got an idea! user added image
People should be able to set options for all the individual objects in a scene.
made a little GUI example:
Code:
window -title "Object Editor" -h 340 -w 480 objE0076;
rowLayout -numberOfColumns 2 -columnWidth2 170 310;
scrollLayout -h 306 -w 170 -backgroundColor 1 1 1;
 			                setParent ..;
 			setParent ..;
columnLayout;
text -label "Object Settings for " -w 480 -align "left" -font "boldLabelFont";
separator -w 480 -h 10;
checkBox -label "Convert this object to XML" -value 1;
checkBox -label "Normal Smoothing" -value 1;

			showWindow;
All the objects in the scene pops up in the list at the left and the options is on the right.
No idea how to make this but i'll try to do something later...
user added image

# 109 29-07-2006 , 01:40 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
not at all hard. I could do that. U know what, let me work on it this weekend. I could just store all the arrays, all the variables... etc... (such as normal smoothing), and on Monday you can go ahead and put it in the GUI user added image


Live the life you love, love the life you live
# 110 29-07-2006 , 10:46 AM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Yay! Thanks, Matt user added image
:attn:

# 111 29-07-2006 , 02:48 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
ok, in the lil object modification thing, I was thinking the Indigo material to be accessed from there, and the normal smoothing. That way we could have our material editor user added image


Live the life you love, love the life you live
# 112 29-07-2006 , 03:04 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Absolutly! user added image
Choose material from a dropdown menu,
and then the material settings comes under there user added image or something...

# 113 29-07-2006 , 03:46 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
How about this?
Code:
window -title "Object Editor" -h 340 -w 570 objE00444;
rowLayout -numberOfColumns 2 -columnWidth2 170 310;
scrollLayout -h 306 -w 170 -backgroundColor 1 1 1;
 			                setParent ..;
 			setParent ..;
 		tabLayout;
columnLayout Object;
text -label "Object settings" -w 400 -align "left" -font "boldLabelFont";
	separator -h 10 -w 400;
checkBox -label "Convert this object to XML" -value 1;
text -label "" -w 310 -align "left";
checkBox -label "Normal Smoothing" -value 1;
text -label "" -w 310 -align "left";
 				setParent ..;

columnLayout Materials;
text -label "Material Settings" -w 400 -align "left" -font "boldLabelFont";
	separator -h 10 -w 400;
 			shelfLayout -width 390 -cellWidth 34 -cellHeight 34;
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 ..;

rowLayout -numberOfColumns 2 -columnWidth2 170 230;
text -label "Name Of Material Type" -w 170 -align "left";
textField -w 200;
 			                setParent ..;

	colorSliderGrp -h 25 -label "Diffuse" -rgb 0.5 0.5 0.5;

	colorSliderGrp -h 25 -label "Specular" -rgb 0 0 0;

	floatSliderGrp -h 25 -label "Exponent" -field true 
                -fieldMinValue -10000 -fieldMaxValue 10000 
                -minValue 0.001 -maxValue 10000 -value 10000;
	separator -h 10 -w 400;
text -label "" -h 20 -align "left";

optionMenu -label "Add Existing Materials";
		menuItem -label "?????";
 			                setParent ..;
 			setParent ..;

			showWindow;


Last edited by arneoog; 29-07-2006 at 03:53 PM.
# 114 29-07-2006 , 04:51 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
yeah, but why don't we do it in just one tab- the convert this object to xml... I don't really know how to do that one... a bit tricky.

But yeah, why not put the normal smoothing at the bottom of the material tab??? that would work user added image

I'm tying the main script better too. Oh- one last thing (sorry arne :p), could you make this window pop up in like

FILE EDIT TOOLS HELP ABOUT

(in tools we could put the object editor and material editor)

whaddya think? user added image


Live the life you love, love the life you live
# 115 29-07-2006 , 05:04 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Okay, now it has one tab.
It is put in to the main script.
Edited the MenuBar.
And I took the "convert this object to xml" away.

This is starting to get huge! user added image hehe
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;
}

//-----------------OBJECT EDITOR------------------

global proc objectEditor() 
{ 
window -title "Object Editor" -h 340 -w 570 objE00444;
rowLayout -numberOfColumns 2 -columnWidth2 174 310;
scrollLayout -h 306 -w 170 -backgroundColor 1 1 1;
 			                setParent ..;
 			setParent ..;
columnLayout;
text -label "Material Settings" -w 400 -align "left" -font "boldLabelFont";
	separator -h 10 -w 400;
 			shelfLayout -width 390 -cellWidth 34 -cellHeight 34;
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 ..;

rowLayout -numberOfColumns 2 -columnWidth2 170 230;
text -label "Name Of Material Type" -w 170 -align "left";
textField -w 200;
 			                setParent ..;

	colorSliderGrp -h 25 -label "Diffuse" -rgb 0.5 0.5 0.5;

	colorSliderGrp -h 25 -label "Specular" -rgb 0 0 0;

	floatSliderGrp -h 25 -label "Exponent" -field true 
                -fieldMinValue -10000 -fieldMaxValue 10000 
                -minValue 0.001 -maxValue 10000 -value 10000;
	separator -h 10 -w 400;
text -label "" -h 20 -align "left";

optionMenu -label "Add Existing Materials";
		menuItem -label "?????";
text -label "" -align "left";
text -label "Object settings" -w 400 -align "left" -font "boldLabelFont";
	separator -h 10 -w 400;
checkBox -label "Normal Smoothing" -value 1;
 			                setParent ..;
 			setParent ..;

			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.2" -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 "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 "Tools" -tearOff true;

		menuItem -label "Object Editor"  -command "objectEditor";
		menuItem -label "Material Editor"  -command "materialEditor";
	
	menu -label "Help" -helpMenu true;
		menuItem -label "Maya to Indigo Help..." -command "helpWin";
		menuItem -label "Go to MayaToIndigo's homepage";
		menuItem -label "Go to Indigo renderer's homepage.";
		menuItem -divider true;
		menuItem -label "About Maya to Indigo..." -command "abWin";

columnLayout -columnAlign "center";
picture -image "mayatoindigo.bmp" -backgroundColor 1 1 1;

 		tabLayout;
 			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" Whitecb;
		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 "Background 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 492 -h 566 -editable false -tx $write;
showWindow indOut;
return 1;
}

# 116 29-07-2006 , 05:27 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
yeah, it is pretty big user added image

and, thanks for supporting my bossiness... I tend to want to take controll of everything, I hope you don't mind :blush:

I removed some useless pathtracing stuff, changed a few min/max values... etc.

also i got a bit more tying in done. all the sliders on the top part (rendersettings)

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;
}

//-----------------OBJECT EDITOR------------------

global proc objectEditor() 
{ 
window -title "Object Editor" -h 340 -w 570 objE00444;
rowLayout -numberOfColumns 2 -columnWidth2 174 310;
scrollLayout -h 306 -w 170 -backgroundColor 1 1 1;
 			                setParent ..;
 			setParent ..;
columnLayout;
text -label "Material Settings" -w 400 -align "left" -font "boldLabelFont";
	separator -h 10 -w 400;
 			shelfLayout -width 390 -cellWidth 34 -cellHeight 34;
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 ..;

rowLayout -numberOfColumns 2 -columnWidth2 170 230;
text -label "Name Of Material Type" -w 170 -align "left";
textField -w 200;
 			                setParent ..;

	colorSliderGrp -h 25 -label "Diffuse" -rgb 0.5 0.5 0.5;

	colorSliderGrp -h 25 -label "Specular" -rgb 0 0 0;

	floatSliderGrp -h 25 -label "Exponent" -field true 
                -fieldMinValue -10000 -fieldMaxValue 10000 
                -minValue 0.001 -maxValue 10000 -value 10000;
	separator -h 10 -w 400;
text -label "" -h 20 -align "left";

optionMenu -label "Add Existing Materials";
		menuItem -label "?????";
text -label "" -align "left";
text -label "Object settings" -w 400 -align "left" -font "boldLabelFont";
	separator -h 10 -w 400;
checkBox -label "Normal Smoothing" -value 1;
 			                setParent ..;
 			setParent ..;

			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.2" -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 "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 "Tools" -tearOff true;

		menuItem -label "Object Editor"  -command "objectEditor";
		menuItem -label "Material Editor"  -command "materialEditor";
	
	menu -label "Help" -helpMenu true;
		menuItem -label "Maya to Indigo Help..." -command "helpWin";
		menuItem -label "Go to MayaToIndigo's homepage";
		menuItem -label "Go to Indigo renderer's homepage.";
		menuItem -divider true;
		menuItem -label "About Maya to Indigo..." -command "abWin";

columnLayout -columnAlign "center";
picture -image "mayatoindigo.bmp" -backgroundColor 1 1 1;

 		tabLayout;
 			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 rrcb;
				floatSliderGrp -h 25 -label "Max Depth" -field true -fieldMinValue 1 -fieldMaxValue 1000 -minValue 1 -maxValue 1000 -value 1000 -precision 0 MaxDepth;
				checkBox -label "Bidirectional" Bidircb;
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 FUP;
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 ISP;
				floatSliderGrp -h 25 -label "Halt Time" -field true -fieldMinValue -5 -fieldMaxValue 5 -minValue -5 -maxValue 5 -value -1 -precision 0 HT;
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" Whitecb;
		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 "Background 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(){
float $larg = `floatSliderGrp -query -value Largecb`;
	return $larg;
}
global proc string getMch(){
float $mch = `floatSliderGrp -query -value MaxCh`;
	return $mch;
}
global proc string getRrlp(){
float $rrlp = `floatSliderGrp -query -value rrcb`;
	return $rrlp;
}
global proc string getMd(){
float $mch = `floatSliderGrp -query -value MaxDepth`;
	return $mch;
}
global proc string getfup(){
float $mch = `floatSliderGrp -query -value FUP`;
	return $mch;
}
global proc string getisp(){
float $mch = `floatSliderGrp -query -value ISP`;
	return $mch;
}
global proc string getht(){
float $mch = `floatSliderGrp -query -value HT`;
	return $mch;
}
//--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 $large = getLarge();
string $bidi = getBidir();
string $logg = getLoggi();
string $norm = getNorma();
string $savt = getSaveT();
string $savu = getSaveU();
string $mch = getMch();
string $rrlp = getRrlp();
string $md = getMd();
string $fup = getfup();
string $isp = getisp();
string $ht = getht();
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>"+$mch+"</max_change>\n";
$write += "\t<russian_roulette_live_prob>"+$rrlp+"</russian_roulette_live_prob>\n";
$write += "\t<max_depth>"+$md+"</max_depth>\n";
$write += "\t<bidirectional>"+$bidi+"</bidirectional>\n";
$write += "\t<strata_width>10</strata_width>\n";
$write += "\t<frame_upload_period>"+$fup+"</frame_upload_period>\n";
$write += "\t<halt_time>"+$ht+"</halt_time>\n";
$write += "\t<logging>"+$logg+"</logging>\n";
$write += "\t<image_save_period>"+$isp+"</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 492 -h 566 -editable false -tx $write;
showWindow indOut;
return 1;
}


Live the life you love, love the life you live
# 117 29-07-2006 , 05:45 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Nice user added image

Heh, I haven't noticed your bossiness user added image Probably cause I feel bossy myself, haha :p
It seems to have worked good so far, though :nod:

# 118 29-07-2006 , 05:56 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
yeah, arne, I'm sure i couldn't have done this without you though :blush:


Live the life you love, love the life you live
# 119 29-07-2006 , 06:42 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
user added image Don't know what to say user added image
user added image hehe :p



Object Editor GUI update:
Code:
window -title "Object Editor" -h 400 -w 570 objEditor0087;
rowLayout -numberOfColumns 2 -columnWidth2 174 310;
scrollLayout -h 366 -w 170 -backgroundColor 1 1 1;
 			                setParent ..;
 			setParent ..;
columnLayout;
text -label "Material Settings" -w 400 -align "left" -font "boldLabelFont";
	separator -h 10 -w 400;
 			shelfLayout -width 388 -cellWidth 34 -cellHeight 34;
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 ..;

rowLayout -numberOfColumns 2 -columnWidth2 140 240;
text -label "*Name Of Material Type*" -w 140 -align "right";
textField -w 180 -text "*the material's name*";
 			                setParent ..;
rowLayout -numberOfColumns 2 -columnWidth2 140 240;
text -label "Material Sample" -w 140 -align "right";
picture -image "" -w 64 -h 64 -backgroundColor 0.5 0.5 0.5;
 			                setParent ..;
	separator -style none -h 5 -w 400;
scrollLayout -h 130 -w 388;
 			                setParent ..;
	separator -style none -h 5 -w 400;
optionMenu -label "Add Existing Materials";
		menuItem -label "?????";
	separator -style none -h 5 -w 400;
text -label "Object settings" -w 400 -align "left" -font "boldLabelFont";
	separator -h 10 -w 400;
checkBox -label "Normal Smoothing" -value 1;

 			                setParent ..;
 			setParent ..;

			showWindow;

# 120 29-07-2006 , 07:32 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
ok, well how would you like me to return you the array of meshes? an array of strings?


Live the life you love, love the life you live
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads