PDA

View Full Version : Exporting Z-sort Data?


timdose
03-20-2008, 09:06 PM
Hi

I'm working on a project that requires an animation of a character to be rendered broken into parts on separate render layers (i.e arms, hands, legs, torso, head, etc all on separate render layers) from multiple camera angles. The character then needs to be "recreated" by layering the rendered images in the correct order for a given frame from a given camera angle. Given that the sorting order may change from frame to frame, the problem is fairly complex and would ideally be done automatically somehow- especially as the number of parts is likely to grow quite a bit.

I was wondering if there's some way to determine such a sorting order via MEL (or python) and write out some kind of file at render time. I have noticed that Maya can render a Z-depth channel for an image, but I'm not sure how I would go about utilizing that data in this context. I suppose a simple text or XML file would suffice for our needs, though anything that could solve this problem would be great.

I understand that this could be done without the need to worry about z-sorting by setting the shader for the other parts to "use background", but due to some constraints that won't work in this particular situation (the individual parts will be swapped out, such that the character could change shirts, for example, and thus the alphas would no longer match up in a nice seam).

Any input would be greatly appreciated!

Tim

geonak
03-21-2008, 11:02 AM
following is a script i wrote for you in like 5 minutes :)
it works on simple scenes in which objects order follows their pivots order
hope it helps you , or at least guide you for your purpose
so if yours is a more complex scene in which pivots and objects aren't or the
same order we may in that case , use casted rays to determine the order
for any quests don't hesitate

Regards

Georges


string $input;
float $dist;
$fileName = "C:\\whatever.txt";
int $fileId=`fopen $fileName "w"`;

//select the objects you want to sort before running the script
//if you only have those objects in the scene just ommit the -sl
//and then you will not be obliged to select your objects vefore running the script

$allObjects = `ls -sl`;
for ( $obj in $allObjects ) {

//get your obj coordinates and your cam coordinates
//put them let us say in objX,objY...,camX,camY....

$dist = sqrt((objX-camX)^2 + (objY-camY)^2 + (objY-camY)^2)
$input = $dist;

//this way you are saving the name of the file then the distance from it to the camera
//you may want here, before saving , sorting all your objects with the respective distances
//then arranging them and saving each one with its depth order instead of the distance

fprint $fileId ($obj);
fprint $fileId ($input + "\n");
}

fclose $fileId;

CGTalk Moderation
03-21-2008, 11:02 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.