Advertisement
Guest User

rig_james

a guest
Aug 12th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.34 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( [ "ValveBiped.Pelvis" ], True )
  181. bonePenisBase = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_Pelvis"], True )
  182. bonePenis1 = sfmUtils.FindFirstDag( [ "ValveBiped.pen_1"], True )
  183. bonePenis2 = sfmUtils.FindFirstDag( [ "ValveBiped.pen_2"], True )
  184. bonePenis3 = sfmUtils.FindFirstDag( [ "ValveBiped.pen_3"], True )
  185. boneSpine1 = sfmUtils.FindFirstDag( [ "ValveBiped.LowerBack" ], True )
  186. boneSpine2 = sfmUtils.FindFirstDag( [ "ValveBiped.Chest" ], True )
  187. boneSpine3 = sfmUtils.FindFirstDag( [ "ValveBiped.Chest1" ], True )
  188. boneSpine4 = sfmUtils.FindFirstDag( [ "ValveBiped.Chest2" ], True )
  189. boneNeck1 = sfmUtils.FindFirstDag( [ "ValveBiped.Neck" ], True )
  190. boneHead = sfmUtils.FindFirstDag( [ "ValveBiped.Neck1" ], True )
  191.  
  192. boneUpperLegR = sfmUtils.FindFirstDag( [ "ValveBiped.RightHip" ], True )
  193. boneLowerLegR = sfmUtils.FindFirstDag( [ "ValveBiped.RightKnee" ], True )
  194. boneFootR = sfmUtils.FindFirstDag( [ "ValveBiped.RightAnkle" ], True )
  195. boneToeR = sfmUtils.FindFirstDag( [ "ValveBiped.RightToe" ], True )
  196. boneCollarR = sfmUtils.FindFirstDag( [ "ValveBiped.RightCollar" ], True )
  197. boneUpperArmR = sfmUtils.FindFirstDag( [ "ValveBiped.RightShoulder" ], True )
  198. boneLowerArmR = sfmUtils.FindFirstDag( [ "ValveBiped.RightElbow" ], True )
  199. boneHandR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Hand" ], True )
  200.  
  201. boneUpperLegL = sfmUtils.FindFirstDag( [ "ValveBiped.LeftHip" ], True )
  202. boneLowerLegL = sfmUtils.FindFirstDag( [ "ValveBiped.LeftKnee" ], True )
  203. boneFootL = sfmUtils.FindFirstDag( [ "ValveBiped.LeftAnkle" ], True )
  204. boneToeL = sfmUtils.FindFirstDag( [ "ValveBiped.LeftToe" ], True )
  205. boneCollarL = sfmUtils.FindFirstDag( [ "ValveBiped.LeftCollar" ], True )
  206. boneUpperArmL = sfmUtils.FindFirstDag( [ "ValveBiped.LeftShoulder" ], True )
  207. boneLowerArmL = sfmUtils.FindFirstDag( [ "ValveBiped.LeftElbow" ], True )
  208. boneHandL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Hand" ], True )
  209.  
  210.  
  211. #==============================================================================================
  212. # Create the rig handles and constrain them to existing bones
  213. #==============================================================================================
  214. rigRoot = sfmUtils.CreateConstrainedHandle( "rig_root", boneRoot, bCreateControls=False )
  215. rigPelvis = sfmUtils.CreateConstrainedHandle( "rig_pelvis", bonePelvis, bCreateControls=False )
  216. rigPenisBase = sfmUtils.CreateConstrainedHandle( "rig_penisBase", bonePenisBase, bCreateControls=False )
  217. rigPenis1 = sfmUtils.CreateConstrainedHandle( "rig_penis1", bonePenis1, bCreateControls=False )
  218. rigPenis2 = sfmUtils.CreateConstrainedHandle( "rig_penis2", bonePenis2, bCreateControls=False )
  219. rigPenis3 = sfmUtils.CreateConstrainedHandle( "rig_penis3", bonePenis3, bCreateControls=False )
  220. rigSpine1 = sfmUtils.CreateConstrainedHandle( "rig_spine_1", boneSpine1, bCreateControls=False )
  221. rigSpine2 = sfmUtils.CreateConstrainedHandle( "rig_spine_2", boneSpine2, bCreateControls=False )
  222. rigSpine3 = sfmUtils.CreateConstrainedHandle( "rig_spine_3", boneSpine3, bCreateControls=False )
  223. rigChest = sfmUtils.CreateConstrainedHandle( "rig_chest", boneSpine4, bCreateControls=False )
  224. rigNeck1 = sfmUtils.CreateConstrainedHandle( "rig_neck1", boneNeck1, bCreateControls=False )
  225. rigHead = sfmUtils.CreateConstrainedHandle( "rig_head", boneHead, bCreateControls=False )
  226.  
  227. rigFootR = sfmUtils.CreateConstrainedHandle( "rig_foot_R", boneFootR, bCreateControls=False )
  228. rigToeR = sfmUtils.CreateConstrainedHandle( "rig_toe_R", boneToeR, bCreateControls=False )
  229. rigCollarR = sfmUtils.CreateConstrainedHandle( "rig_collar_R", boneCollarR, bCreateControls=False )
  230. rigHandR = sfmUtils.CreateConstrainedHandle( "rig_hand_R", boneHandR, bCreateControls=False )
  231. rigFootL = sfmUtils.CreateConstrainedHandle( "rig_foot_L", boneFootL, bCreateControls=False )
  232. rigToeL = sfmUtils.CreateConstrainedHandle( "rig_toe_L", boneToeL, bCreateControls=False )
  233. rigCollarL = sfmUtils.CreateConstrainedHandle( "rig_collar_L", boneCollarL, bCreateControls=False )
  234. rigHandL = sfmUtils.CreateConstrainedHandle( "rig_hand_L", boneHandL, bCreateControls=False )
  235.  
  236.  
  237. # Use the direction from the heel to the toe to compute the knee offsets,
  238. # this makes the knee offset indpendent of the inital orientation of the model.
  239. vKneeOffsetR = ComputeVectorBetweenBones( boneFootR, boneToeR, 10 )
  240. vKneeOffsetL = ComputeVectorBetweenBones( boneFootL, boneToeL, 10 )
  241.  
  242.  
  243. rigKneeR = sfmUtils.CreateOffsetHandle( "rig_knee_R", boneLowerLegR, vKneeOffsetR, bCreateControls=False )
  244. rigKneeL = sfmUtils.CreateOffsetHandle( "rig_knee_L", boneLowerLegL, vKneeOffsetL, bCreateControls=False )
  245. rigElbowR = sfmUtils.CreateOffsetHandle( "rig_elbow_R", boneLowerArmR, -vKneeOffsetR, bCreateControls=False )
  246. rigElbowL = sfmUtils.CreateOffsetHandle( "rig_elbow_L", boneLowerArmL, -vKneeOffsetL, bCreateControls=False )
  247.  
  248. # Create a helper handle which will remain constrained to the each foot position that can be used for parenting.
  249. rigFootHelperR = sfmUtils.CreateConstrainedHandle( "rig_footHelper_R", boneFootR, bCreateControls=False )
  250. rigFootHelperL = sfmUtils.CreateConstrainedHandle( "rig_footHelper_L", boneFootL, bCreateControls=False )
  251.  
  252. # Create a list of all of the rig dags
  253. allRigHandles = [ rigRoot, rigPelvis, rigPenisBase, rigPenis1,rigPenis2,rigPenis3, rigSpine1, rigSpine2,rigSpine3, rigChest, rigNeck1, rigHead,
  254. rigCollarR, rigElbowR, rigHandR, rigKneeR, rigFootR, rigToeR,
  255. rigCollarL, rigElbowL, rigHandL, rigKneeL, rigFootL, rigToeL ];
  256.  
  257.  
  258. #==============================================================================================
  259. # Generate the world space logs for the rig handles and remove the constraints
  260. #==============================================================================================
  261. sfm.ClearSelection()
  262. sfmUtils.SelectDagList( allRigHandles )
  263. sfm.GenerateSamples()
  264. sfm.RemoveConstraints()
  265.  
  266.  
  267. #==============================================================================================
  268. # Build the rig handle hierarchy
  269. #==============================================================================================
  270. sfmUtils.ParentMaintainWorld( rigPelvis, rigRoot )
  271. sfmUtils.ParentMaintainWorld( rigSpine1, rigPelvis )
  272. sfmUtils.ParentMaintainWorld( rigPenisBase, rigPelvis )
  273. sfmUtils.ParentMaintainWorld( rigPenis1, rigPenisBase )
  274. sfmUtils.ParentMaintainWorld( rigPenis2, rigPenis1 )
  275. sfmUtils.ParentMaintainWorld( rigPenis3, rigPenis2 )
  276. sfmUtils.ParentMaintainWorld( rigSpine2, rigSpine1 )
  277. sfmUtils.ParentMaintainWorld( rigSpine3, rigSpine2 )
  278. sfmUtils.ParentMaintainWorld( rigChest, rigSpine3 )
  279. sfmUtils.ParentMaintainWorld( rigNeck1, rigChest )
  280. sfmUtils.ParentMaintainWorld( rigHead, rigNeck1 )
  281.  
  282. sfmUtils.ParentMaintainWorld( rigFootHelperR, rigRoot )
  283. sfmUtils.ParentMaintainWorld( rigFootHelperL, rigRoot )
  284. sfmUtils.ParentMaintainWorld( rigFootR, rigRoot )
  285. sfmUtils.ParentMaintainWorld( rigFootL, rigRoot )
  286. sfmUtils.ParentMaintainWorld( rigKneeR, rigFootR )
  287. sfmUtils.ParentMaintainWorld( rigKneeL, rigFootL )
  288. sfmUtils.ParentMaintainWorld( rigToeR, rigFootHelperR )
  289. sfmUtils.ParentMaintainWorld( rigToeL, rigFootHelperL )
  290.  
  291. sfmUtils.ParentMaintainWorld( rigCollarR, rigChest )
  292. sfmUtils.ParentMaintainWorld( rigElbowR, rigCollarR )
  293. sfmUtils.ParentMaintainWorld( rigHandR, rigRoot )
  294. sfmUtils.ParentMaintainWorld( rigCollarL, rigChest )
  295. sfmUtils.ParentMaintainWorld( rigElbowL, rigCollarL )
  296. sfmUtils.ParentMaintainWorld( rigHandL, rigRoot )
  297.  
  298. # Create the hips control, this allows a pelvis rotation that does not effect the spine,
  299. # it is only used for rotation so a position control is not created. Additionally add the
  300. # new control to the selection so the that set default call operates on it too.
  301. rigHips = sfmUtils.CreateHandleAt( "rig_hips", rigPelvis, False, True )
  302. sfmUtils.Parent( rigHips, rigPelvis, vs.REPARENT_LOGS_OVERWRITE )
  303. sfm.SelectDag( rigHips )
  304.  
  305. # Set the defaults of the rig transforms to the current locations. Defaults are stored in local
  306. # space, so while the parent operation tries to preserve default values it is cleaner to just
  307. # set them once the final hierarchy is constructed.
  308. sfm.SetDefault()
  309.  
  310.  
  311. #==============================================================================================
  312. # Create the reverse foot controls for both the left and right foot
  313. #==============================================================================================
  314. rigLegsGroup = rootGroup.CreateControlGroup( "RigLegs" )
  315. rigHelpersGroup = rootGroup.CreateControlGroup( "RigHelpers" )
  316. rigHelpersGroup.SetVisible( False )
  317. rigHelpersGroup.SetSnappable( False )
  318.  
  319. footIKTargetR = rigFootR
  320. footIkTargetL = rigFootL
  321.  
  322. if ( gameModel != None ) :
  323. footRollIkTargetR = CreateReverseFoot( "rig_footRoll", "R", gameModel, animSet, shot, rigHelpersGroup, rigLegsGroup )
  324. footRollIkTargetL = CreateReverseFoot( "rig_footRoll", "L", gameModel, animSet, shot, rigHelpersGroup, rigLegsGroup )
  325. if ( footRollIkTargetR != None ) :
  326. footIKTargetR = footRollIkTargetR
  327. if ( footRollIkTargetL != None ) :
  328. footIkTargetL = footRollIkTargetL
  329.  
  330.  
  331. #==============================================================================================
  332. # Create constraints to drive the bone transforms using the rig handles
  333. #==============================================================================================
  334.  
  335. # The following bones are simply constrained directly to a rig handle
  336. sfmUtils.CreatePointOrientConstraint( rigRoot, boneRoot )
  337. sfmUtils.CreatePointOrientConstraint( rigHips, bonePelvis )
  338. sfmUtils.CreatePointOrientConstraint( rigPenisBase, bonePenisBase )
  339. sfmUtils.CreatePointOrientConstraint( rigPenis1, bonePenis1 )
  340. sfmUtils.CreatePointOrientConstraint( rigPenis2, bonePenis2 )
  341. sfmUtils.CreatePointOrientConstraint( rigPenis3, bonePenis3 )
  342. sfmUtils.CreatePointOrientConstraint( rigSpine1, boneSpine1 )
  343. sfmUtils.CreatePointOrientConstraint( rigSpine2, boneSpine2 )
  344. sfmUtils.CreatePointOrientConstraint( rigSpine3, boneSpine3 )
  345. sfmUtils.CreatePointOrientConstraint( rigChest, boneSpine4 )
  346. sfmUtils.CreatePointOrientConstraint( rigNeck1, boneNeck1 )
  347. sfmUtils.CreatePointOrientConstraint( rigHead, boneHead )
  348. sfmUtils.CreatePointOrientConstraint( rigCollarR, boneCollarR )
  349. sfmUtils.CreatePointOrientConstraint( rigCollarL, boneCollarL )
  350. sfmUtils.CreatePointOrientConstraint( rigToeR, boneToeR )
  351. sfmUtils.CreatePointOrientConstraint( rigToeL, boneToeL )
  352.  
  353. # Create ik constraints for the arms and legs that will control the rotation of the hip / knee and
  354. # upper arm / elbow joints based on the position of the foot and hand respectively.
  355. sfmUtils.BuildArmLeg( rigKneeR, footIKTargetR, boneUpperLegR, boneFootR, True )
  356. sfmUtils.BuildArmLeg( rigKneeL, footIkTargetL, boneUpperLegL, boneFootL, True )
  357. sfmUtils.BuildArmLeg( rigElbowR, rigHandR, boneUpperArmR, boneHandR, True )
  358. sfmUtils.BuildArmLeg( rigElbowL, rigHandL, boneUpperArmL, boneHandL, True )
  359.  
  360.  
  361. #==============================================================================================
  362. # Create handles for the important attachment points
  363. #==============================================================================================
  364. attachmentGroup = rootGroup.CreateControlGroup( "Attachments" )
  365. attachmentGroup.SetVisible( False )
  366.  
  367. sfmUtils.CreateAttachmentHandleInGroup( "pvt_heel_R", attachmentGroup )
  368. sfmUtils.CreateAttachmentHandleInGroup( "pvt_toe_R", attachmentGroup )
  369. sfmUtils.CreateAttachmentHandleInGroup( "pvt_outerFoot_R", attachmentGroup )
  370. sfmUtils.CreateAttachmentHandleInGroup( "pvt_innerFoot_R", attachmentGroup )
  371.  
  372. sfmUtils.CreateAttachmentHandleInGroup( "pvt_heel_L", attachmentGroup )
  373. sfmUtils.CreateAttachmentHandleInGroup( "pvt_toe_L", attachmentGroup )
  374. sfmUtils.CreateAttachmentHandleInGroup( "pvt_outerFoot_L", attachmentGroup )
  375. sfmUtils.CreateAttachmentHandleInGroup( "pvt_innerFoot_L", attachmentGroup )
  376.  
  377.  
  378.  
  379. #==============================================================================================
  380. # Re-organize the selection groups
  381. #==============================================================================================
  382. rigBodyGroup = rootGroup.CreateControlGroup( "RigBody" )
  383. rigPenisGroup = rootGroup.CreateControlGroup( "RigNaughty" )
  384. rigArmsGroup = rootGroup.CreateControlGroup( "RigArms" )
  385.  
  386. RightArmGroup = rootGroup.CreateControlGroup( "RightArm" )
  387. LeftArmGroup = rootGroup.CreateControlGroup( "LeftArm" )
  388. RightLegGroup = rootGroup.CreateControlGroup( "RightLeg" )
  389. LeftLegGroup = rootGroup.CreateControlGroup( "LeftLeg" )
  390.  
  391. sfmUtils.AddDagControlsToGroup( rigBodyGroup, rigRoot, rigPelvis, rigHips, rigSpine1, rigSpine2, rigSpine3, rigChest, rigNeck1, rigHead )
  392. sfmUtils.AddDagControlsToGroup( rigPenisGroup,rigPenisBase, rigPenis1, rigPenis2,rigPenis3)
  393.  
  394. rigArmsGroup.AddChild( RightArmGroup )
  395. rigArmsGroup.AddChild( LeftArmGroup )
  396. sfmUtils.AddDagControlsToGroup( RightArmGroup, rigHandR, rigElbowR, rigCollarR )
  397. sfmUtils.AddDagControlsToGroup( LeftArmGroup, rigHandL, rigElbowL, rigCollarL )
  398.  
  399. rigLegsGroup.AddChild( RightLegGroup )
  400. rigLegsGroup.AddChild( LeftLegGroup )
  401. sfmUtils.AddDagControlsToGroup( RightLegGroup, rigKneeR, rigFootR, rigToeR )
  402. sfmUtils.AddDagControlsToGroup( LeftLegGroup, rigKneeL, rigFootL, rigToeL )
  403.  
  404. sfmUtils.MoveControlGroup( "rig_footRoll_L", rigLegsGroup, LeftLegGroup )
  405. sfmUtils.MoveControlGroup( "rig_footRoll_R", rigLegsGroup, RightLegGroup )
  406.  
  407.  
  408.  
  409. sfmUtils.AddDagControlsToGroup( rigHelpersGroup, rigFootHelperR, rigFootHelperL )
  410.  
  411. # Set the control group visiblity, this is done through the rig so it can track which
  412. # groups it hid, so they can be set back to being visible when the rig is detached.
  413. HideControlGroups( rig, rootGroup, "Body", "Arms", "Legs", "Root" )
  414.  
  415. #Re-order the groups
  416. fingersGroup = rootGroup.FindChildByName( "Fingers", False )
  417. rootGroup.MoveChildToBottom( rigBodyGroup )
  418. rootGroup.MoveChildToBottom( rigLegsGroup )
  419. rootGroup.MoveChildToBottom( rigArmsGroup )
  420. rootGroup.MoveChildToBottom( fingersGroup )
  421.  
  422. rightFingersGroup = rootGroup.FindChildByName( "RightFingers", True )
  423. if ( rightFingersGroup != None ):
  424. RightArmGroup.AddChild( rightFingersGroup )
  425. rightFingersGroup.SetSelectable( False )
  426.  
  427. leftFingersGroup = rootGroup.FindChildByName( "LeftFingers", True )
  428. if ( leftFingersGroup != None ):
  429. LeftArmGroup.AddChild( leftFingersGroup )
  430. leftFingersGroup.SetSelectable( False )
  431.  
  432.  
  433. #==============================================================================================
  434. # Set the selection groups colors
  435. #==============================================================================================
  436. topLevelColor = vs.Color( 0, 128, 255, 255 )
  437. RightColor = vs.Color( 255, 0, 0, 255 )
  438. LeftColor = vs.Color( 0, 255, 0, 255 )
  439.  
  440. rigBodyGroup.SetGroupColor( topLevelColor, False )
  441. rigPenisGroup.SetGroupColor( topLevelColor, False )
  442. rigArmsGroup.SetGroupColor( topLevelColor, False )
  443. rigLegsGroup.SetGroupColor( topLevelColor, False )
  444. attachmentGroup.SetGroupColor( topLevelColor, False )
  445. rigHelpersGroup.SetGroupColor( topLevelColor, False )
  446.  
  447. RightArmGroup.SetGroupColor( RightColor, False )
  448. LeftArmGroup.SetGroupColor( LeftColor, False )
  449. RightLegGroup.SetGroupColor( RightColor, False )
  450. LeftLegGroup.SetGroupColor( LeftColor, False )
  451.  
  452.  
  453. # End the rig definition
  454. sfm.EndRig()
  455. return
  456.  
  457. #==================================================================================================
  458. # Script entry
  459. #==================================================================================================
  460.  
  461. # Construct the rig for the selected animation set
  462. BuildRig();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement