MEL How-To #52 | ||
| ||
How do I get the names of the locators that animate a two- or three-node Camera's "View" and "Up" control if all I know is the name of the Camera?A two-node camera creates a locator which acts as the "view." The "view"
locator feeds its translation values into a "camera group" node which is
actually a node of type "lookAt". This "lookAt" node provides the constrain
values to control the camera's rotation attributes (‘ A three-node camera also creates the "view" node and connections as above, with
the addition of an "up" node. This is a simple locator node which feeds its
‘ To determine the locators that serve as the "view" and "up" controls, use
the The two MEL procedures below -- ‘
proc string getTransform( string $shape )
{
string $transform = $shape;
if ( "transform" != `nodeType $shape` )
// If given node is already a transform, just pass on through
{
string $parents[] = `listRelatives -fullPath -parent $shape`;
$transform = $parents[0];
}
return $transform;
}
proc string rootNode( string $object )
// Description: Strips the dot-suffix of the specified string.
{
string $buffer[];
tokenize $object "." $buffer;
return $buffer[0];
}
proc string getCameraView( string $cam )
{
string $cameraView = "";
// assert that we are querying the Camera's transform
$cam = getTransform( $cam );
// Is Camera's rotation constrained via a "lookAt" constraint?
if ( `connectionInfo -id ( $cam + ".rotateX" )` &&
nodeType( `connectionInfo -sfd ( $cam + ".rotateX" )` ) == "lookAt"
)
{
string $lookAt = rootNode( `connectionInfo -sfd
( $cam + ".rotateX" )` );
// What's the transform feeding the .target attribute?
if ( `connectionInfo -id ( $lookAt +
".target[0].targetTranslateX" )` )
{
$cameraView = rootNode( `connectionInfo -sfd ( $lookAt +
".target[0].targetTranslateX" )` );
}
}
return $cameraView;
}
proc string getCameraUp( string $cam )
{
string $cameraUp = "";
// assert that we are querying the Camera's transform
$cam = getTransform( $cam );
// Is Camera's rotation constrained via a "lookAt" constraint?
if ( `connectionInfo -id ( $cam + ".rotateX" )` &&
nodeType( `connectionInfo -sfd ( $cam + ".rotateX" )` ) == "lookAt"
)
{
string $lookAt =
rootNode( `connectionInfo -sfd ( $cam + ".rotateX" )` );
// What's the transform feeding the .worldUpMatrix attribute?
if ( `connectionInfo -id ( $lookAt + ".worldUpMatrix" )` )
{
$cameraUp = rootNode( `connectionInfo -sfd ( $lookAt +
".worldUpMatrix" )` );
}
}
return $cameraUp;
}
Wednesday, December 13, 2000 | ||
| Copyright ©2005 by Bryan Ewert, maya@ewertb.com Maya is a Registered Trademark of Alias |