Here we list a couple of scripts and tricks that can be useful when working with Craft Director Studio®.
Description: This is a script that can be used to generate tire track particles.Create a PF Source for each tire and place it slightly above the tire bottom and then link the PF Source to the respective “WheelCenterMesh”.
Also play back with “Real Time” unchecked in the “Time Configuration” dialog.
on ChannelsUsed pCont do ( pCont.useTime = true pCont.useAge = true pCont.usePosition = true pCont.useOrientation = true pCont.useSpeed = true ) on Init pCont do ( global initFrame = 40f --sliderTime as float global PFSource = $'PF Source 01' global distBetweenParticles = 0.3 global initTime = initFrame as float global distToPrevParticle = 0.0 global PFEuler = 0.0 ) on Proceed pCont do ( sTime = sliderTime as float previousParticlePos = pCont.particlePosition previousParticleTime = pCont.particleTime if( sliderTime < initFrame + 1f and sliderTime >= initFrame) then ( pCont.AddParticle() pCont.particleIndex = pCont.NumParticles() -- last particle that was added pCont.particleTime = sTime pCont.particleAge = 0 pCont.particlePosition = PFSource.pos PFEuler = PFSource.rotation as eulerAngles pCont.particleOrientation = [PFEuler.x,PFEuler.y,PFEuler.z] pCont.particleSpeed = [0, 0, 0] previousParticlePos = pCont.particlePosition previousParticleTime = pCont.particleTime ) if( sliderTime >= initFrame + 1f) then ( particlesSinceLastDrop = ((length (PFSource.pos - previousParticlePos))/distBetweenParticles) as float particlesSinceLastDrop_int = particlesSinceLastDrop as integer i = particlesSinceLastDrop as integer while ( i > 0) do ( pCont.AddParticle() pCont.particleIndex = pCont.NumParticles() -- last particle that was added pCont.particleTime = previousParticleTime + (particlesSinceLastDrop_int + 1 - i)*(sTime - previousParticleTime)/(particlesSinceLastDrop) pCont.particleAge = 0 pCont.particlePosition = previousParticlePos + (particlesSinceLastDrop_int + 1 - i)*(PFSource.pos - previousParticlePos)/(particlesSinceLastDrop) PFEuler = PFSource.rotation as eulerAngles pCont.particleOrientation = [PFEuler.x,PFEuler.y,PFEuler.z] pCont.particleSpeed = [0, 0, 0] i = i - 1 ) ) ) on Release pCont do ( )
Description: The guide below will show how to connect a Craft Camera together with VRayPhysicalCamera.
36.0/(2.0*tan(0.5*FOV*180.0/3.1415))
Notice the 36.0 at the start of the expression. This is the film gate (mm) value from the start of the guide. If you’re using a different value than 36, you will need to change the expression accordingly. Finally click Connect.
The window should update and look like this.
The VRayPhysicalCamera will then inherit all of the Craft Camera’s motion, along with the Target Distance and FOV values. Record the Craft Camera like you normally would and render using the VRayPhysicalCamera.
Usage: Select the the object you wish to move, then shift-select the object you want it to get aligned to (it aligns to its pivot).
{
// Author: Luigi Tramontana @ Craft Animations
// AT: Align Translations
// Usage: Select the the object you wish to move, then shift-select the object you wish it to get aligned to (it aligns to its pivot).
string $nodes[] = `ls -selection`;
float $pos[] = `xform -query -worldSpace -scalePivot $nodes[1]`;;
move -worldSpace ($pos[0]) ($pos[1]) ($pos[2]) $nodes[0];
};
You can select the script text in the Script Editor and drag it to a shelf spot to create a shortcut for it. Select MEL when prompted for MEL/Python.
This is a very useful script when working with cameras in Maya. It moves the selected camera to your current view and parents it to that camera (except when it’s the persp-camera).
Usage: Select the camera you want to move to the current view.
{
// Author: Luigi Tramontana @ Craft Animations
// MCP: Move Camera and Parent selected camera
// Usage: Select the camera you want to move to the current view
string $currPanel = `getPanel -withFocus`;
string $currCamera = `modelPanel -q -camera $currPanel`;
// Save the current position of the current camera.
string $homeName = `cameraView -camera $currCamera`;
// Get selection list. Gets listed in the selection order.
string $nodes[] = `ls -selection`;
if( `camera -q -orthographic $currCamera` == 0) // if not orthographic continue
{
// Make the selected camera identical to the current view.
cameraView -e -camera $nodes[0] -sc $homeName;
// Look through the selected camera.
lookThroughModelPanel $nodes[0] $currPanel; //lookThroughModelPanelClipped $nodes[0] $currPanel 0.001 1000;
if( `strcmp $currCamera persp` != 0) // if not persp camera, parent selected camera to it
{
// Parent the selected camera to the current.
parent $nodes[0] $currCamera;
}
}
};
You can select the script text in the Script Editor and drag it to a shelf spot to create a shortcut for it. Select MEL when prompted for MEL/Python.
Usage: Saves your current scene as a new file with its last two numbers increased by one, or if there are no numbers at the end adds ” 01″ to the file name.
{
// Author: Luigi Tramontana @ Craft Animations
// S++: Incremental Save
// Usage: Saves your current scene as a new file with its last two numbers increased by one, or if there are no numbers at the end adds " 01" to the file name.
$currentFilePathName = `file -q -sceneName`;
$currentFileType = `file -q -type`;
$fileType = endString( $currentFilePathName, 3);
$currentBaseName = basenameEx( $currentFilePathName);
$lastTwoChars = endString( $currentBaseName, 2);
if( strcmp( $lastTwoChars, "99") == 1)
{
$currentFilePathName = startString( $currentFilePathName, `size $currentFilePathName` - 3) + " 01" + $fileType;
}
else
{
$lastTwoCharsAsIntIcr = (int) $lastTwoChars;
$lastTwoChars = "";
$lastTwoCharsAsIntIcr = $lastTwoCharsAsIntIcr + 1;
if( $lastTwoCharsAsIntIcr < 10)
{
$lastTwoChars = (string) 0;
}
$lastTwoChars = $lastTwoChars + (string) $lastTwoCharsAsIntIcr;
$currentFilePathName = startString( $currentFilePathName, `size $currentFilePathName` - 5) + $lastTwoChars + $fileType;
}
file -rename $currentFilePathName;
file -save -type $currentFileType;
};
You can select the script text in the Script Editor and drag it to a shelf spot to create a shortcut for it. Select MEL when prompted for MEL/Python.
Description: The guide below will show how to connect a Craft Camera together with VRayPhysicalCamera.
cameraShape1.vrayCameraPhysicalFocalLength = ZoomAndFocusCam_01_Camera.focalLength
(Please Note that you need to change the ZoomAndFocusCam_01_Camera part of the expression if you’re using another Craft Camera so that the name matches accordingly. Click Create and then Close.)
Notice that the Focal length (in mm) value field has turned purple. It will now update its value automatically using the Craft Camera’s focal length value.