home *** CD-ROM | disk | FTP | other *** search
- //
- // Copyright (C) 1997-2000 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 18 March 1998
- // Author: Shawn Dunn
- //
- //
- // Procedure Name:
- //
- // IKdisableWin
- //
- // Description:
- //
- // This script creates a window for enabling or disabling IK handles
- // When an IK handle has been selected you push the button in the
- // window and it selects all the joints associated with it and
- // then disables or enables the IK handle and sets keyframes on
- // the selected joints. This makes it easy to switch between animating
- // with forward and inverse kinematics.
- //
-
- //This procedure selects the joints associated with an IK handle. Sets
- //keyframes on the IK handle and the joints. It then disables or enables
- //the IK handle.
- //
-
- global proc ikOnOff()
- {
-
- //get a listing of any active IK handles
- //
- string $activeIKHandle[] = `ls -sl -type "ikHandle"`;
-
- //check to see if an IK handle is selected if it is not prompt
- //the user to select one
- //
- if (size($activeIKHandle) == 0)
- {
- print "Please pick an IK Handle";
- }
-
- //if the user has picked an IK handle do the following
- //
- else
- {
-
- //A for loop is needed in case more than one IK handle is selected
- //
- for ($activeIK in $activeIKHandle)
-
- {
- //We need to make sure that only one IK handle is selected
- //
- select $activeIK;
-
- //We need to be able to pick the joints that are contained within the
- //IK handle.The listConnections command is used to see what joints are
- //connected to the IK handle.
- //
-
- string $endEffector[] = `listConnections -type "ikEffector"`;
- string $lastJoint[] = `listConnections -type "joint" $endEffector`;
- string $firstJoint[] = `listConnections -type "joint"`;
-
- //Add the first and last joints to the selection and
- //then put the result in a variable
- //
- select -add $lastJoint $firstJoint;
- string $selectAll[] = `ls -sl`;
- select $lastJoint;
- $lastJoint = `ls -sl`;
-
- //Pick the last joint and then use pickWalk to go up to the first joint
- //using a while loop. Keep adding the new joint to the selection
- //
- while ($firstJoint[0] != $lastJoint[0])
- {
- string $newSelection[] = `pickWalk -d "up"`;
- select $selectAll $newSelection;
- $selectAll = `ls -sl`;
- select $newSelection;
- $lastJoint = $newSelection;
- }
- // Select the IK handle and the joints and set keyframes on them
- //
- select $selectAll;
- setKeyframe;
-
- //Enable or disable the IK handle. First check to see if the IK
- //handle is on or off
- //
- if (`getAttr ($activeIK + ".solverEnable")` == 1)
- {
- //if the IK handle is on turn it off by changing
- //the attribute
- //
- setAttr ($activeIK + ".solverEnable") 0;
- print ($activeIK + "'s solver has been disabled\n");
- }
- else
- {
- //if the IK handle is off turn it on by changing
- //the attribute
- //
- setAttr ($activeIK + ".solverEnable") 1;
- print ($activeIK + "'s solver has been enabled\n");
- }
- }
-
- //After running all the above return the selection to the original
- //IK handles
- //
- select $activeIKHandle;
- }
- }
-
-
-
- //Create a window with a button
- //
- global proc IKdisableWin()
- {
- string $wind = "IKdisable";
-
- //Check and see if the window exists
- //
- if (!`window -exists $wind`)
- {
-
- window
- -width 150
- -title "Disable/Enable IK"
- $wind;
-
- columnLayout
- -adjustableColumn true;
-
- button
- -label "Disable/Enable"
- -command "ikOnOff";
-
- showWindow $wind;
- }
- }
-