Digital humans the art of the digital double
Ever wanted to know how digital doubles are created in the movie industry? This course will give you an insight into how it's done.
# 16 26-05-2006 , 06:58 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Location: Norway
Posts: 189
Did I move <name>?
Huh... I thought I didn't move anything in the materials...
so what...

Yay to conditional that writes lambert1 if the name is InitialShading... hehe


Arne OOG - Makin' stuff
>>elqx Studios<<
# 17 27-05-2006 , 12:45 AM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
fixed script:

first- triangulate mesh. second- delete ALL history.

Then, run this script.
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";
		if($one == "initialMaterialInfo"){
			$one = "lambert1";
		}
		$write += "\t<name>"+$one+"</name>\n";
		$write += "\t<diffuse>\n";
		float $color[] = `getAttr ($one + ".color")`;
		$write+="\t\t<colour>"+$color[0]+" "+$color[1]+" "+$color[2]+"</colour>\n";
		$write += "\t</diffuse>\n";
		$write += "</material>\n";
	}
	if (`objectType $one` == "phong"){
		$write += "\n<material>\n";
		$write += "\t\t<name>"+$one+"</name>\n";
		$write += "\t<phong>\n";		
		float $col[] = `getAttr ($one + ".color")`;
		$write += "\t\t<diffuse>"+$col[0]+" "+$col[1]+" "+$col[2]+"</diffuse>\n";
		float $reflectivity = `getAttr($one +".reflectivity")`;
		if ($reflectivity > 0.0){
			$write += "\t\t<specular>"+$reflectivity+" "+$reflectivity+" "+$reflectivity+"</specular>\n";
		}
		if ($reflectivity == 0.0){
			float $refl[] = `getAttr ($one +".reflectedColor")`;
			$write += "\t\t<specular>"+$refl[0]+" "+$refl[1]+" "+$refl[2]+"</specular>\n";
		}		
		float $exp = `getAttr ($one + ".cosinePower")`;
		float $exp = $exp * 10;
		$write += "\t\t<exponent>"+$exp+"</exponent>\n";
		$write += "\t</phong>\n";
		$write += "</material>\n";
	}
}

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

//Models
string $trans[] =`ls -s`;
for ($one in $trans) {
			string $shape[] = `listRelatives -shapes $one`;
			if (`objectType $one` == "mesh"){
			$write += "\n\n<model>\n\t<pos>0 0 0</pos>";
		$write += "\n\t<scale>1</scale>";
		$write += "\n\t<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>";
	}
}
$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

Last edited by MattTheMan; 27-05-2006 at 01:54 PM.
# 18 27-05-2006 , 06:14 AM
Registered User
Join Date: Apr 2006
Posts: 10
Coming along nicely there, Matt!
I would've tried it...if I had Indigo.
I still tried it.
I forgot that I hadn't got maya.
Just PLE.

user added image
Arangol

# 19 27-05-2006 , 11:46 AM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Location: Norway
Posts: 189
There is one thing that still haven't been done...
Correcting the "maya Y" to "indigo Z"
It makes the Sky Light look really stupid :p

Could you try to add/fix that? user added image

In this image the sky light is lying sideways... even though I sat it directly above...

Attached Thumbnails

Arne OOG - Makin' stuff
>>elqx Studios<<

Last edited by arneoog; 27-05-2006 at 11:50 AM.
# 20 27-05-2006 , 01:18 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
umm... I should do that... but-

but- a bunch (ok, maybe not a bunch) of people actually have Maya Z as up. I do. You should change yours too.

But, if it does cause many more problems, i'll end up with a conditional that does that (if orientationUp == "Y")then... add the <rotation><matrix>whatever matrice does it</matrix></rotation>.

Oh- how did you fix the bug that didn't let you load? I'm curious.


Live the life you love, love the life you live
# 21 27-05-2006 , 01:26 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436

Originally posted by Arangol
Coming along nicely there, Matt!
I would've tried it...if I had Indigo.
I still tried it.
I forgot that I hadn't got maya.
Just PLE.

user added image
Arangol

lol, arangol... poor little peeps with their PLE user added image You can still get indigo if you want, its free! Find a link in the Indigo Unbiased Renderer thread- look for 0.5 tests.


Live the life you love, love the life you live
# 22 27-05-2006 , 01:28 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Location: Norway
Posts: 189
I tried to change it to Z up, but then all my models I've made suddenly rotaded and became totally screwed...
So I had to change it back...


hehe, okay I tell you :p

-You wrote <forewards> insted of <forwards>
-And I took the </embedded> before <triangle_set> away
-Last I removed all the <!-- --!>, I'm not quite sure why... hehe...

Edit: and you had </colour>0 0 1</colour>...
<colour>0 0 1</colour>...


Arne OOG - Makin' stuff
>>elqx Studios<<

Last edited by arneoog; 27-05-2006 at 01:34 PM.
# 23 27-05-2006 , 01:57 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
well... I guess I'll have to add the rotation matrices. See, the problem would have been the cameras- rotating -90 around the X axis. I guess I'll try it... but I'm not guaranteeing ANYTHING.

Oh- do you know the MEL name for orientation? Or should I just prompt the user "Is Y+ currently up?".


Live the life you love, love the life you live
# 24 27-05-2006 , 02:14 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Location: Norway
Posts: 189
I have no idea what the MEL name for orientation is...

Have you chacked the MEL Command Reference?


Arne OOG - Makin' stuff
>>elqx Studios<<
# 25 27-05-2006 , 03:20 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
yeah- I have... didn't find anything.

Well- MEL is slow. Very slow. I would have done this is C++ but... I can't hook it with Maya!!!!!

It took about 7 minutes to export 12000 polygons(24000tris) on my 3.2 ghz HT with 2 gigs of ram. user added image


Live the life you love, love the life you live
# 26 27-05-2006 , 03:23 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Location: Norway
Posts: 189
yes, it is slow... user added image


Arne OOG - Makin' stuff
>>elqx Studios<<
# 27 27-05-2006 , 03:25 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
oh- and I think there are some normal smoothing issues- either I am exporting them wrong or it's Indigo's fault. I'm pretty sure it's mine... and I will show you a before and after shot.


Live the life you love, love the life you live
# 28 27-05-2006 , 04:58 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
ok- here's a couple:

No Normal Smooth
user added image

With Normal Smooth
user added image

Odd Cube w/ Normal Smooth
user added image

Odd Torus
user added image


Live the life you love, love the life you live

Last edited by MattTheMan; 27-05-2006 at 06:13 PM.
# 29 27-05-2006 , 05:03 PM
arneoog's Avatar
Registered User
Join Date: Mar 2006
Location: Norway
Posts: 189
weird...

I haven't used normal smooth...
Why should I?


Arne OOG - Makin' stuff
>>elqx Studios<<
# 30 27-05-2006 , 05:05 PM
MattTheMan's Avatar
Registered User
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
well, so you don't get faceting in rendering... etc.

my latest post, btw had normal smoothing in the code.


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