Camera Path Animation

Forums: Camera Path Animation
Forum for OctaneRender Lua scripting examples, discussion and support.

Re: Camera Path Animation

Postby erges » Fri Jun 13, 2014 1:33 pm

erges Fri Jun 13, 2014 1:33 pm
I've found this mel for Maya path animation, but it makes a bit different code. Instead of "," sign it does "#", and at the end it write additional #0#1#0:

-22.99270358#31.09716012#21.56283787#0.473509088#0.792945669#-0.3834400991#54.43222358#0#1#0
-22.98582183#31.09823494#21.56220702#0.4734152751#0.7929300934#-0.3835881181#54.43222358#0#1#0
-22.96530924#31.10144289#21.56032049#0.4731355279#0.792883499#-0.3840293337#54.43222358#0#1#0
erges
Licensed Customer
Licensed Customer
 
Posts: 46
Joined: Thu Dec 22, 2011 12:45 pm

Re: Camera Path Animation

Postby erges » Fri Jun 13, 2014 1:36 pm

erges Fri Jun 13, 2014 1:36 pm
If someone can edit this script to get right output please.
Here is the body:

$startRange = `getAttr "defaultRenderGlobals.startFrame"`;
$endRange = `getAttr "defaultRenderGlobals.endFrame"`;
$byFrame = `getAttr "defaultRenderGlobals.byFrameStep"`;

float $animStart = `playbackOptions -q -minTime`;
float $animEnd = `playbackOptions -q -maxTime`;
float $animStep = 1;
string $animCmdLine = "";
int $f = int ($animEnd) - int ($animStart) + 1;

$filePath = ( `internalVar -userAppDir` + "MayaCamera.txt" );
$fileId=`fopen $filePath "w"`;
fprint $fileId ("\n");
fclose $fileId;

for ($n=int ($animStart);$n<=int ($animEnd);$n = $n + int($animStep))
{

currentTime -e $n;


string $camPos = getPos();
string $camVec = getVector();
string $camAim = getAim();
string $camFov = getFov();



$animCmdLine =$camPos + $camVec + $camFov + $camAim ;
//print ($animCmdLine +"\n");

$filePath = ( `internalVar -userAppDir` + "MayaCamera.txt" );
$fileId=`fopen $filePath "a"`;
fprint $fileId ($animCmdLine+"\n");
fclose $fileId;

}


global proc string getPos()
{
string $camPos;

string $cameraName;
string $panel = `getPanel -wf`;
if ( "modelPanel" == `getPanel -to $panel` )
{
// Get the name of the camera using the ‘modelEditor’ command
$cameraName = `modelEditor -q -camera $panel`;
}


float $camPosXYZ[] = `camera -q -p $cameraName`;
$camPos =$camPosXYZ[0] + "#" + $camPosXYZ[1]+ "#" + $camPosXYZ[2];

return $camPos;
}


global proc string getVector()
{

string $camVector;
string $cameraName;
string $panel = `getPanel -wf`;
if ( "modelPanel" == `getPanel -to $panel` )
{
// Get the name of the camera using the ‘modelEditor’ command
$cameraName = `modelEditor -q -camera $panel`;
}


float $camUpXYZ[] = `camera -q -wup $cameraName`;
$camVector ="#" + $camUpXYZ[0] + "#" + $camUpXYZ[1]+ "#" + $camUpXYZ[2];

return $camVector;
}


global proc string getAim()
{

string $camAim;
string $cameraName;
string $panel = `getPanel -wf`;
if ( "modelPanel" == `getPanel -to $panel` )
{
// Get the name of the camera using the ‘modelEditor’ command
$cameraName = `modelEditor -q -camera $panel`;
}

float $camAimXYZ[] = `camera -q -wci $cameraName`;
$camAim = "#" + 0 + "#" + 1 + "#" + 0;

return $camAim;
}


global proc string getFov()
{

string $camFov;
string $cameraName;
string $panel = `getPanel -wf`;
if ( "modelPanel" == `getPanel -to $panel` )
{
// Get the name of the camera using the ‘modelEditor’ command
$cameraName = `modelEditor -q -camera $panel`;
}

float $camAperture = `getAttr ($cameraName + ".horizontalFilmAperture")`;
float $camFocalLenght = 35;
float $camFovValue = (0.5 * $camAperture) / ($camFocalLenght * 0.03937);
$camFovValue = 2.0 * atan ($camFovValue);
$camFovValue = 57.29578 * $camFovValue;
$camFov = "#" + (string)$camFovValue;

return $camFov;
}
erges
Licensed Customer
Licensed Customer
 
Posts: 46
Joined: Thu Dec 22, 2011 12:45 pm
Previous

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 3 guests

Fri Nov 27, 2020 1:27 pm [ UTC ]