Introduction to Maya - Rendering in Arnold
This course will look at the fundamentals of rendering in Arnold. We'll go through the different light types available, cameras, shaders, Arnold's render settings and finally how to split an image into render passes (AOV's), before we then reassemble it i
# 1 25-05-2006 , 01:33 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436

Maya->Indigo0.5.3/0.5.4 Exporter Script

Well, people, I haven't programmed in a while. Now I want to make an MEL script that takes a Maya scene and makes an Indigo XML file.

So far- this is what my program outputs:

Code:
<?xml version='1.0' standalone=no>
<!--Exported from Maya-->

<scene>

<renderer_settings>
	<width>640</width>
	<height>480</height>
	<metropolis>true</metropolis>
	<large_mutation_prob>0.2</large_mutation_prob>
	<max_change>0.025</max_change>
	<russian_roulette_live_prob>0.7</russian_roulette_live_prob>
	<max_depth>1000</max_depth>
	<bidirectional>true</bidirectional>
	<strata_width>10</strata_width>
	<frame_upload_period>20</frame_uplod_period>
	<halt_time>-1</halt_time>
	<logging>true</logging>
	<image_save_period>30</image_save_period>
	<save_tonemapped_exr>false</save_tonemapped_exr>
	<save_untonemapped_exr>false</save_untonemapped_exr>
</renderer_settings>

	<tonemapping>		<reinhard>
			<pre_scale>2.0</pre_scale>
			<post_scale>1.0</post_scale>
		</reinhard>

		<colour_correction>1.0 1.0 1.0</colour_correction>
	</tonemapping>

<camera>
	<pos>2.852831591 -31.3782011 32.76079742</pos>
	<up>0 0 1</up>
	<forewards>-2.852831591 31.3782011 -27.63515811</forewards>
	<aperture_radius>
Yes, the numbers aren't just random outputs, they are actual processed positions. The camera target is a locator (with default name). The user can add an aim constraint to the camera from the locator if they want, it won't affect the script anyway.

Soon, I will have the vectors normalized, but, until then, this will have to do.

Also I'll have a window that prompts you, asks for settings, basically, a UI.


Live the life you love, love the life you live
# 2 25-05-2006 , 01:51 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
fast update- didn't know Maya had a target camera, so now you have to create a camera (camera 1, dont rename) and, instead of a locator, my script uses the camera target as the locator.

EDIT- Maya has just solved a big problem of mine- the up vector. Maya has a camera called Camera, aim, and up! I can use this to my advantage! :attn:

but you'lll have to use that kind of camera or else it won't export (the script won't run)


Live the life you love, love the life you live

Last edited by MattTheMan; 25-05-2006 at 01:53 AM.
# 3 25-05-2006 , 08:41 AM
Registered User
Join Date: Apr 2006
Posts: 10
Hmm, I think you'we got the basics right but as I don't know anything/very little of the Indigo file format I can't give you much C&C.
Yay for 13 year old programmers user added image
//lol
Arangol

# 4 25-05-2006 , 11:17 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
ya, yay lol :attn:

I will just post a sample XML file with 2 triangles in it and no light (exported from 3ds Max)

Code:
?xml version="1.0" standalone=no>
<!--Exported from 3ds Max-->

<scene>

<renderer_settings>
	<width>640</width>
	<height>480</height>
	<metropolis>true</metropolis>
	<large_mutation_prob>0.2</large_mutation_prob>
	<max_change>0.025</max_change>
	<russian_roulette_live_prob>0.7</russian_roulette_live_prob>
	<max_depth>1000</max_depth>
	<bidirectional>true</bidirectional>
	<strata_width>10</strata_width>
	<frame_upload_period>20</frame_upload_period>
	<halt_time>-1</halt_time>
	<logging>true</logging>
	<image_save_period>20</image_save_period>
	<save_tonemapped_exr>false</save_tonemapped_exr>
	<save_untonemapped_exr>false</save_untonemapped_exr>
</renderer_settings>

	<tonemapping>
		<reinhard>
			<pre_scale>2.0</pre_scale>
			<post_scale>1.0</post_scale>
		</reinhard>

		<colour_correction>1.0 1.0 1.0</colour_correction>
	</tonemapping>

	<camera>
		<pos>-1.05755 -0.00719424 0.0</pos>
		<up>0 0 1</up>
		<forwards>0.11223 0.0 0.0</forwards>
		<aperture_radius>0.003125</aperture_radius>
		<focus_distance>1.1223</focus_distance>
		<aspect_ratio>1.5</aspect_ratio>
		<sensor_width>0.036</sensor_width>
		<lens_sensor_dist>0.0523314</lens_sensor_dist>
		<white_balance>D65</white_balance>
	</camera>

	<include>
		<pathname>TESTmat.xml</pathname>
	</include>
		<!--object Plane02 -->
	<mesh>

		<name>Plane02</name>
	<embedded>
			<vertex pos="-26.489 -27.0168 26.9344" normal="0.0 0.0 1.0" uv0="0.0 0.0"/>
			<vertex pos="28.0727 -27.0168 26.9344" normal="0.0 0.0 1.0" uv0="1.0 0.0"/>
			<vertex pos="-26.489 27.5449 26.9344" normal="0.0 0.0 1.0" uv0="0.0 0.0"/>
			<vertex pos="28.0727 27.5449 26.9344" normal="0.0 0.0 1.0" uv0="1.0 0.0"/>
		<triangle_set>
			<material_name>Defaultmat</material_name>
			<tri>2 0 3</tri>
			<tri>1 3 0</tri>
		</triangle_set>
		</embedded>
	</mesh>
	<model>
		<pos>0 0 0</pos>
		<scale>0.01</scale>
		<normal_smoothing>true</normal_smoothing>
		<rotation>
			<matrix>
			1 0 0 0 1 0 0 0 1
			</matrix>
		</rotation>
		<mesh_name>Plane02</mesh_name>
	</model>
</scene>


Live the life you love, love the life you live
# 5 25-05-2006 , 11:06 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
well- I can get diffuse and phong materials exported.

Code:
<?xml version='1.0' standalone=no>
<!--Exported from Maya-->

<scene>

<renderer_settings>
	<width>640</width>
	<height>480</height>
	<metropolis>true</metropolis>
	<large_mutation_prob>0.2</large_mutation_prob>
	<max_change>0.025</max_change>
	<russian_roulette_live_prob>0.7</russian_roulette_live_prob>
	<max_depth>1000</max_depth>
	<bidirectional>true</bidirectional>
	<strata_width>10</strata_width>
	<frame_upload_period>20</frame_uplod_period>
	<halt_time>-1</halt_time>
	<logging>true</logging>
	<image_save_period>30</image_save_period>
	<save_tonemapped_exr>false</save_tonemapped_exr>
	<save_untonemapped_exr>false</save_untonemapped_exr>
</renderer_settings>

	<tonemapping>		<reinhard>
			<pre_scale>2.0</pre_scale>
			<post_scale>1.0</post_scale>
		</reinhard>

		<colour_correction>1.0 1.0 1.0</colour_correction>
	</tonemapping>

<camera>
	<pos>0 -5.06812214 4.74225765</pos>
	<up>0 0.5252816443 0.8509284307</up>
	<forewards>0 0.9012067486 -0.4333894279</forewards>
	<aperture_radius>0.03125</aperture_radius>
	<focus_distance>5.816917335</focus_distance>
	<aspect_ratio>1.333330035</asect_ratio>
	<sensor_width>0.036</sensor_width>
	<lens_sensor_dist>0.0523314</lens_sensor_dist>
	<white_balance>D65</white_balance>
</camera>

	<!--Materials--!>
	<!--Credits partially to LaLiLuLeLo, also with the models!!!--!>
<material>
	<name>lambert1</name>
	<diffuse>
		</colour>0.5 0.5 0.5</colour>
	</diffuse>
</material>

<material>
	<phong>
		<name>phong1</name>
		<diffuse>0 0.5 0.1034166962</diffuse>
		<specular>0.55400002 0.04321199656 0</specular>
		<exponent>120</exponent>
	</phong>
</material>
	<!--Actual Model Starts Here. --!>
That was exported with my script!!!!

I won't post code because I really don't want to be plaigerized, since my exporter is the only one around for Maya! (apart from LaLiLuLeLo from the flipcode forums, and his doens't work with Indigo 0.5)

Mine doesn't either but it will in an hour or two.

Later,
Matt


Live the life you love, love the life you live
# 6 26-05-2006 , 01:57 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
Hurry, hurry! user added image
I want to render my own modells :attn:

# 7 26-05-2006 , 04:02 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
ok ok!

I can export a full file now- plese try it out.. it doesn't work on my comp, no clue as to why the f**** it doesnt work. It tells me it can't read line -2.233.user added image

no meshlights or any kind of light for that matter, use it the same way you used LaLiLuLeLo's script, but:

Lambert materials are plain diffuse

Phong materials-

Color is actual color

Reflectivity is specular color

If you want a non-constant specular color (eg 1 0 1 instead of 1 1 1) you need to set reflectivity to 0 and use the reflected color gauge

Cosine power is specular sharpness (warning- it is multiplied by 10- eg. 12 is 120 and 0.3 is 3)

you need to use a camera- camera, aim, and up. Don't rename it.
Code:
//Script by Matt B. (ThatDude33) for export from Maya 6.5+ to Indigo 0.5.3
//Outputs in script window
//Copy-Paste results into XML file, run using Ini File.
//No edits should be neccesary

//Start Writing:
string $write = "<?xml version='1.0' standalone=no>\n";
$write += "<!--Exported from Maya-->\n\n";

proc vector normalize(vector $v){
float $len = sqrt($v.x*$v.x+$v.y*$v.y+$v.z*$v.z);
vector $n = <<$v.x/$len, $v.y/$len, $v.z/$len>>;
return $n;
}
//Will have a prompt window, but now uses settings from render globals
$write +="<scene>\n";
$write += "\n<renderer_settings>\n";
$write += "\t<width>" + `getAttr defaultResolution.width` +"</width>\n";
$write += "\t<height>" + `getAttr defaultResolution.height` +"</height>\n";
$write += "\t<metropolis>true</metropolis>\n";
$write += "\t<large_mutation_prob>0.2</large_mutation_prob>\n";
$write += "\t<max_change>0.025</max_change>\n";
$write += "\t<russian_roulette_live_prob>0.7</russian_roulette_live_prob>\n";
$write += "\t<max_depth>1000</max_depth>\n";
$write += "\t<bidirectional>true</bidirectional>\n";
$write += "\t<strata_width>10</strata_width>\n";
$write += "\t<frame_upload_period>20</frame_upload_period>\n";
$write += "\t<halt_time>-1</halt_time>\n";
$write += "\t<logging>true</logging>\n";
$write += "\t<image_save_period>30</image_save_period>\n";
$write += "\t<save_tonemapped_exr>false</save_tonemapped_exr>\n";
$write += "\t<save_untonemapped_exr>false</save_untonemapped_exr>\n";
$write += "</renderer_settings>\n\n";
$write += "\t<tonemapping>\n";
$write += "\t\t<reinhard>\n";
$write += "\t\t\t<pre_scale>2.0</pre_scale>\n";
$write += "\t\t\t<post_scale>1.0</post_scale>\n";
$write += "\t\t</reinhard>\n";
$write += "\n\t\t<colour_correction>1.0 1.0 1.0</colour_correction>\n";
$write += "\t</tonemapping>\n";
$write += "<background>\n<radiance>1 1 1</radiance>\n</background>\n\n";
$write += "\n<camera>\n";
float $px = `getAttr camera1.tx`;
float $py = `getAttr camera1.ty`;
float $pz = `getAttr camera1.tz`;
vector $pos = <<$px, $py, $pz>>;
float $tx = `getAttr camera1_aim.tx`;
float $ty = `getAttr camera1_aim.ty`;
float $tz = `getAttr camera1_aim.tz`;
vector $aria-label="User link" rel="noopener noreferrer nofollow" class="giveMeEllipsisa" target= <<$tx, $ty, $tz>>;
vector $front = $target-$pos;
vector $dist = $front;
$front = normalize($front);
$write += "\t<pos>"+$px+" "+$py+" "+$pz+"</pos>\n";
float $ux = `getAttr camera1_up.tx`;
float $uy = `getAttr camera1_up.ty`;
float $uz = `getAttr camera1_up.tz`;
vector $up = <<$ux, $uy, $uz>>;
$up = $up - $pos;
$up = normalize($up);
$write += "\t<up>"+$up.x+" "+$up.y+" "+$up.z+"</up>\n";
$write += "\t<forewards>"+$front.x+" "+$front.y+" "+$front.z+"</forewards>\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";
$write += "\t<!--Materials--!>\n";
$write += "\t<!--Some Credit to LaLiLuLeLo--!>";
string $mats[] = `ls -mat`;
for ($one in $mats){
	if (`objectType $one` == "lambert"){
		$write+= "\n<material>\n";
		$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<phong>\n";		
		$write += "\t\t<name>"+$one+"</name>\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";
	}
}
$write += "\t<!--Actual Model Starts Here. --!>\n";
string $shapes[] = `ls -s`;
for ($one in $shapes){
	if(`objectType $one` == "mesh"){
	int $nV[] = `polyEvaluate -v $one`;
	int $nF[] = `polyEvaluate -f $one`;
	int $x = 0;
	$write += "\n<mesh>\n";
	$write += "\t<name>"+$one+"</name>\n";
	$write += "\t<embedded>\n";
	for($x=0;$x < $nV[0];$x++){
		string $cv = $one+".vtx["+$x+"]";
		float $pos[] = `pointPosition $cv`;
		$write += "\t\t<vertex pos='"+$pos[0]+" "+$pos[1]+" "+$pos[2]+"'";
		float $normal[] = `polyNormalPerVertex -q -xyz $cv`;
		$write += " normal='"+$normal[0]+" "+$normal[1]+" "+$normal[2]+"'";
		string $uv[] = `polyListComponentConversion -fv -tuv $cv`;
		float $uvcoord[] = `polyEditUV -q $uv`;
		$write += " uv0='"+$uvcoord[0]+" "+$uvcoord[1]+"'/>\n";
		}
	$write += "\t</embedded>\n";	
	$write += "\t<triangle_set>\n";
	string $sg[] = `listConnections -type shadingEngine $one`;
	string $mat[] = `listConnections $sg[0]`;
	//$mat[2] holds the actual material.
	$write += "\t<material_name>"+$mat[2]+"</material_name>\n";
	for($x = 0;$x < $nF[0];$x++){
		string $curface = $one +".f["+$x+"]";
		string $vfl[] = `polyListComponentConversion -ff -tvf $curface`;
		$vfl = `filterExpand -sm 70 $vfl`;
		$write +="\t\t<tri>";
		for ($v in $vfl){
			string $vert[]=`polyListComponentConversion -fvf -tv $v`;
			string $vnum = match("[0-9]+",match("[0-9]+\]",$vert[0]));
			int $conv = $vnum;
			$write += $conv + " ";
		}
		$write += "</tri>\n";
	}	
	$write += "\t</triangle_set>\n";
	$write += "\t</embedded>\n";
	$write += "</mesh>";
	}
}

//Models
string $trans[] =`ls -s`;
for ($one in $trans) {
			string $shape[] = `listRelatives -shapes $one`;
			if (`objectType $one` == "mesh"){
			$write += "\n\n<model>\n\t<pos>0 0 0</pos>";
		$write += "\n\t<scale>1</scale>";
		$write += "\n\t<rotation><matrix>1 0 0 0 1 0 0 0 1</matrix></rotation>";
		$write += "\n\t<mesh_name>"+$one +"</mesh_name>\n</model>";
	}
}
$write += "\n</scene>";
print($write);
if (`window -exists indOut`) deleteUI indOut;
window -title "Output for Indigo Renderer" indOut;
windowPref -wh 500 600 indOut;
rowLayout -h 600;
scrollField -w 480 -h 560 -editable false -tx $write;
showWindow indOut;


Live the life you love, love the life you live
# 8 26-05-2006 , 04:16 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
user added image
Can't get Indigo to read it...
SceneLoaderExept: Failed to load XML doc from path 'testscenes/mayatest1100.xml': Error reading Element value. Line 0, column 0

Strange... user added image

# 9 26-05-2006 , 04:20 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
yeah- same here.

Odd indeed... and I wonder why! I mean, my 3ds Max files are just fine. I'll try to export an identical 3ds Max file and see what's up.


Live the life you love, love the life you live
# 10 26-05-2006 , 04:44 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
an identical 3ds exported file runs just fine.

I talked to nick (writer of Indigo) and he said he'd tell me what it is, if it's not because it can't find the file, which i'm sure it can.

This is making me maaaaaaaaad. I really want to solve this problem!!!1


Live the life you love, love the life you live
# 11 26-05-2006 , 06:36 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
YESS!!!!!!!!!!!!!!!!!!!!!! :attn:
I fixed it user added image user added image user added image user added image

There was some stupid mistakes there...

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";
$write += "<!--Exported from Maya-->\n\n";

proc vector normalize(vector $v){
float $len = sqrt($v.x*$v.x+$v.y*$v.y+$v.z*$v.z);
vector $n = <<$v.x/$len, $v.y/$len, $v.z/$len>>;
return $n;
}
//Will have a prompt window, but now uses settings from render globals
$write +="<scene>\n";
$write += "\n<renderer_settings>\n";
$write += "\t<width>" + `getAttr defaultResolution.width` +"</width>\n";
$write += "\t<height>" + `getAttr defaultResolution.height` +"</height>\n";
$write += "\t<metropolis>true</metropolis>\n";
$write += "\t<large_mutation_prob>0.2</large_mutation_prob>\n";
$write += "\t<max_change>0.025</max_change>\n";
$write += "\t<russian_roulette_live_prob>0.7</russian_roulette_live_prob>\n";
$write += "\t<max_depth>1000</max_depth>\n";
$write += "\t<bidirectional>true</bidirectional>\n";
$write += "\t<strata_width>10</strata_width>\n";
$write += "\t<frame_upload_period>20</frame_upload_period>\n";
$write += "\t<halt_time>-1</halt_time>\n";
$write += "\t<logging>true</logging>\n";
$write += "\t<image_save_period>30</image_save_period>\n";
$write += "\t<save_tonemapped_exr>false</save_tonemapped_exr>\n";
$write += "\t<save_untonemapped_exr>false</save_untonemapped_exr>\n";
$write += "</renderer_settings>\n\n";
$write += "\t<tonemapping>\n";
$write += "\t\t<reinhard>\n";
$write += "\t\t\t<pre_scale>2.0</pre_scale>\n";
$write += "\t\t\t<post_scale>1.0</post_scale>\n";
$write += "\t\t</reinhard>\n";
$write += "\n\t\t<colour_correction>1.0 1.0 1.0</colour_correction>\n";
$write += "\t</tonemapping>\n";
$write += "<background>\n<radiance>1 1 1</radiance>\n</background>\n\n";
$write += "\n<camera>\n";
float $px = `getAttr camera1.tx`;
float $py = `getAttr camera1.ty`;
float $pz = `getAttr camera1.tz`;
vector $pos = <<$px, $py, $pz>>;
float $tx = `getAttr camera1_aim.tx`;
float $ty = `getAttr camera1_aim.ty`;
float $tz = `getAttr camera1_aim.tz`;
vector $aria-label="User link" rel="noopener noreferrer nofollow" class="giveMeEllipsisa" target= <<$tx, $ty, $tz>>;
vector $front = $target-$pos;
vector $dist = $front;
$front = normalize($front);
$write += "\t<pos>"+$px+" "+$py+" "+$pz+"</pos>\n";
float $ux = `getAttr camera1_up.tx`;
float $uy = `getAttr camera1_up.ty`;
float $uz = `getAttr camera1_up.tz`;
vector $up = <<$ux, $uy, $uz>>;
$up = $up - $pos;
$up = normalize($up);
$write += "\t<up>"+$up.x+" "+$up.y+" "+$up.z+"</up>\n";
$write += "\t<forwards>"+$front.x+" "+$front.y+" "+$front.z+"</forwards>\n";
float $fstop = 8;
if ($fstop < 1.0){
$fstop = 1.0;
}
if ($fstop > 22){
$fstop = 22;
}
float $aprad = 50/$fstop;
$aprad = $aprad/200;
$write += "\t<aperture_radius>"+$aprad+"</aperture_radius>\n";
float $FD = sqrt($dist.x*$dist.x+$dist.y*$dist.y+$dist.z*$dist.z);
$write += "\t<focus_distance>"+$FD+"</focus_distance>\n";
$write += "\t<aspect_ratio>"+`getAttr defaultResolution.deviceAspectRatio`+"</aspect_ratio>\n";
$write += "\t<sensor_width>0.036</sensor_width>\n";
$write += "\t<lens_sensor_dist>0.0523314</lens_sensor_dist>\n";
$write += "\t<white_balance>D65</white_balance>\n";
$write += "</camera>\n\n";

string $mats[] = `ls -mat`;
for ($one in $mats){
	if (`objectType $one` == "lambert"){
		$write+= "\n<material>\n";
		$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<phong>\n";		
		$write += "\t\t<name>"+$one+"</name>\n";
		float $col[] = `getAttr ($one + ".color")`;
		$write += "\t\t<diffuse>"+$col[0]+" "+$col[1]+" "+$col[2]+"</diffuse>\n";
		float $reflectivity = `getAttr($one +".reflectivity")`;
		if ($reflectivity > 0.0){
			$write += "\t\t<specular>"+$reflectivity+" "+$reflectivity+" "+$reflectivity+"</specular>\n";
		}
		if ($reflectivity == 0.0){
			float $refl[] = `getAttr ($one +".reflectedColor")`;
			$write += "\t\t<specular>"+$refl[0]+" "+$refl[1]+" "+$refl[2]+"</specular>\n";
		}		
		float $exp = `getAttr ($one + ".cosinePower")`;
		float $exp = $exp * 10;
		$write += "\t\t<exponent>"+$exp+"</exponent>\n";
		$write += "\t</phong>\n";
		$write += "</material>\n";
	}
}

string $shapes[] = `ls -s`;
for ($one in $shapes){
	if(`objectType $one` == "mesh"){
	int $nV[] = `polyEvaluate -v $one`;
	int $nF[] = `polyEvaluate -f $one`;
	int $x = 0;
	$write += "\n<mesh>\n";
	$write += "\t<name>"+$one+"</name>\n";
	$write += "\t<embedded>\n";
	for($x=0;$x < $nV[0];$x++){
		string $cv = $one+".vtx["+$x+"]";
		float $pos[] = `pointPosition $cv`;
		$write += "\t\t<vertex pos='"+$pos[0]+" "+$pos[1]+" "+$pos[2]+"'";
		float $normal[] = `polyNormalPerVertex -q -xyz $cv`;
		$write += " normal='"+$normal[0]+" "+$normal[1]+" "+$normal[2]+"'";
		string $uv[] = `polyListComponentConversion -fv -tuv $cv`;
		float $uvcoord[] = `polyEditUV -q $uv`;
		$write += " uv0='"+$uvcoord[0]+" "+$uvcoord[1]+"'/>\n";
		}	
	$write += "\t<triangle_set>\n";
	string $sg[] = `listConnections -type shadingEngine $one`;
	string $mat[] = `listConnections $sg[0]`;
	//$mat[2] holds the actual material.
	$write += "\t<material_name>"+$mat[2]+"</material_name>\n";
	for($x = 0;$x < $nF[0];$x++){
		string $curface = $one +".f["+$x+"]";
		string $vfl[] = `polyListComponentConversion -ff -tvf $curface`;
		$vfl = `filterExpand -sm 70 $vfl`;
		$write +="\t\t<tri>";
		for ($v in $vfl){
			string $vert[]=`polyListComponentConversion -fvf -tv $v`;
			string $vnum = match("[0-9]+",match("[0-9]+\]",$vert[0]));
			int $conv = $vnum;
			$write += $conv + " ";
		}
		$write += "</tri>\n";
	}	
	$write += "\t</triangle_set>\n";
	$write += "\t</embedded>\n";
	$write += "</mesh>";
	}
}

//Models
string $trans[] =`ls -s`;
for ($one in $trans) {
			string $shape[] = `listRelatives -shapes $one`;
			if (`objectType $one` == "mesh"){
			$write += "\n\n<model>\n\t<pos>0 0 0</pos>";
		$write += "\n\t<scale>1</scale>";
		$write += "\n\t<rotation><matrix>1 0 0 0 1 0 0 0 1</matrix></rotation>";
		$write += "\n\t<mesh_name>"+$one +"</mesh_name>\n</model>";
	}
}
$write += "\n</scene>";
print($write);
if (`window -exists indOut`) deleteUI indOut;
window -title "Output for Indigo Renderer" indOut;
windowPref -wh 500 600 indOut;
rowLayout -h 600;
scrollField -w 480 -h 560 -editable false -tx $write;
showWindow indOut;
Just one thing must be done before rendering...
Write 'lambert1' insted of 'initialMaterialInfo' in the Mesh material_name.

You should kiss my feet Matt! HAHA!!!
Just kidding... hehe...
user added image

# 12 26-05-2006 , 06:44 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
damn! now I have to add you to credits... user added image user added image user added image :p

BUt still I can't say that you did the whole thing, I'll just add

"Thanks to Arneoog for fixing some major bugs"

Is that ok?

yawn- time to add a nice UI


Live the life you love, love the life you live
# 13 26-05-2006 , 06:47 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
yepp that's okay user added image

# 14 26-05-2006 , 06:49 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Posts: 189
I made this Icon for Maya some days ago...

Attached Images
File Type: bmp shelf_image.bmp (3.1 KB, 605 views)
# 15 26-05-2006 , 06:52 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
cool- oh and just so you know you moved the <name> tag inside the <phong> one, and it gives errors.

edit- I added a conditional that writes lambert1 if the name is InitialShading... whatever user added image


Live the life you love, love the life you live

Last edited by MattTheMan; 26-05-2006 at 06:55 PM.
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