Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 31 27-05-2006 , 05:14 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Oh, well then I probably have used normal smoothing...

The Image I posted some posts up is exported with your last script...

# 32 27-05-2006 , 05:23 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
hmm... that's odd. I'll see if I botched up something in my script before useing it myself. Might as well add meshlights and physical sky now too...


Live the life you love, love the life you live
# 33 28-05-2006 , 07:38 AM
Registered User
Join Date: Apr 2006
Posts: 10
Wow, nice thing that Indigo is free.

And Matt, ho do ya get enough money to buy Maya?
It's 2000 USD or something?

# 34 28-05-2006 , 12:26 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
lol- everyone asks me this. I have a non-commercial license: just about $350.


Live the life you love, love the life you live
# 35 28-05-2006 , 04:07 PM
Registered User
Join Date: Apr 2006
Posts: 10
Heh, But isn't the PLE the same thing, non-commercial? Yah, it's got a watermark but you learn to live with it in a few years (like I did, took just maybe one year or something user added image ).

# 36 29-05-2006 , 12:36 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Yeah- you learn to live with it but you can't make a portfolio, you can't have high quality... etc.

I don't want to sell my works, so non-commercial is just fine for me. I not what most people would call "poor"... my parents can afford these things user added image


Live the life you love, love the life you live
# 37 29-05-2006 , 12:46 PM
Registered User
Join Date: Apr 2006
Posts: 10
Lucky you, I'm trying to earn my own maya, but now I have to think about that non-com version.
Time to get back to topic, lol?

user added image

# 38 05-06-2006 , 04:06 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Sorry for lack of progress- but I am adding support for meshlights simply by using the Incandescence slider in the Lambert attribute bar.

This is a bit tricky, because, in Indigo, meshlights are not declared as <model></model> and the material has to not appear in the <material> definition either.

Later,
-Matt


Live the life you love, love the life you live
# 39 05-06-2006 , 04:13 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Jippi! user added image hehe

# 40 05-06-2006 , 11:07 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Ok, added support for meshlights. All ya have to do is crank up the incandescense value on any kind of material.

Edit- fixed bad code user added image
Code:
//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";


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>false</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"){
		float $inc[]=`getAttr ($one + ".incandescence")`;
		if ($inc[0] > 0.0){
			break;
		}
if ($inc[1] > 0.0){
			break;
		}
if ($inc[2] > 0.0){
			break;
		}
		$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`;
		$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>true</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;
Should work.

-Matt


Live the life you love, love the life you live

Last edited by MattTheMan; 06-06-2006 at 01:17 AM.
# 41 06-06-2006 , 03:46 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Added a choise between skylight, physical sky, and none.

Soon, for physical sky, you will be able to choose the sundir.

Code:
//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";


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;
}
if (`window -exists In`) deleteUI In;
window -title "Maya->Indigo Settings" In;
	windowPref -wh 300 100 In;
	columnLayout ColumnLayout;
	frameLayout -labelVisible false  -marginWidth 5 -marginHeight 5;
		columnLayout;
			text -label "Render Settings";
			rowLayout -numberOfColumns 3;
	string $physical = `button -label "Physical Sky"`;
	string $sky = `button -label "Skylight"`;
	string $none = `button -label "None"`;
	button -edit -command ("output physical") $physical;
button -edit -command ("output skylight") $sky;
button -edit -command ("output none") $none;
showWindow In;
global proc output(string $selected){		
string $write;
print $selected;
$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>false</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";
if ($selected == "skylight"){
$write += "<background>\n<radiance>1 1 1</radiance>\n</background>\n\n";
}
if ($selected == "physical"){
$write += "\n<skylight>\n\t<sundir>0 0 1</sundir>\n\t<turbidity>2.0</turbidity>\n\t<sky_gain>0.02</sky_gain>\n</skylight>\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"){
		float $inc[]=`getAttr ($one + ".incandescence")`;
		if ($inc[0] > 0.0){
			break;
		}
if ($inc[1] > 0.0){
			break;
		}
if ($inc[2] > 0.0){
			break;
		}
		$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`;
		$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>true</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;

}


Live the life you love, love the life you live
# 42 06-06-2006 , 03:52 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Now- for sundir all you have to do is to create a point light and position it where the sun is, supposing the target is 0,0,0.

Code:
//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";


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;
}
if (`window -exists In`) deleteUI In;
window -title "Maya->Indigo Settings" In;
	windowPref -wh 300 100 In;
	columnLayout ColumnLayout;
	frameLayout -labelVisible false  -marginWidth 5 -marginHeight 5;
		columnLayout;
			text -label "Render Settings";
			rowLayout -numberOfColumns 3;
	string $physical = `button -label "Physical Sky"`;
	string $sky = `button -label "Skylight"`;
	string $none = `button -label "None"`;
	button -edit -command ("output physical") $physical;
button -edit -command ("output skylight") $sky;
button -edit -command ("output none") $none;
showWindow In;
global proc output(string $selected){		
string $write;
print $selected;
$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>false</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";
if ($selected == "skylight"){
$write += "<background>\n<radiance>1 1 1</radiance>\n</background>\n\n";
}
if ($selected == "physical"){
float $x = `getAttr pointLight1.tx`;
float $y = `getAttr pointLight1.ty`;
float $z = `getAttr pointLight1.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";
}

$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"){
		float $inc[]=`getAttr ($one + ".incandescence")`;
		if ($inc[0] > 0.0){
			break;
		}
if ($inc[1] > 0.0){
			break;
		}
if ($inc[2] > 0.0){
			break;
		}
		$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`;
		$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>true</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;

}


Live the life you love, love the life you live
# 43 06-06-2006 , 05:29 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Keep it up, Matt!!!
Super Great!!!
I like the new light features user added image

# 44 06-06-2006 , 05:43 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Thanks, I am trying to build a UI for it :headbang:


Live the life you love, love the life you live
# 45 06-06-2006 , 05:46 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Cool!
UIs ain't that hard to make user added image
Check this site for help:
MEL scripts GUI
Lots of cool stuff user added image
More links at the bottom

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