Advertisement
Guest User

rig_Ryu

a guest
Aug 12th, 2013
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.11 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.  
  105. # Create a rotation constraint to drive the toe rotation and connect its input to the
  106. # toe rotation expression and connect its output to the reverse heel dag's orientation
  107. toeRotateConstraintName = "rotationConstraint_toe_" + sideName
  108. toeRotateConstraint = sfmUtils.CreateRotationConstraint( toeRotateConstraintName, rotationAxis, reverseHeelDag, animSet )
  109.  
  110. toeRotateExprConnName = "conn_toeRotateExpr_" + sideName
  111. toeRotateExprConn = sfmUtils.CreateConnection( toeRotateExprConnName, toeRotateExpr, "result", animSet )
  112. toeRotateExprConn.AddOutput( toeRotateConstraint, "rotations", 0 );
  113.  
  114. # Create a rotation constraint to drive the heel rotation and connect its input to the
  115. # heel rotation expression and connect its output to the heel dag's orientation
  116. heelRotateConstraintName = "rotationConstraint_heel_" + sideName
  117. heelRotateConstraint = sfmUtils.CreateRotationConstraint( heelRotateConstraintName, rotationAxis, heelDag, animSet )
  118.  
  119. heelRotateExprConnName = "conn_heelRotateExpr_" + sideName
  120. heelRotateExprConn = sfmUtils.CreateConnection( heelRotateExprConnName, heelRotateExpr, "result", animSet )
  121. heelRotateExprConn.AddOutput( heelRotateConstraint, "rotations", 0 )
  122.  
  123. if ( helperControlGroup != None ):
  124. sfmUtils.AddDagControlsToGroup( helperControlGroup, reverseHeelDag, ikHandleDag, heelDag )
  125.  
  126. if ( footControlGroup != None ):
  127. footControlGroup.AddControl( footRollControl )
  128.  
  129. return ikHandleDag
  130.  
  131.  
  132. #==================================================================================================
  133. # Compute the direction from boneA to boneB
  134. #==================================================================================================
  135. def ComputeVectorBetweenBones( boneA, boneB, scaleFactor ):
  136.  
  137. vPosA = vs.Vector( 0, 0, 0 )
  138. boneA.GetAbsPosition( vPosA )
  139.  
  140. vPosB = vs.Vector( 0, 0, 0 )
  141. boneB.GetAbsPosition( vPosB )
  142.  
  143. vDir = vs.Vector( 0, 0, 0 )
  144. vs.mathlib.VectorSubtract( vPosB, vPosA, vDir )
  145. vDir.NormalizeInPlace()
  146.  
  147. vScaledDir = vs.Vector( 0, 0, 0 )
  148. vs.mathlib.VectorScale( vDir, scaleFactor, vScaledDir )
  149.  
  150. return vScaledDir
  151.  
  152.  
  153. #==================================================================================================
  154. # Build a simple ik rig for the currently selected animation set
  155. #==================================================================================================
  156. def BuildRig():
  157.  
  158. # Get the currently selected animation set and shot
  159. shot = sfm.GetCurrentShot()
  160. animSet = sfm.GetCurrentAnimationSet()
  161. gameModel = animSet.gameModel
  162. rootGroup = animSet.GetRootControlGroup()
  163.  
  164. # Start the biped rig to which all of the controls and constraints will be added
  165. rig = sfm.BeginRig( "rig_biped_" + animSet.GetName() );
  166. if ( rig == None ):
  167. return
  168.  
  169. # Change the operation mode to passthrough so changes chan be made temporarily
  170. sfm.SetOperationMode( "Pass" )
  171.  
  172. # Move everything into the reference pose
  173. sfm.SelectAll()
  174. sfm.SetReferencePose()
  175.  
  176. #==============================================================================================
  177. # Find the dag nodes for all of the bones in the model which will be used by the script
  178. #==============================================================================================
  179. boneRoot = sfmUtils.FindFirstDag( [ "RootTransform" ], True )
  180. bonePelvis = sfmUtils.FindFirstDag( [ "MOT00_Hips" ], True )
  181. boneSpine0 = sfmUtils.FindFirstDag( [ "MOT16_Waist" ], True )
  182. boneSpine3 = sfmUtils.FindFirstDag( [ "MOT02_Chest" ], True )
  183. boneNeck = sfmUtils.FindFirstDag( [ "MOT15_Neck" ], True )
  184. boneHead = sfmUtils.FindFirstDag( [ "MOT01_Head" ], True )
  185.  
  186. boneUpperLegR = sfmUtils.FindFirstDag( [ "MOT12_RightUpLeg" ], True )
  187. boneLowerLegR = sfmUtils.FindFirstDag( [ "MOT13_RightLeg" ], True )
  188. boneFootR = sfmUtils.FindFirstDag( [ "MOT09_RightFoot" ], True )
  189. boneToeR = sfmUtils.FindFirstDag( [ "MOT20_RightToe" ], True )
  190. boneCollarR = sfmUtils.FindFirstDag( [ "MOT19_RightShoulder" ], True )
  191. boneUpperArmR = sfmUtils.FindFirstDag( [ "MOT14_RightArm" ], True )
  192. boneLowerArmR = sfmUtils.FindFirstDag( [ "MOT10_RightForeArm" ], True )
  193. boneHandR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Hand", "Bip01_R_Hand", "bip_hand_R" ], True )
  194.  
  195. boneUpperLegL = sfmUtils.FindFirstDag( [ "MOT06_LeftUpLeg" ], True )
  196. boneLowerLegL = sfmUtils.FindFirstDag( [ "MOT07_LeftLeg" ], True )
  197. boneFootL = sfmUtils.FindFirstDag( [ "MOT03_LeftFoot" ], True )
  198. boneToeL = sfmUtils.FindFirstDag( [ "MOT18_LeftToe" ], True )
  199. boneCollarL = sfmUtils.FindFirstDag( [ "MOT17_LeftShoulder" ], True )
  200. boneUpperArmL = sfmUtils.FindFirstDag( [ "MOT08_LeftArm" ], True )
  201. boneLowerArmL = sfmUtils.FindFirstDag( [ "MOT04_LeftForeArm" ], True )
  202. boneHandL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Hand", "Bip01_L_Hand", "bip_hand_L" ], True )
  203.  
  204.  
  205. #==============================================================================================
  206. # Create the rig handles and constrain them to existing bones
  207. #==============================================================================================
  208. rigRoot = sfmUtils.CreateConstrainedHandle( "rig_root", boneRoot, bCreateControls=False )
  209. rigPelvis = sfmUtils.CreateConstrainedHandle( "rig_pelvis", bonePelvis, bCreateControls=False )
  210. rigSpine0 = sfmUtils.CreateConstrainedHandle( "rig_spine_0", boneSpine0, bCreateControls=False )
  211. rigChest = sfmUtils.CreateConstrainedHandle( "rig_chest", boneSpine3, bCreateControls=False )
  212. rigNeck = sfmUtils.CreateConstrainedHandle( "rig_neck", boneNeck, bCreateControls=False )
  213. rigHead = sfmUtils.CreateConstrainedHandle( "rig_head", boneHead, bCreateControls=False )
  214.  
  215. rigFootR = sfmUtils.CreateConstrainedHandle( "rig_foot_R", boneFootR, bCreateControls=False )
  216. rigToeR = sfmUtils.CreateConstrainedHandle( "rig_toe_R", boneToeR, bCreateControls=False )
  217. rigCollarR = sfmUtils.CreateConstrainedHandle( "rig_collar_R", boneCollarR, bCreateControls=False )
  218. rigHandR = sfmUtils.CreateConstrainedHandle( "rig_hand_R", boneHandR, bCreateControls=False )
  219. rigFootL = sfmUtils.CreateConstrainedHandle( "rig_foot_L", boneFootL, bCreateControls=False )
  220. rigToeL = sfmUtils.CreateConstrainedHandle( "rig_toe_L", boneToeL, bCreateControls=False )
  221. rigCollarL = sfmUtils.CreateConstrainedHandle( "rig_collar_L", boneCollarL, bCreateControls=False )
  222. rigHandL = sfmUtils.CreateConstrainedHandle( "rig_hand_L", boneHandL, bCreateControls=False )
  223.  
  224.  
  225. # Use the direction from the heel to the toe to compute the knee offsets,
  226. # this makes the knee offset indpendent of the inital orientation of the model.
  227. vKneeOffsetR = ComputeVectorBetweenBones( boneFootR, boneToeR, 10 )
  228. vKneeOffsetL = ComputeVectorBetweenBones( boneFootL, boneToeL, 10 )
  229.  
  230.  
  231. rigKneeR = sfmUtils.CreateOffsetHandle( "rig_knee_R", boneLowerLegR, vKneeOffsetR, bCreateControls=False )
  232. rigKneeL = sfmUtils.CreateOffsetHandle( "rig_knee_L", boneLowerLegL, vKneeOffsetL, bCreateControls=False )
  233. rigElbowR = sfmUtils.CreateOffsetHandle( "rig_elbow_R", boneLowerArmR, -vKneeOffsetR, bCreateControls=False )
  234. rigElbowL = sfmUtils.CreateOffsetHandle( "rig_elbow_L", boneLowerArmL, -vKneeOffsetL, bCreateControls=False )
  235.  
  236. # Create a helper handle which will remain constrained to the each foot position that can be used for parenting.
  237. rigFootHelperR = sfmUtils.CreateConstrainedHandle( "rig_footHelper_R", boneFootR, bCreateControls=False )
  238. rigFootHelperL = sfmUtils.CreateConstrainedHandle( "rig_footHelper_L", boneFootL, bCreateControls=False )
  239.  
  240. # Create a list of all of the rig dags
  241. allRigHandles = [ rigRoot, rigPelvis, rigSpine0, rigChest, rigNeck, rigHead,
  242. rigCollarR, rigElbowR, rigHandR, rigKneeR, rigFootR, rigToeR,
  243. rigCollarL, rigElbowL, rigHandL, rigKneeL, rigFootL, rigToeL ];
  244.  
  245.  
  246. #==============================================================================================
  247. # Generate the world space logs for the rig handles and remove the constraints
  248. #==============================================================================================
  249. sfm.ClearSelection()
  250. sfmUtils.SelectDagList( allRigHandles )
  251. sfm.GenerateSamples()
  252. sfm.RemoveConstraints()
  253.  
  254.  
  255. #==============================================================================================
  256. # Build the rig handle hierarchy
  257. #==============================================================================================
  258. sfmUtils.ParentMaintainWorld( rigPelvis, rigRoot )
  259. sfmUtils.ParentMaintainWorld( rigSpine0, rigPelvis )
  260. sfmUtils.ParentMaintainWorld( rigChest, rigSpine0 )
  261. sfmUtils.ParentMaintainWorld( rigNeck, rigChest )
  262. sfmUtils.ParentMaintainWorld( rigHead, rigNeck )
  263.  
  264. sfmUtils.ParentMaintainWorld( rigFootHelperR, rigRoot )
  265. sfmUtils.ParentMaintainWorld( rigFootHelperL, rigRoot )
  266. sfmUtils.ParentMaintainWorld( rigFootR, rigRoot )
  267. sfmUtils.ParentMaintainWorld( rigFootL, rigRoot )
  268. sfmUtils.ParentMaintainWorld( rigKneeR, rigFootR )
  269. sfmUtils.ParentMaintainWorld( rigKneeL, rigFootL )
  270. sfmUtils.ParentMaintainWorld( rigToeR, rigFootHelperR )
  271. sfmUtils.ParentMaintainWorld( rigToeL, rigFootHelperL )
  272.  
  273. sfmUtils.ParentMaintainWorld( rigCollarR, rigChest )
  274. sfmUtils.ParentMaintainWorld( rigElbowR, rigCollarR )
  275. sfmUtils.ParentMaintainWorld( rigHandR, rigRoot )
  276. sfmUtils.ParentMaintainWorld( rigCollarL, rigChest )
  277. sfmUtils.ParentMaintainWorld( rigElbowL, rigCollarL )
  278. sfmUtils.ParentMaintainWorld( rigHandL, rigRoot )
  279.  
  280. # Create the hips control, this allows a pelvis rotation that does not effect the spine,
  281. # it is only used for rotation so a position control is not created. Additionally add the
  282. # new control to the selection so the that set default call operates on it too.
  283. rigHips = sfmUtils.CreateHandleAt( "rig_hips", rigPelvis, False, True )
  284. sfmUtils.Parent( rigHips, rigPelvis, vs.REPARENT_LOGS_OVERWRITE )
  285. sfm.SelectDag( rigHips )
  286.  
  287. # Set the defaults of the rig transforms to the current locations. Defaults are stored in local
  288. # space, so while the parent operation tries to preserve default values it is cleaner to just
  289. # set them once the final hierarchy is constructed.
  290. sfm.SetDefault()
  291.  
  292.  
  293. #==============================================================================================
  294. # Create the reverse foot controls for both the left and right foot
  295. #==============================================================================================
  296. rigLegsGroup = rootGroup.CreateControlGroup( "RigLegs" )
  297. rigHelpersGroup = rootGroup.CreateControlGroup( "RigHelpers" )
  298. rigHelpersGroup.SetVisible( False )
  299. rigHelpersGroup.SetSnappable( False )
  300.  
  301. footIKTargetR = rigFootR
  302. footIkTargetL = rigFootL
  303.  
  304. if ( gameModel != None ) :
  305. footRollIkTargetR = CreateReverseFoot( "rig_footRoll", "R", gameModel, animSet, shot, rigHelpersGroup, rigLegsGroup )
  306. footRollIkTargetL = CreateReverseFoot( "rig_footRoll", "L", gameModel, animSet, shot, rigHelpersGroup, rigLegsGroup )
  307. if ( footRollIkTargetR != None ) :
  308. footIKTargetR = footRollIkTargetR
  309. if ( footRollIkTargetL != None ) :
  310. footIkTargetL = footRollIkTargetL
  311.  
  312.  
  313. #==============================================================================================
  314. # Create constraints to drive the bone transforms using the rig handles
  315. #==============================================================================================
  316.  
  317. # The following bones are simply constrained directly to a rig handle
  318. sfmUtils.CreatePointOrientConstraint( rigRoot, boneRoot )
  319. sfmUtils.CreatePointOrientConstraint( rigHips, bonePelvis )
  320. sfmUtils.CreatePointOrientConstraint( rigSpine0, boneSpine0 )
  321. sfmUtils.CreatePointOrientConstraint( rigChest, boneSpine3 )
  322. sfmUtils.CreatePointOrientConstraint( rigNeck, boneNeck )
  323. sfmUtils.CreatePointOrientConstraint( rigHead, boneHead )
  324. sfmUtils.CreatePointOrientConstraint( rigCollarR, boneCollarR )
  325. sfmUtils.CreatePointOrientConstraint( rigCollarL, boneCollarL )
  326. sfmUtils.CreatePointOrientConstraint( rigToeR, boneToeR )
  327. sfmUtils.CreatePointOrientConstraint( rigToeL, boneToeL )
  328.  
  329. # Create ik constraints for the arms and legs that will control the rotation of the hip / knee and
  330. # upper arm / elbow joints based on the position of the foot and hand respectively.
  331. sfmUtils.BuildArmLeg( rigKneeR, footIKTargetR, boneUpperLegR, boneFootR, True )
  332. sfmUtils.BuildArmLeg( rigKneeL, footIkTargetL, boneUpperLegL, boneFootL, True )
  333. sfmUtils.BuildArmLeg( rigElbowR, rigHandR, boneUpperArmR, boneHandR, True )
  334. sfmUtils.BuildArmLeg( rigElbowL, rigHandL, boneUpperArmL, boneHandL, True )
  335.  
  336.  
  337. #==============================================================================================
  338. # Create handles for the important attachment points
  339. #==============================================================================================
  340. attachmentGroup = rootGroup.CreateControlGroup( "Attachments" )
  341. attachmentGroup.SetVisible( False )
  342.  
  343. sfmUtils.CreateAttachmentHandleInGroup( "pvt_heel_R", attachmentGroup )
  344. sfmUtils.CreateAttachmentHandleInGroup( "pvt_toe_R", attachmentGroup )
  345. sfmUtils.CreateAttachmentHandleInGroup( "pvt_outerFoot_R", attachmentGroup )
  346. sfmUtils.CreateAttachmentHandleInGroup( "pvt_innerFoot_R", attachmentGroup )
  347.  
  348. sfmUtils.CreateAttachmentHandleInGroup( "pvt_heel_L", attachmentGroup )
  349. sfmUtils.CreateAttachmentHandleInGroup( "pvt_toe_L", attachmentGroup )
  350. sfmUtils.CreateAttachmentHandleInGroup( "pvt_outerFoot_L", attachmentGroup )
  351. sfmUtils.CreateAttachmentHandleInGroup( "pvt_innerFoot_L", attachmentGroup )
  352.  
  353.  
  354.  
  355. #==============================================================================================
  356. # Re-organize the selection groups
  357. #==============================================================================================
  358. rigBodyGroup = rootGroup.CreateControlGroup( "RigBody" )
  359. rigArmsGroup = rootGroup.CreateControlGroup( "RigArms" )
  360.  
  361. RightArmGroup = rootGroup.CreateControlGroup( "RightArm" )
  362. LeftArmGroup = rootGroup.CreateControlGroup( "LeftArm" )
  363. RightLegGroup = rootGroup.CreateControlGroup( "RightLeg" )
  364. LeftLegGroup = rootGroup.CreateControlGroup( "LeftLeg" )
  365.  
  366. sfmUtils.AddDagControlsToGroup( rigBodyGroup, rigRoot, rigPelvis, rigHips, rigSpine0, rigChest, rigNeck, rigHead )
  367.  
  368. rigArmsGroup.AddChild( RightArmGroup )
  369. rigArmsGroup.AddChild( LeftArmGroup )
  370. sfmUtils.AddDagControlsToGroup( RightArmGroup, rigHandR, rigElbowR, rigCollarR )
  371. sfmUtils.AddDagControlsToGroup( LeftArmGroup, rigHandL, rigElbowL, rigCollarL )
  372.  
  373. rigLegsGroup.AddChild( RightLegGroup )
  374. rigLegsGroup.AddChild( LeftLegGroup )
  375. sfmUtils.AddDagControlsToGroup( RightLegGroup, rigKneeR, rigFootR, rigToeR )
  376. sfmUtils.AddDagControlsToGroup( LeftLegGroup, rigKneeL, rigFootL, rigToeL )
  377.  
  378. sfmUtils.MoveControlGroup( "rig_footRoll_L", rigLegsGroup, LeftLegGroup )
  379. sfmUtils.MoveControlGroup( "rig_footRoll_R", rigLegsGroup, RightLegGroup )
  380.  
  381.  
  382.  
  383. sfmUtils.AddDagControlsToGroup( rigHelpersGroup, rigFootHelperR, rigFootHelperL )
  384.  
  385. # Set the control group visiblity, this is done through the rig so it can track which
  386. # groups it hid, so they can be set back to being visible when the rig is detached.
  387. HideControlGroups( rig, rootGroup, "Body", "Arms", "Legs", "Unknown", "Other", "Root" )
  388.  
  389. #Re-order the groups
  390. fingersGroup = rootGroup.FindChildByName( "Fingers", False )
  391. rootGroup.MoveChildToBottom( rigBodyGroup )
  392. rootGroup.MoveChildToBottom( rigLegsGroup )
  393. rootGroup.MoveChildToBottom( rigArmsGroup )
  394. rootGroup.MoveChildToBottom( fingersGroup )
  395.  
  396. rightFingersGroup = rootGroup.FindChildByName( "RightFingers", True )
  397. if ( rightFingersGroup != None ):
  398. RightArmGroup.AddChild( rightFingersGroup )
  399. rightFingersGroup.SetSelectable( False )
  400.  
  401. leftFingersGroup = rootGroup.FindChildByName( "LeftFingers", True )
  402. if ( leftFingersGroup != None ):
  403. LeftArmGroup.AddChild( leftFingersGroup )
  404. leftFingersGroup.SetSelectable( False )
  405.  
  406.  
  407. #==============================================================================================
  408. # Set the selection groups colors
  409. #==============================================================================================
  410. topLevelColor = vs.Color( 0, 128, 255, 255 )
  411. RightColor = vs.Color( 255, 0, 0, 255 )
  412. LeftColor = vs.Color( 0, 255, 0, 255 )
  413.  
  414. rigBodyGroup.SetGroupColor( topLevelColor, False )
  415. rigArmsGroup.SetGroupColor( topLevelColor, False )
  416. rigLegsGroup.SetGroupColor( topLevelColor, False )
  417. attachmentGroup.SetGroupColor( topLevelColor, False )
  418. rigHelpersGroup.SetGroupColor( topLevelColor, False )
  419.  
  420. RightArmGroup.SetGroupColor( RightColor, False )
  421. LeftArmGroup.SetGroupColor( LeftColor, False )
  422. RightLegGroup.SetGroupColor( RightColor, False )
  423. LeftLegGroup.SetGroupColor( LeftColor, False )
  424.  
  425.  
  426. # End the rig definition
  427. sfm.EndRig()
  428. return
  429.  
  430. #==================================================================================================
  431. # Script entry
  432. #==================================================================================================
  433.  
  434. # Construct the rig for the selected animation set
  435. BuildRig();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement