|
Hey There,
Here is some code you can use to write out the basic functionallity or at least put you in the right direction.
All you need to do now is read the docs on how the xform tool works to work out how to extract the rotations and scale for the object.
snip-->
// where ever you want to open the file that you want to write to.
string $animFile = “c:/temp/animation.txt”;
// opeing the file in a file handel
int $fileId = `fopen $animFile “w"`;
// now the file is open, writing a mel style comment to the top.
fprint($fileId,"\/\/this is my per frame animation file\n");
// getting the start and end frames of the animation from the render globals, you can get this infor from any where or hardcode it.
int $startFrame = `getAttr “defaultRenderGlobals.startFrame"`;
int $endFrame = `getAttr “defaultRenderGlobals.endFrame"`;
// this is my object transform, the ojject i want its animation
string $object = “persp”;
// simple line to show the format of my file.
// \t is a tab space
fprint($fileId,"attr\t\t frame \t\t x\t\t y\t\t z \n");
// $current frame is my increment var
int $currentFrame = $startFrame;
// my chossen loop for this exersize , giving the end frame a padding of 1.
while ($currentFrame != ($endFrame+1))
{
//setting the maya timeline to my current frame
currentTime -e $currentFrame;
//get transformations using the xform tool.
float $trans[] = `xform -q -t -ws $object`;
//writting the formatted line to the file
fprint($fileId,"trans “+$currentFrame+” “+$trans[0]+"\t\t"+$trans[1]+"\t\t"+$trans[2]+" \n");
// read xform on how to get the rotation and scale of an ojbect.
//incrementing the count.
$currentFrame++;
}
// closing the file handle
fclose $fileId;
<--snip
Another way you could do this, but its more complicated to read the files in, is to export out the meshes to mi files with mentalray.
But at least the above code will put you in the right direction.
Hope this helps.
Cheers
Kym
|