Published using Google Docs
na_space.txt
Updated automatically every 5 minutes

/**na_space.mel v1.0.0 tools for basic keying operations, used in space option tools

@note date created: Apr 26 2012

@note date last modified: Apr 30 2012

@note install

@note source na_assertGeneral.mel, naMath.mel

@note Inspired by Inspired by Jason Schleifer's Animator Friendly Rigging

@note not applicable if not allowed to have two different attributes to scroll down for spaces

@bug not used on a real rig yet, important special attribute is non keyable

@bug little error checking, ex that return for getconstraint is of constraint type, no checking

type before sending it out ex if expecting constraint need to verify before do anything with it even just

sending it out somewhere

*/

////

proc string

na_spaceGetAttrName_var()

{

        string $result = "naSpace";

        return $result;

}

proc string

na_spaceGetAttrNamePlugLetter_var()

{

        string $result = "Z";

        return $result;

}

proc string

na_spaceGetAttrNamePlugInput_var()

{

        string $result = "input1";

        return $result;

}

////

////how are constraints connected to multiply divide node

proc string

na_spaceGetCntTranslationPlugLetter_var()

{

        string $result = "X";

        return $result;

}

proc string

na_spaceGetCntTranslationPlugInput_var()

{

        string $result = "input2";

        return $result;

}

proc string

na_spaceGetCntRotationPlugLetter_var()

{

        string $result = "Y";

        return $result;

}

proc string

na_spaceGetCntRotationPlugInput_var()

{

        string $result = "input2";

        return $result;

}

////

////how are enums connected to multiply divide node

proc string

na_spaceGetTranslationEnumPlugLetter_var()

{

        string $result = "X";

        return $result;

}

proc string

na_spaceGetTranslationEnumPlugInput_var()

{

        string $result = "input1";

        return $result;

}

proc string

na_spaceGetRotationEnumPlugLetter_var()

{

        string $result = "Y";

        return $result;

}

proc string

na_spaceGetRotationEnumPlugInput_var()

{

        string $result = "input1";

        return $result;

}

////

/**

@bug no error checking, doesnt work on first frame, doesn't check specific node format

*/

global proc

na_space()

{

    string $sel[] = `ls -sl`;

    na_assertSizeEqualArg( $sel, 1 );

   

    string $anim = "";

    $anim = $sel[0];

    string $naAttr = na_spaceGetAttrName_var();

   

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertPrevFrameExists(); //make sure we can go to previous frame

    na_assertSpaceEnum( $anim, $naAttr );//make sure there is an enum for every space

    na_assertSpaceWeight( $anim, $naAttr );//make sure weight 1 or 0, at most one with 1

   

    //we are at a given frame we will

    //key old weights at their current values we don't touch them

    //on previous frame, and on the current frame, this is on the constraint itself

    //

    //

    //we then will move new constraining object to old one

    //on previous frame and on the current frame we do this before keying so we can have this

    //move stay

    //

    //we will then key old constraining objects position for now assume to do all its attributes

    //on previous frame and on the current frame again we haven't moved or changed anything

    //

    //we then key new constraining object at its new position

    //on previous frame and on the current frame

    //

    //we then set weight to one of the new on

    //current frame only, this is important not to do on previous frame

    //

    //finally we key the new weights on

    //current frame only

   

   

    na_moveNewCntObjectToOld( $anim, $naAttr );

    na_setKeyCntObject( $anim, $naAttr);

    na_setKeyOldWeight( $anim, $naAttr );

    na_setWeightNew($anim, $naAttr);

    na_setKeyNewWeight( $anim, $naAttr );

   

}

////

global proc

na_assertSpaceEnum(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

   

    if(size($translationCntWeightObject) > 0)

    {

        na_assertSpaceEnumTranslation($anim, $naAttr);

    }

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    if(size($rotationCntWeightObject) > 0)

    {

        na_assertSpaceEnumRotation($anim, $naAttr);

    }

   

}

global proc

na_assertSpaceWeight(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

   

    if(size($translationCntWeightObject) > 0)

    {

        na_assertSpaceWeightTranslation($anim, $naAttr);

    }

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    if(size($rotationCntWeightObject) > 0)

    {

        na_assertSpaceWeightRotation($anim, $naAttr);

    }

   

}

///space specific assert

/**make sure there is an enum for every space

*/

global proc

na_assertSpaceEnumTranslation(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $translationCntWeightObject, 1);

   

    //get enum for spaces

    string $translationSceneEnum[] = {};

    $translationSceneEnum = na_getTranslationSceneEnum($anim, $naAttr);

    na_assertSizeEqualArg( $translationSceneEnum, 1 );

   

    string $enumArray[] = {};

    string $objAndPlug[] = {};

    $objAndPlug = na_getObjectSepPlug( $translationSceneEnum[0]  );

    $enumArray = na_getEnumList( $anim, $objAndPlug[1] );

    na_assertSizeGreaterEqualTo( $enumArray, 1);

   

   

    na_assertSizeEqualArg( $translationCntWeightObject, size($enumArray) );

}

/**make sure weight 1 or 0, at most one with 1

*/

global proc

na_assertSpaceWeightTranslation(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $translationCntWeightObject, 1);

   

    float $weight = 0;

    int $numberWeightWithOne = 0;

   

    for($i = 0; $i < size($translationCntWeightObject); $i++ )

    {

        //for each weight assert 1 or 0

        $weight = `getAttr $translationCntWeightObject[$i]`;

        if( ($weight == 1) || ($weight == 0) ){}

        else{ error("expecting 1 or 0 for weights"); }

       

        //for all weight assert exactly one with 1

        if( $weight == 1 ){ $numberWeightWithOne++; }

        if( $numberWeightWithOne > 1 ){ error("expecting exactly one weight with one"); }

    }

}

///space specific assert

/**make sure there is an enum for every space

*/

global proc

na_assertSpaceEnumRotation(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $rotationCntWeightObject, 1);

   

    //get enum for spaces

    string $rotationSceneEnum[] = {};

    $rotationSceneEnum = na_getRotationSceneEnum($anim, $naAttr);

    na_assertSizeEqualArg( $rotationSceneEnum, 1 );

   

    string $enumArray[] = {};

    string $objAndPlug[] = {};

    $objAndPlug = na_getObjectSepPlug( $rotationSceneEnum[0]  );

    $enumArray = na_getEnumList( $anim, $objAndPlug[1] );

    na_assertSizeGreaterEqualTo( $enumArray, 1);

   

   

    na_assertSizeEqualArg( $rotationCntWeightObject, size($enumArray) );

}

/**make sure weight 1 or 0, at most one with 1

*/

global proc

na_assertSpaceWeightRotation(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $rotationCntWeightObject, 1);

   

    float $weight = 0;

    int $numberWeightWithOne = 0;

   

    for($i = 0; $i < size($rotationCntWeightObject); $i++ )

    {

        //for each weight assert 1 or 0

        $weight = `getAttr $rotationCntWeightObject[$i]`;

        if( ($weight == 1) || ($weight == 0) ){}

        else{ error("expecting 1 or 0 for weights"); }

       

        //for all weight assert exactly one with 1

        if( $weight == 1 ){ $numberWeightWithOne++; }

        if( $numberWeightWithOne > 1 ){ error("expecting exactly one weight with one"); }

    }

}

//space specific operations

/**

@bug no error checking

*/

global proc

na_setKeyOldWeight(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertPrevFrameExists();

    int $cur = `currentTime -query`;

    int $currentFrame = $cur;

    int $prevFrame = $currentFrame - 1;

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

   

    if(size($translationCntWeightObject) > 0)

    {

        currentTime $prevFrame;

        setKeyframe $translationCntWeightObject;

        currentTime $currentFrame;

        setKeyframe $translationCntWeightObject;

    }

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    if(size($rotationCntWeightObject) > 0)

    {

        currentTime $prevFrame;

        setKeyframe $rotationCntWeightObject;

        currentTime $currentFrame;

        setKeyframe $rotationCntWeightObject;

    }

   

    currentTime $cur;//restore key frame

}

/**

@bug not being clever about setting keys on translate only attr if needed, or rotate only attributes

*/

global proc

na_setKeyCntObject(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    string $translationCntObject[] = {};

    $translationCntObject = getTranslationSceneCntObject($anim,$naAttr);

   

    if(size($translationCntObject) > 0)

    {

        setKeyframe $translationCntObject;

    }

   

    string $rotationCntObject[] = {};

    $rotationCntObject = getRotationSceneCntObject($anim,$naAttr);

    if(size($rotationCntObject) > 0)

    {

        setKeyframe $rotationCntObject;

    }

   

}

/**

@bug no assert enum, existence attr ..,  existence new scene constraining object, enum length matches weights

no verifying enum is an enum

*/

global proc

na_moveNewCntObjectToOld(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertPrevFrameExists();

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

   

    if(size($translationCntWeightObject) > 0)

    {

        na_moveNewCntObjectToOldTranslation($anim, $naAttr);

    }

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    if(size($rotationCntWeightObject) > 0)

    {

        na_moveNewCntObjectToOldRotation($anim, $naAttr);

    }

   

}

/**

@bug no assert enum, existence attr ..,  existence new scene constraining object, enum length matches weights

no verifying enum is an enum, most objects includes plug which can be a little confusing sometimes

*/

global proc

na_moveNewCntObjectToOldTranslation(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertSpaceEnumTranslation($anim, $naAttr);

    na_assertSpaceWeightTranslation($anim, $naAttr);

    string $newSceneCntObject = "";

    $newSceneCntObject = na_getNewTranslationSceneObject($anim,$naAttr);

   

    string $oldSceneCntObject = "";

    $oldSceneCntObject = na_getOldTranslationSceneObject($anim,$naAttr);

   

   

    ////changing scene

    na_translationWorldFirstArgToSecond($newSceneCntObject,$oldSceneCntObject );

   

}

/**

@pre

@post

@bug may need to change your attribute names to match what they are suppose to be doing

*/

global proc string[]

na_getSceneCntObjectWithWeightOneTranslation(string $anim, string $naAttr)

{

    na_assertSpaceEnumTranslation($anim, $naAttr);

    na_assertSpaceWeightTranslation($anim, $naAttr);

   

   

   

    string $result[] = {};

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $translationCntWeightObject, 1);

   

    string $translationCntObject[] = {};

    $translationCntObject = getTranslationSceneCntObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $translationCntObject, 1);

   

    na_assertSizeEqualArg( $translationCntWeightObject, size($translationCntObject) );

   

    float $weight = 0;

    int $numberWeightWithOne = 0;

   

    //this is checking when weight equals one we know that should be the

    //constraing object

    for($i = 0; $i < size($translationCntWeightObject); $i++ )

    {

        //for each weight assert 1 or 0

        $weight = `getAttr $translationCntWeightObject[$i]`;

        if( $weight == 1  )

        {

            $result = {$translationCntObject[$i]};

            break;

        }

    }

   

    return $result;

}

/**

@bug no assert enum, existence attr ..,  existence new scene constraining object, enum length matches weights

no verifying enum is an enum, most objects includes plug which can be a little confusing sometimes

*/

global proc

na_moveNewCntObjectToOldRotation(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertSpaceEnumRotation($anim, $naAttr);

    na_assertSpaceWeightRotation($anim, $naAttr);

    string $newSceneCntObject = "";

    $newSceneCntObject = na_getNewRotationSceneObject($anim,$naAttr);

   

    string $oldSceneCntObject = "";

    $oldSceneCntObject = na_getOldRotationSceneObject($anim,$naAttr);

   

   

    ////changing scene

    na_rotationWorldFirstArgToSecond($newSceneCntObject,$oldSceneCntObject );

   

}

/**

*/

global proc string

na_getNewRotationSceneObject(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertSpaceEnumRotation($anim, $naAttr);

    na_assertSpaceWeightRotation($anim, $naAttr);

   

    string $result = "";

   

    //get enum for spaces

    string $rotationSceneEnum[] = {};

    $rotationSceneEnum = na_getRotationSceneEnum($anim, $naAttr);

    na_assertSizeEqualArg( $rotationSceneEnum, 1 );

    int $newSceneCntObjectIndex = 0;

    $newSceneCntObjectIndex = `getAttr $rotationSceneEnum[0]`;

   

    //get scene constraining objects

    string $rotationCntObject[] = {};

    $rotationCntObject = getRotationSceneCntObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $rotationCntObject, 1);

    string $newSceneCntObject = "";

    $newSceneCntObject = $rotationCntObject[ $newSceneCntObjectIndex ];

   

    $result = $newSceneCntObject;

   

    return $result;

}

/**

*/

global proc string

na_getOldRotationSceneObject(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertSpaceEnumRotation($anim, $naAttr);

    na_assertSpaceWeightRotation($anim, $naAttr);

   

    string $result = "";

   

    string $oldSceneCntObjectArray[] = {};

    $oldSceneCntObjectArray = na_getSceneCntObjectWithWeightOneRotation($anim,$naAttr);

    na_assertSizeEqualArg( $oldSceneCntObjectArray, 1 );

    string $oldSceneCntObject = "";

    $oldSceneCntObject = $oldSceneCntObjectArray[0];

   

    $result = $oldSceneCntObject;

   

    return $result;

}

/**

*/

global proc string

na_getNewTranslationSceneObject(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertSpaceEnumTranslation($anim, $naAttr);

    na_assertSpaceWeightTranslation($anim, $naAttr);

   

    string $result = "";

   

    //get enum for spaces

    string $translationSceneEnum[] = {};

    $translationSceneEnum = na_getTranslationSceneEnum($anim, $naAttr);

    na_assertSizeEqualArg( $translationSceneEnum, 1 );

    int $newSceneCntObjectIndex = 0;

    $newSceneCntObjectIndex = `getAttr $translationSceneEnum[0]`;

   

    //get scene constraining objects

    string $translationCntObject[] = {};

    $translationCntObject = getTranslationSceneCntObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $translationCntObject, 1);

    string $newSceneCntObject = "";

    $newSceneCntObject = $translationCntObject[ $newSceneCntObjectIndex ];

   

    $result = $newSceneCntObject;

   

    return $result;

}

/**

*/

global proc string

na_getOldTranslationSceneObject(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertSpaceEnumTranslation($anim, $naAttr);

    na_assertSpaceWeightTranslation($anim, $naAttr);

   

    string $result = "";

   

    string $oldSceneCntObjectArray[] = {};

    $oldSceneCntObjectArray = na_getSceneCntObjectWithWeightOneTranslation($anim,$naAttr);

    na_assertSizeEqualArg( $oldSceneCntObjectArray, 1 );

    string $oldSceneCntObject = "";

    $oldSceneCntObject = $oldSceneCntObjectArray[0];

   

    $result = $oldSceneCntObject;

   

    return $result;

}

/**

@pre

@post

@bug may need to change your attribute names to match what they are suppose to be doing

*/

global proc string[]

na_getSceneCntObjectWithWeightOneRotation(string $anim, string $naAttr)

{

    na_assertSpaceEnumRotation($anim, $naAttr);

    na_assertSpaceWeightRotation($anim, $naAttr);

   

   

   

    string $result[] = {};

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $rotationCntWeightObject, 1);

   

    string $rotationCntObject[] = {};

    $rotationCntObject = getRotationSceneCntObject($anim,$naAttr);

    na_assertSizeGreaterEqualTo( $rotationCntObject, 1);

   

    na_assertSizeEqualArg( $rotationCntWeightObject, size($rotationCntObject) );

   

    float $weight = 0;

    int $numberWeightWithOne = 0;

   

    //this is checking when weight equals one we know that should be the

    //constraing object

    for($i = 0; $i < size($rotationCntWeightObject); $i++ )

    {

        //for each weight assert 1 or 0

        $weight = `getAttr $rotationCntWeightObject[$i]`;

        if( $weight == 1  )

        {

            $result = {$rotationCntObject[$i]};

            break;

        }

    }

   

    return $result;

}

global proc

na_setWeightNew(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

   

    if(size($translationCntWeightObject) > 0)

    {

        na_setWeightNewTranslation($anim, $naAttr);

    }

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    if(size($rotationCntWeightObject) > 0)

    {

        na_setWeightNewRotation($anim, $naAttr);

    }

   

}

/**

@pre should be on frame we are changing space

@bug no checking same size weight and constraint objects, no index checking

*/

global proc

na_setWeightNewRotation(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertSpaceEnumRotation($anim, $naAttr);

    na_assertSpaceWeightRotation($anim, $naAttr);

   

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    string $rotationCntObject[] = {};

    $rotationCntObject = getRotationSceneCntObject($anim,$naAttr);

   

   

    string $newSceneCntObject = "";

    $newSceneCntObject = na_getNewRotationSceneObject($anim,$naAttr);

    na_assertObjectExist( {$newSceneCntObject} );

   

   

    int $newIndex[] = {};

    $newIndex = naIndex( $newSceneCntObject, $rotationCntObject  );

    na_assertIntSizeEqualArg( $newIndex, 1 );

    string $newScenCntWeightObject = "";

    $newSceneCntWeightObject = $rotationCntWeightObject[$newIndex[0]];

   

   

    string $oldSceneCntObject = "";

    $oldSceneCntObject = na_getOldRotationSceneObject($anim,$naAttr);

    na_assertObjectExist( {$oldSceneCntObject} );

   

   

    int $oldIndex[] = {};

    $oldIndex = naIndex( $oldSceneCntObject, $rotationCntObject  );

    na_assertIntSizeEqualArg( $oldIndex, 1 );

    string $oldScenCntWeightObject = "";

    $oldSceneCntWeightObject = $rotationCntWeightObject[$oldIndex[0]];

   

    setAttr $oldSceneCntWeightObject 0; //no weight on old constraining object

    setAttr $newSceneCntWeightObject 1; //all weight on new constraining object

   

   

}

/**

@pre should be on frame we are changing space

@bug no checking same size weight and constraint objects, no index checking

*/

global proc

na_setWeightNewTranslation(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

    na_assertSpaceEnumTranslation($anim, $naAttr);

    na_assertSpaceWeightTranslation($anim, $naAttr);

   

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

    string $translationCntObject[] = {};

    $translationCntObject = getTranslationSceneCntObject($anim,$naAttr);

   

   

    string $newSceneCntObject = "";

    $newSceneCntObject = na_getNewTranslationSceneObject($anim,$naAttr);

    na_assertObjectExist( {$newSceneCntObject} );

   

   

    int $newIndex[] = {};

    $newIndex = naIndex( $newSceneCntObject, $translationCntObject  );

    na_assertIntSizeEqualArg( $newIndex, 1 );

    string $newScenCntWeightObject = "";

    $newSceneCntWeightObject = $translationCntWeightObject[$newIndex[0]];

   

   

    string $oldSceneCntObject = "";

    $oldSceneCntObject = na_getOldTranslationSceneObject($anim,$naAttr);

    na_assertObjectExist( {$oldSceneCntObject} );

   

   

    int $oldIndex[] = {};

    $oldIndex = naIndex( $oldSceneCntObject, $translationCntObject  );

    na_assertIntSizeEqualArg( $oldIndex, 1 );

    string $oldScenCntWeightObject = "";

    $oldSceneCntWeightObject = $translationCntWeightObject[$oldIndex[0]];

   

   

    setAttr $oldSceneCntWeightObject 0; //no weight on old constraining object

    setAttr $newSceneCntWeightObject 1; //all weight on new constraining object

   

}

/**

@pre assume on frame changing space

@bug no error checking

*/

global proc

na_setKeyNewWeight(string $anim, string $naAttr)

{

    na_assertObjectExist( {$anim+"."+$naAttr} );

   

   

    string $translationCntWeightObject[] = {};

    $translationCntWeightObject = getTranslationSceneCntWeightObject($anim,$naAttr);

   

    if(size($translationCntWeightObject) > 0)

    {

        na_assertSpaceEnumTranslation($anim, $naAttr);

        na_assertSpaceWeightTranslation($anim, $naAttr);

       

        setKeyframe $translationCntWeightObject;

    }

   

    string $rotationCntWeightObject[] = {};

    $rotationCntWeightObject = getRotationSceneCntWeightObject($anim,$naAttr);

    if(size($rotationCntWeightObject) > 0)

    {

        na_assertSpaceEnumRotation($anim, $naAttr);

        na_assertSpaceWeightRotation($anim, $naAttr);

        setKeyframe $rotationCntWeightObject;

    }

   

}

/**get enum for space options whether for translation or rotation

@param string $anim animator control with a specific attribute to access network

@param int $moveType either 1 for translation or 2 for rotation

@pre a specific node network is setup see more info in figure

@post returns enum for space switching

@note moveType 1 for translation, 2 for rotation

@see getTranslationSceneEnum

@see getRotationSceneEnum

*/

global proc string[]

na_spaceGetSceneEnum(string $anim, int $moveType)

{

   

        string $naAttr = na_spaceGetAttrName_var();

        na_assertObjectExist({$anim,($anim+"."+$naAttr)});

        

        string $sceneObjects[] = {};

        

        if( $moveType == 1 ){

            $sceneObjects = getTranslationSceneEnum($anim,$naAttr);

        }

        else if( $moveType == 2 ){

            $sceneObjects = getRotationSceneEnum($anim,$naAttr);

        }

        

        return $sceneObjects;

}

/**get enum for space options for Translation

@param string $anim animator control with a specific attribute to access network

@param string $naAttr name for attribute whose input is to a multiply divide node

@pre a specific node network is setup see more info in figure

@post returns weights for space switching

@see na_spaceGetSceneCnt

@see na_getInConstraintPlug

@bug no constraint type checking

*/

global proc string[]

na_getTranslationSceneEnum(string $anim, string $naAttr)

{

    na_assertObjectExist({$anim,($anim+"."+$naAttr)});

        string $result[] = {};

        

        //find data node from animator control

        string $mdArray[] = {};

        $mdArray = na_getMultiplyDivideNodeFromPlug( $anim, $naAttr );

        na_assertSizeEqualArg($mdArray,1);

        string $node = "";

        $node = $mdArray[0];

        

        

        string $plugLetter = na_spaceGetTranslationEnumPlugLetter_var();

        string $plugInput = na_spaceGetTranslationEnumPlugInput_var();

        string $plug = "";

        $plug = $plugInput+$plugLetter;

        

        $result = `listConnections -source true -plugs true ($node+"."+$plug)`;

        

        return $result;

}

/**get enum for space options for Rotation

@param string $anim animator control with a specific attribute to access network

@param string $naAttr name for attribute whose input is to a multiply divide node

@pre a specific node network is setup see more info in figure

@post returns weights for space switching

@see na_spaceGetSceneCnt

@see na_getInConstraintPlug

@bug no constraint type checking

*/

global proc string[]

na_getRotationSceneEnum(string $anim, string $naAttr)

{

    na_assertObjectExist({$anim,($anim+"."+$naAttr)});

        string $result[] = {};

        

        //find data node from animator control

        string $mdArray[] = {};

        $mdArray = na_getMultiplyDivideNodeFromPlug( $anim, $naAttr );

        na_assertSizeEqualArg($mdArray,1);

        string $node = "";

        $node = $mdArray[0];

        

        

        string $plugLetter = na_spaceGetRotationEnumPlugLetter_var();

        string $plugInput = na_spaceGetRotationEnumPlugInput_var();

        string $plug = "";

        $plug = $plugInput+$plugLetter;

        

        $result = `listConnections -source true -plugs true ($node+"."+$plug)`;

        

        return $result;

}

/**get weights for space options whether for translation or rotation

@param string $anim animator control with a specific attribute to access network

@param int $moveType either 1 for translation or 2 for rotation

@pre a specific node network is setup see more info in figure

@post returns weights for space switching

@note moveType 1 for translation, 2 for rotation

@see getTranslationSceneCntWeightObject

@see getRotationSceneCntWeightObject

*/

global proc string[]

na_spaceGetSceneCntWeightObject(string $anim, int $moveType)

{

   

        string $naAttr = na_spaceGetAttrName_var();

        na_assertObjectExist({$anim,($anim+"."+$naAttr)});

        

        string $sceneObjects[] = {};

        

        if( $moveType == 1 ){

            $sceneObjects = getTranslationSceneCntWeightObject($anim,$naAttr);

        }

        else if( $moveType == 2 ){

            $sceneObjects = getRotationSceneCntWeightObject($anim,$naAttr);

        }

        

        return $sceneObjects;

}

/**get weights for space options for translation

@param string $anim animator control with a specific attribute to access network

@param string $naAttr name for attribute whose input is to a multiply divide node

@pre a specific node network is setup see more info in figure

@post returns weights for space switching

@see na_spaceGetSceneCnt

@see na_getInConstraintPlug

@bug no constraint type checking

*/

global proc string[]

getTranslationSceneCntWeightObject(string $anim, string $naAttr)

{

    na_assertObjectExist({$anim,($anim+"."+$naAttr)});

   

        string $result[] = {};

        

        string $cntArray[] = {};

        $cntArray = na_spaceGetSceneCnt($anim, 1);

        string $cnt = "";

        

        if( size($cntArray) == 1 ){

            $cnt = $cntArray[0];        

            $result = na_getInConstraintPlug($cnt);

        }

        

        return $result;

}

/**get weights for space options for rotation

@param string $anim animator control with a specific attribute to access network

@param string $naAttr name for attribute whose input is to a multiply divide node

@pre a specific node network is setup see more info in figure

@post returns weights for space switching

@see na_spaceGetSceneCnt

@see na_getInConstraintPlug

@bug no constraint type checking

*/

global proc string[]

getRotationSceneCntWeightObject(string $anim, string $naAttr)

{

    na_assertObjectExist({$anim,($anim+"."+$naAttr)});

   

        string $result[] = {};

        

        string $cntArray[] = {};

        $cntArray = na_spaceGetSceneCnt($anim, 2);

        string $cnt = "";

        

        if( size($cntArray) == 1 ){

            $cnt = $cntArray[0];        

           

            $result = na_getInConstraintPlug($cnt);

        }

        

        return $result;

}

/**

@note moveType 1 for translation, 2 for rotation

*/

global proc string[]

na_spaceGetSceneCntObject(string $anim, int $moveType)

{

        string $naAttr = na_spaceGetAttrName_var();

        na_assertObjectExist({$anim,($anim+"."+$naAttr)});

        

        string $sceneObjects[] = {};

        

        if( $moveType == 1 ){

            $sceneObjects = getTranslationSceneCntObject($anim,$naAttr);

        }

        else if( $moveType == 2 ){

            $sceneObjects = getRotationSceneCntObject($anim,$naAttr);

        }

        

        return $sceneObjects;

}

global proc string[]

getTranslationSceneCntObject(string $anim, string $naAttr)

{

    na_assertObjectExist({$anim,($anim+"."+$naAttr)});

        string $result[] = {};

        

        string $cntArray[] = {};

        $cntArray = na_spaceGetSceneCnt($anim, 1);

        string $cnt = "";

        if( size($cntArray) == 1 ){

            $cnt = $cntArray[0];  

            $result = na_getInConstraint($cnt);

        }

        

        return $result;

}

global proc string[]

getRotationSceneCntObject(string $anim, string $naAttr)

{

    na_assertObjectExist({$anim,($anim+"."+$naAttr)});

   

        string $result[] = {};

        

        string $cntArray[] = {};

        $cntArray = na_spaceGetSceneCnt($anim, 2);

        string $cnt = "";

        

        if( size($cntArray) == 1 ){

            $cnt = $cntArray[0];  

            $result = na_getInConstraint($cnt);

        }

        

        return $result;

}

/**give the contraint name corresponding to either translation or rotation for animator control

@note it finds it using an attribute on the animator control

@note moveType 1 for translation, 2 for rotation

@bug not tested in practice

@see  na_getInputFromSingleMDNodeFromAnim

*/

global proc string[]

na_spaceGetSceneCnt(string $anim, int $moveType)

{

        string $naAttr = na_spaceGetAttrName_var();

        na_assertObjectExist({$anim,($anim+"."+$naAttr)});

        

        string $sceneObjects[] = {};

        

        if( $moveType == 1 ){

            string $plugLetterTranslation = "";

            $plugLetterTranslation = na_spaceGetCntTranslationPlugLetter_var();

            string $plugInputTranslation = "";

            $plugInputTranslation = na_spaceGetCntTranslationPlugInput_var();

            $sceneObjects = na_getInputFromSingleMDNodeFromAnim($anim,$naAttr, $plugLetterTranslation, $plugInputTranslation);

        }

        else if( $moveType == 2 ){

            string $plugLetterRotation = "";

            $plugLetterRotation = na_spaceGetCntRotationPlugLetter_var();

            string $plugInputRotation = "";

            $plugInputRotation = na_spaceGetCntRotationPlugInput_var();

           

            $sceneObjects = na_getInputFromSingleMDNodeFromAnim($anim,$naAttr, $plugLetterRotation, $plugInputRotation);

        }

        return $sceneObjects;

}