Advertisement
Guest User

Untitled

a guest
Jul 15th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 24.44 KB | None | 0 0
  1. import vs
  2.  
  3. #==================================================================================================
  4. def AddValidObjectToList( objectList, obj ):
  5.     if ( obj != None ): objectList.append( obj )
  6.    
  7.  
  8. #==================================================================================================
  9. def HideControlGroups( rig, rootGroup, *groupNames ):
  10.     for name in groupNames:    
  11.         group = rootGroup.FindChildByName( name, False )
  12.         if ( group != None ):
  13.             rig.HideControlGroup( group )
  14.  
  15.    
  16. #==================================================================================================
  17. # Create the reverse foot control and operators for the foot on the specified side
  18. #==================================================================================================
  19. def CreateReverseFoot( controlName, sideName, gameModel, animSet, shot, helperControlGroup, footControlGroup ) :
  20.    
  21.     # Cannot create foot controls without heel position, so check for that first
  22.     heelAttachName = "pvt_heel_" + sideName
  23.     if ( gameModel.FindAttachment( heelAttachName ) == 0 ):
  24.         print "Could not create foot control " + controlName + ", model is missing heel attachment point: " + heelAttachName;
  25.         return None
  26.    
  27.     footRollDefault = 0.5
  28.     rotationAxis = vs.Vector( 1, 0, 0 )
  29.        
  30.     # Construct the name of the dag nodes of the foot and toe for the specified side
  31.     footName = "rig_foot_" + sideName
  32.     toeName = "rig_toe_" + sideName    
  33.    
  34.     # Get the world space position and orientation of the foot and toe
  35.     footPos = sfm.GetPosition( footName )
  36.     footRot = sfm.GetRotation( footName )
  37.     toePos = sfm.GetPosition( toeName )
  38.    
  39.     # Setup the reverse foot hierarchy such that the foot is the parent of all the foot transforms, the
  40.     # reverse heel is the parent of the heel, so it can be used for rotations around the ball of the
  41.     # foot that will move the heel, the heel is the parent of the foot IK handle so that it can perform
  42.     # rotations around the heel and move the foot IK handle, resulting in moving all the foot bones.
  43.     # root
  44.     #   + rig_foot_R
  45.     #       + rig_knee_R
  46.     #       + rig_reverseHeel_R
  47.     #           + rig_heel_R
  48.     #               + rig_footIK_R
  49.    
  50.  
  51.     # Construct the reverse heel joint this will be used to rotate the heel around the toe, and as
  52.     # such is positioned at the toe, but using the rotation of the foot which will be its parent,
  53.     # so that it has no local rotation once parented to the foot.
  54.     reverseHeelName = "rig_reverseHeel_" + sideName
  55.     reverseHeelDag = sfm.CreateRigHandle( reverseHeelName, pos=toePos, rot=footRot, rotControl=False )
  56.     sfmUtils.Parent( reverseHeelName, footName, vs.REPARENT_LOGS_OVERWRITE )
  57.    
  58.    
  59.    
  60.     # Construct the heel joint, this will be used to rotate the foot around the back of the heel so it
  61.     # is created at the heel location (offset from the foot) and also given the rotation of its parent.
  62.     heelName = "rig_heel_" + sideName
  63.     vecHeelPos = gameModel.ComputeAttachmentPosition( heelAttachName )
  64.     heelPos = [ vecHeelPos.x, vecHeelPos.y, vecHeelPos.z ]    
  65.     heelRot = sfm.GetRotation( reverseHeelName )
  66.     heelDag = sfm.CreateRigHandle( heelName, pos=heelPos, rot=heelRot, posControl=True, rotControl=False )
  67.     sfmUtils.Parent( heelName, reverseHeelName, vs.REPARENT_LOGS_OVERWRITE )
  68.    
  69.     # Create the ik handle which will be used as the target for the ik chain for the leg
  70.     ikHandleName = "rig_footIK_" + sideName  
  71.     ikHandleDag = sfmUtils.CreateHandleAt( ikHandleName, footName )
  72.     sfmUtils.Parent( ikHandleName, heelName, vs.REPARENT_LOGS_OVERWRITE )
  73.                    
  74.     # Create an orient constraint which causes the toe's orientation to match the foot's orientation
  75.     footRollControlName = controlName + "_" + sideName
  76.     toeOrientTarget = sfm.OrientConstraint( footName, toeName, mo=True, controls=False )
  77.     footRollControl, footRollValue = sfmUtils.CreateControlledValue( footRollControlName, "value", vs.AT_FLOAT, footRollDefault, animSet, shot )
  78.    
  79.     # Create the expressions to re-map the footroll slider value for use in the constraint and rotation operators
  80.     toeOrientExprName = "expr_toeOrientEnable_" + sideName    
  81.     toeOrientExpr = sfmUtils.CreateExpression( toeOrientExprName, "inrange( footRoll, 0.5001, 1.0 )", animSet )
  82.     toeOrientExpr.SetValue( "footRoll", footRollDefault )
  83.    
  84.     toeRotateExprName = "expr_toeRotation_" + sideName
  85.     toeRotateExpr = sfmUtils.CreateExpression( toeRotateExprName, "max( 0, (footRoll - 0.5) ) * 140", animSet )
  86.     toeRotateExpr.SetValue( "footRoll", footRollDefault )
  87.                            
  88.     heelRotateExprName = "expr_heelRotation_" + sideName
  89.     heelRotateExpr = sfmUtils.CreateExpression( heelRotateExprName, "max( 0, (0.5 - footRoll) ) * -100", animSet )
  90.     heelRotateExpr.SetValue( "footRoll", footRollDefault )
  91.        
  92.     # Create a connection from the footroll value to all of the expressions that require it
  93.     footRollConnName = "conn_footRoll_" + sideName
  94.     footRollConn = sfmUtils.CreateConnection( footRollConnName, footRollValue, "value", animSet )
  95.     footRollConn.AddOutput( toeOrientExpr, "footRoll" )
  96.     footRollConn.AddOutput( toeRotateExpr, "footRoll" )
  97.     footRollConn.AddOutput( heelRotateExpr, "footRoll" )
  98.    
  99.     # Create the connection from the toe orientation enable expression to the target weight of the
  100.     # toe orientation constraint, this will turn the constraint on an off based on the footRoll value
  101.     toeOrientConnName = "conn_toeOrientExpr_" + sideName;
  102.     toeOrientConn = sfmUtils.CreateConnection( toeOrientConnName, toeOrientExpr, "result", animSet )
  103.     toeOrientConn.AddOutput( toeOrientTarget, "targetWeight" )
  104.     # toeOrientTarget( toeOrientConn.AddOutput, "targetHeight" )
  105.    
  106.     # Create a rotation constraint to drive the toe rotation and connect its input to the
  107.     # toe rotation expression and connect its output to the reverse heel dag's orientation
  108.     toeRotateConstraintName = "rotationConstraint_toe_" + sideName
  109.     toeRotateConstraint = sfmUtils.CreateRotationConstraint( toeRotateConstraintName, rotationAxis, reverseHeelDag, animSet )
  110.    
  111.     toeRotateExprConnName = "conn_toeRotateExpr_" + sideName
  112.     toeRotateExprConn = sfmUtils.CreateConnection( toeRotateExprConnName, toeRotateExpr, "result", animSet )
  113.     toeRotateExprConn.AddOutput( toeRotateConstraint, "rotations", 0 );
  114.  
  115.     # Create a rotation constraint to drive the heel rotation and connect its input to the
  116.     # heel rotation expression and connect its output to the heel dag's orientation
  117.     heelRotateConstraintName = "rotationConstraint_heel_" + sideName
  118.     heelRotateConstraint = sfmUtils.CreateRotationConstraint( heelRotateConstraintName, rotationAxis, heelDag, animSet )
  119.    
  120.     heelRotateExprConnName = "conn_heelRotateExpr_" + sideName
  121.     heelRotateExprConn = sfmUtils.CreateConnection( heelRotateExprConnName, heelRotateExpr, "result", animSet )
  122.     heelRotateExprConn.AddOutput( heelRotateConstraint, "rotations", 0 )
  123.    
  124.     if ( helperControlGroup != None ):
  125.         sfmUtils.AddDagControlsToGroup( helperControlGroup, reverseHeelDag, ikHandleDag, heelDag )      
  126.    
  127.     if ( footControlGroup != None ):
  128.         footControlGroup.AddControl( footRollControl )
  129.        
  130.     return ikHandleDag
  131.  
  132.  
  133. #==================================================================================================
  134. # Build a simple ik rig for the currently selected animation set
  135. #==================================================================================================
  136. def BuildRig():
  137.    
  138.     # Get the currently selected animation set and shot
  139.     shot = sfm.GetCurrentShot()
  140.     animSet = sfm.GetCurrentAnimationSet()
  141.     gameModel = animSet.gameModel
  142.     rootGroup = animSet.GetRootControlGroup()
  143.    
  144.     # Start the biped rig to which all of the controls and constraints will be added
  145.     rig = sfm.BeginRig( "rig_biped_" + animSet.GetName() );
  146.     if ( rig == None ):
  147.         return
  148.    
  149.     # Change the operation mode to passthrough so changes chan be made temporarily
  150.     sfm.SetOperationMode( "Pass" )
  151.    
  152.     # Move everything into the reference pose
  153.     sfm.SelectAll()
  154.     sfm.SetReferencePose()
  155.    
  156.     #==============================================================================================
  157.     # Find the dag nodes for all of the bones in the model which will be used by the script
  158.     #==============================================================================================
  159.     boneRoot      = sfmUtils.FindFirstDag( [ "RootTransform" ], True )
  160.     bonePelvis    = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_Pelvis",     "Bip01_Pelvis",     "bip_pelvis" ], True )
  161.     boneSpine0    = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_Spine",      "Bip01_Spine",      "bip_spine_0" ], True )
  162.     boneSpine1    = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_Spine1",     "Bip01_Spine1",     "bip_spine_1" ], True )
  163.     boneSpine2    = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_Spine2",     "Bip01_Spine2",     "bip_spine_2" ], True )
  164.     boneNeck      = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_Neck",       "Bip01_Neck",       "bip_neck_0",   "bip_neck", "ValveBiped.Bip01_Neck1" ], True )
  165.     boneHead      = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_Head",       "Bip01_Head",       "bip_head",     "ValveBiped.Bip01_Head1" ], True )
  166.    
  167.     boneUpperLegR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Thigh",    "Bip01_R_Thigh",    "bip_hip_R" ], True )
  168.     boneLowerLegR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Calf",     "Bip01_R_Calf",     "bip_knee_R" ], True )
  169.     boneFootR     = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Foot",     "Bip01_R_Foot",     "bip_foot_R" ], True )
  170.     boneToeR      = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Toe0",     "Bip01_R_Toe0",     "bip_toe_R" ], True )
  171.     boneCollarR   = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Clavicle", "Bip01_R_Clavicle", "bip_collar_R" ], True )  
  172.     boneUpperArmR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_UpperArm", "Bip01_R_UpperArm", "bip_upperArm_R" ], True )
  173.     boneLowerArmR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Forearm",  "Bip01_R_Forearm",  "bip_lowerArm_R" ], True )
  174.     boneHandR     = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Hand",     "Bip01_R_Hand",     "bip_hand_R" ], True )
  175.    
  176.     boneUpperLegL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Thigh",    "Bip01_L_Thigh",    "bip_hip_L" ], True )
  177.     boneLowerLegL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Calf",     "Bip01_L_Calf",     "bip_knee_L" ], True )
  178.     boneFootL     = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Foot",     "Bip01_L_Foot",     "bip_foot_L" ], True )
  179.     boneToeL      = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Toe0",     "Bip01_L_Toe0",     "bip_toe_L" ], True )
  180.     boneCollarL   = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Clavicle", "Bip01_L_Clavicle", "bip_collar_L" ], True )        
  181.     boneUpperArmL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_UpperArm", "Bip01_L_UpperArm", "bip_upperArm_L" ], True )
  182.     boneLowerArmL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Forearm",  "Bip01_L_Forearm",  "bip_lowerArm_L" ], True )
  183.     boneHandL     = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Hand",     "Bip01_L_Hand",     "bip_hand_L" ], True )
  184.    
  185.  
  186.     #==============================================================================================
  187.     # Create the rig handles and constrain them to existing bones
  188.     #==============================================================================================
  189.     rigRoot    = sfmUtils.CreateConstrainedHandle( "rig_root",     boneRoot,    bCreateControls=False )
  190.     rigPelvis  = sfmUtils.CreateConstrainedHandle( "rig_pelvis",   bonePelvis,  bCreateControls=False )
  191.     rigSpine0  = sfmUtils.CreateConstrainedHandle( "rig_spine_0",  boneSpine0,  bCreateControls=False )
  192.     rigSpine1  = sfmUtils.CreateConstrainedHandle( "rig_spine_1",  boneSpine1,  bCreateControls=False )
  193.     rigChest   = sfmUtils.CreateConstrainedHandle( "rig_chest",  boneSpine2,  bCreateControls=False )
  194.     rigNeck    = sfmUtils.CreateConstrainedHandle( "rig_neck",     boneNeck,    bCreateControls=False )
  195.     rigHead    = sfmUtils.CreateConstrainedHandle( "rig_head",     boneHead,    bCreateControls=False )
  196.    
  197.     rigFootR   = sfmUtils.CreateConstrainedHandle( "rig_foot_R",   boneFootR,   bCreateControls=False )
  198.     rigToeR    = sfmUtils.CreateConstrainedHandle( "rig_toe_R",    boneToeR,    bCreateControls=False )
  199.     rigCollarR = sfmUtils.CreateConstrainedHandle( "rig_collar_R", boneCollarR, bCreateControls=False )
  200.     rigHandR   = sfmUtils.CreateConstrainedHandle( "rig_hand_R",   boneHandR,   bCreateControls=False )
  201.     rigFootL   = sfmUtils.CreateConstrainedHandle( "rig_foot_L",   boneFootL,   bCreateControls=False )
  202.     rigToeL    = sfmUtils.CreateConstrainedHandle( "rig_toe_L",    boneToeL,    bCreateControls=False )
  203.     rigCollarL = sfmUtils.CreateConstrainedHandle( "rig_collar_L", boneCollarL, bCreateControls=False )
  204.     rigHandL   = sfmUtils.CreateConstrainedHandle( "rig_hand_L",   boneHandL,   bCreateControls=False )
  205.        
  206.     rigKneeR   = sfmUtils.CreateOffsetHandle( "rig_knee_R",  boneLowerLegR, vs.Vector( 0, 0,  10 ),  bCreateControls=False )  
  207.     rigKneeL   = sfmUtils.CreateOffsetHandle( "rig_knee_L",  boneLowerLegL, vs.Vector( 0, 0,  10 ),  bCreateControls=False )
  208.     rigElbowR  = sfmUtils.CreateOffsetHandle( "rig_elbow_R", boneLowerArmR, vs.Vector( 0, 0, -10 ),  bCreateControls=False )
  209.     rigElbowL  = sfmUtils.CreateOffsetHandle( "rig_elbow_L", boneLowerArmL, vs.Vector( 0, 0, -10 ),  bCreateControls=False )
  210.    
  211.     # Create a helper handle which will remain constrained to the each foot position that can be used for parenting.
  212.     rigFootHelperR = sfmUtils.CreateConstrainedHandle( "rig_footHelper_R", boneFootR, bCreateControls=False )
  213.     rigFootHelperL = sfmUtils.CreateConstrainedHandle( "rig_footHelper_L", boneFootL, bCreateControls=False )
  214.    
  215.     # Create a list of all of the rig dags
  216.     allRigHandles = [ rigRoot, rigPelvis, rigSpine0, rigSpine1, rigChest, rigNeck, rigHead,
  217.                       rigCollarR, rigElbowR, rigHandR, rigKneeR, rigFootR, rigToeR,
  218.                       rigCollarL, rigElbowL, rigHandL, rigKneeL, rigFootL, rigToeL ];
  219.    
  220.    
  221.     #==============================================================================================
  222.     # Generate the world space logs for the rig handles and remove the constraints
  223.     #==============================================================================================
  224.     sfm.ClearSelection()
  225.     sfmUtils.SelectDagList( allRigHandles )
  226.     sfm.GenerateSamples()
  227.     sfm.RemoveConstraints()    
  228.    
  229.    
  230.     #==============================================================================================
  231.     # Build the rig handle hierarchy
  232.     #==============================================================================================
  233.     sfmUtils.ParentMaintainWorld( rigPelvis,        rigRoot )
  234.     sfmUtils.ParentMaintainWorld( rigSpine0,        rigPelvis )
  235.     sfmUtils.ParentMaintainWorld( rigSpine1,        rigSpine0 )
  236.     sfmUtils.ParentMaintainWorld( rigChest,         rigSpine1 )
  237.     sfmUtils.ParentMaintainWorld( rigNeck,          rigChest )
  238.     sfmUtils.ParentMaintainWorld( rigHead,          rigNeck )
  239.    
  240.     sfmUtils.ParentMaintainWorld( rigFootHelperR,   rigRoot )
  241.     sfmUtils.ParentMaintainWorld( rigFootHelperL,   rigRoot )
  242.     sfmUtils.ParentMaintainWorld( rigFootR,         rigRoot )
  243.     sfmUtils.ParentMaintainWorld( rigFootL,         rigRoot )
  244.     sfmUtils.ParentMaintainWorld( rigKneeR,         rigFootR )
  245.     sfmUtils.ParentMaintainWorld( rigKneeL,         rigFootL )
  246.     sfmUtils.ParentMaintainWorld( rigToeR,          rigFootHelperR )
  247.     sfmUtils.ParentMaintainWorld( rigToeL,          rigFootHelperL )
  248.    
  249.     sfmUtils.ParentMaintainWorld( rigCollarR,       rigChest )
  250.     sfmUtils.ParentMaintainWorld( rigElbowR,        rigCollarR )
  251.     sfmUtils.ParentMaintainWorld( rigHandR,     rigRoot )
  252.     sfmUtils.ParentMaintainWorld( rigCollarL,       rigChest )
  253.     sfmUtils.ParentMaintainWorld( rigElbowL,        rigCollarL )
  254.     sfmUtils.ParentMaintainWorld( rigHandL,     rigRoot )
  255.    
  256.     # Create the hips control, this allows a pelvis rotation that does not effect the spine,
  257.     # it is only used for rotation so a position control is not created. Additionally add the
  258.     # new control to the selection so the that set default call operates on it too.
  259.     rigHips = sfmUtils.CreateHandleAt( "rig_hips", rigPelvis, False, True )
  260.     sfmUtils.Parent( rigHips, rigPelvis, vs.REPARENT_LOGS_OVERWRITE )
  261.     sfm.SelectDag( rigHips )
  262.  
  263.     # Set the defaults of the rig transforms to the current locations. Defaults are stored in local
  264.     # space, so while the parent operation tries to preserve default values it is cleaner to just
  265.     # set them once the final hierarchy is constructed.
  266.     sfm.SetDefault()
  267.    
  268.    
  269.     #==============================================================================================
  270.     # Create the reverse foot controls for both the left and right foot
  271.     #==============================================================================================
  272.     rigLegsGroup = rootGroup.CreateControlGroup( "RigLegs" )
  273.     rigHelpersGroup = rootGroup.CreateControlGroup( "RigHelpers" )
  274.     rigHelpersGroup.SetVisible( False )
  275.     rigHelpersGroup.SetSnappable( False )
  276.    
  277.     footIKTargetR = rigFootR
  278.     footIkTargetL = rigFootL
  279.    
  280.     if ( gameModel != None ) :
  281.         footRollIkTargetR = CreateReverseFoot( "rig_footRoll", "R", gameModel, animSet, shot, rigHelpersGroup, rigLegsGroup )
  282.         footRollIkTargetL = CreateReverseFoot( "rig_footRoll", "L", gameModel, animSet, shot, rigHelpersGroup, rigLegsGroup )
  283.         if ( footRollIkTargetR != None ) :
  284.             footIKTargetR = footRollIkTargetR
  285.         if ( footRollIkTargetL != None ) :
  286.             footIkTargetL = footRollIkTargetL
  287.    
  288.    
  289.     #==============================================================================================
  290.     # Create constraints to drive the bone transforms using the rig handles
  291.     #==============================================================================================
  292.    
  293.     # The following bones are simply constrained directly to a rig handle
  294.     sfmUtils.CreatePointOrientConstraint( rigRoot,      boneRoot        )
  295.     sfmUtils.CreatePointOrientConstraint( rigHips,      bonePelvis      )
  296.     sfmUtils.CreatePointOrientConstraint( rigSpine0,    boneSpine0      )
  297.     sfmUtils.CreatePointOrientConstraint( rigSpine1,    boneSpine1      )
  298.     sfmUtils.CreatePointOrientConstraint( rigChest,     boneSpine2      )
  299.     sfmUtils.CreatePointOrientConstraint( rigNeck,      boneNeck        )
  300.     sfmUtils.CreatePointOrientConstraint( rigHead,      boneHead        )
  301.     sfmUtils.CreatePointOrientConstraint( rigCollarR,   boneCollarR     )
  302.     sfmUtils.CreatePointOrientConstraint( rigCollarL,   boneCollarL     )
  303.     sfmUtils.CreatePointOrientConstraint( rigToeR,      boneToeR        )
  304.     sfmUtils.CreatePointOrientConstraint( rigToeL,      boneToeL        )
  305.    
  306.     # Create ik constraints for the arms and legs that will control the rotation of the hip / knee and
  307.     # upper arm / elbow joints based on the position of the foot and hand respectively.
  308.     sfmUtils.BuildArmLeg( rigKneeR,  footIKTargetR, boneUpperLegR,  boneFootR, True )
  309.     sfmUtils.BuildArmLeg( rigKneeL,  footIkTargetL, boneUpperLegL,  boneFootL, True )
  310.     sfmUtils.BuildArmLeg( rigElbowR, rigHandR,      boneUpperArmR,  boneHandR, True )
  311.     sfmUtils.BuildArmLeg( rigElbowL, rigHandL,      boneUpperArmL,  boneHandL, True )
  312.    
  313.    
  314.     #==============================================================================================
  315.     # Create handles for the important attachment points
  316.     #==============================================================================================    
  317.     attachmentGroup = rootGroup.CreateControlGroup( "Attachments" )  
  318.     attachmentGroup.SetVisible( False )
  319.    
  320.     sfmUtils.CreateAttachmentHandleInGroup( "pvt_heel_R",       attachmentGroup )
  321.     sfmUtils.CreateAttachmentHandleInGroup( "pvt_toe_R",        attachmentGroup )
  322.     sfmUtils.CreateAttachmentHandleInGroup( "pvt_outerFoot_R",  attachmentGroup )
  323.     sfmUtils.CreateAttachmentHandleInGroup( "pvt_innerFoot_R",  attachmentGroup )
  324.    
  325.     sfmUtils.CreateAttachmentHandleInGroup( "pvt_heel_L",       attachmentGroup )
  326.     sfmUtils.CreateAttachmentHandleInGroup( "pvt_toe_L",        attachmentGroup )
  327.     sfmUtils.CreateAttachmentHandleInGroup( "pvt_outerFoot_L",  attachmentGroup )
  328.     sfmUtils.CreateAttachmentHandleInGroup( "pvt_innerFoot_L",  attachmentGroup )
  329.    
  330.    
  331.    
  332.     #==============================================================================================
  333.     # Re-organize the selection groups
  334.     #==============================================================================================  
  335.     rigBodyGroup = rootGroup.CreateControlGroup( "RigBody" )
  336.     rigArmsGroup = rootGroup.CreateControlGroup( "RigArms" )
  337.    
  338.     RightArmGroup = rootGroup.CreateControlGroup( "RightArm" )
  339.     LeftArmGroup = rootGroup.CreateControlGroup( "LeftArm" )
  340.     RightLegGroup = rootGroup.CreateControlGroup( "RightLeg" )
  341.     LeftLegGroup = rootGroup.CreateControlGroup( "LeftLeg" )  
  342.    
  343.     sfmUtils.AddDagControlsToGroup( rigBodyGroup, rigRoot, rigPelvis, rigHips, rigSpine0, rigSpine1, rigChest, rigNeck, rigHead )  
  344.      
  345.     rigArmsGroup.AddChild( RightArmGroup )
  346.     rigArmsGroup.AddChild( LeftArmGroup )
  347.     sfmUtils.AddDagControlsToGroup( RightArmGroup,  rigHandR, rigElbowR, rigCollarR )
  348.     sfmUtils.AddDagControlsToGroup( LeftArmGroup, rigHandL, rigElbowL, rigCollarL )
  349.    
  350.     rigLegsGroup.AddChild( RightLegGroup )
  351.     rigLegsGroup.AddChild( LeftLegGroup )
  352.     sfmUtils.AddDagControlsToGroup( RightLegGroup, rigKneeR, rigFootR, rigToeR )
  353.     sfmUtils.AddDagControlsToGroup( LeftLegGroup, rigKneeL, rigFootL, rigToeL )
  354.    
  355.     sfmUtils.MoveControlGroup( "rig_footRoll_L", rigLegsGroup, LeftLegGroup )
  356.     sfmUtils.MoveControlGroup( "rig_footRoll_R", rigLegsGroup, RightLegGroup )
  357.    
  358.  
  359.  
  360.     sfmUtils.AddDagControlsToGroup( rigHelpersGroup, rigFootHelperR, rigFootHelperL )
  361.  
  362.     # Set the control group visiblity, this is done through the rig so it can track which
  363.     # groups it hid, so they can be set back to being visible when the rig is detached.
  364.     HideControlGroups( rig, rootGroup, "Body", "Arms", "Legs", "Unknown", "Other", "Root" )      
  365.        
  366.     #Re-order the groups
  367.     fingersGroup = rootGroup.FindChildByName( "Fingers", False )
  368.     rootGroup.MoveChildToBottom( rigBodyGroup )
  369.     rootGroup.MoveChildToBottom( rigLegsGroup )    
  370.     rootGroup.MoveChildToBottom( rigArmsGroup )      
  371.     rootGroup.MoveChildToBottom( fingersGroup )  
  372.        
  373.     rightFingersGroup = rootGroup.FindChildByName( "RightFingers", True )
  374.     if ( rightFingersGroup != None ):
  375.         RightArmGroup.AddChild( rightFingersGroup )
  376.         rightFingersGroup.SetSelectable( False )
  377.                                
  378.     leftFingersGroup = rootGroup.FindChildByName( "LeftFingers", True )
  379.     if ( leftFingersGroup != None ):
  380.         LeftArmGroup.AddChild( leftFingersGroup )
  381.         leftFingersGroup.SetSelectable( False )
  382.        
  383.  
  384.     #==============================================================================================
  385.     # Set the selection groups colors
  386.     #==============================================================================================
  387.     topLevelColor = vs.Color( 0, 128, 255, 255 )
  388.     RightColor = vs.Color( 255, 0, 0, 255 )
  389.     LeftColor = vs.Color( 0, 255, 0, 255 )
  390.    
  391.     rigBodyGroup.SetGroupColor( topLevelColor, False )
  392.     rigArmsGroup.SetGroupColor( topLevelColor, False )
  393.     rigLegsGroup.SetGroupColor( topLevelColor, False )
  394.     attachmentGroup.SetGroupColor( topLevelColor, False )
  395.     rigHelpersGroup.SetGroupColor( topLevelColor, False )
  396.    
  397.     RightArmGroup.SetGroupColor( RightColor, False )
  398.     LeftArmGroup.SetGroupColor( LeftColor, False )
  399.     RightLegGroup.SetGroupColor( RightColor, False )
  400.     LeftLegGroup.SetGroupColor( LeftColor, False )
  401.    
  402.    
  403.     # End the rig definition
  404.     sfm.EndRig()
  405.     return
  406.    
  407. #==================================================================================================
  408. # Script entry
  409. #==================================================================================================
  410.  
  411. # Construct the rig for the selected animation set
  412. BuildRig();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement