DigitalEro Offline

Trouble with custom rigs

Sun, 24 Mar 2013 04:29:21

Nurb

'Lo! New guy here, corrupted by your perversion into becoming a member of the site. You monsters! :D Anyway, I've been screwing around with SFM and all that, working on some custom IK rigs in python for a huge dump of Skyrim assets. I've just recently starting using the stuff, though picking it up rather well thanks to the models offered by the fine folks here, but customizing rigs is making me want to blow my brains out. I did manage to make one editing the Simple rig for a Rebecca model, but I'm trying to now rig this khajiit lady and just getting a simple rig going, without including the tail bones yet, isn't working and I don't have a clue why. SO! I thought I'd ask you folks to take a peek and see what you think. Is it something to do with the bone names not being read properly? Any help would be appreciated :) Here's the python Idle code [spoiler:r0nw7jdl]#============================================================================================== # Find the dag nodes for all of the bones in the model which will be used by the script #============================================================================================== bonePelvis = sfmUtils.FindFirstDag( [ "NPC Pelvis [Pelv]" ], True ) boneSpine0 = sfmUtils.FindFirstDag( [ "NPC Spine [Spn0]" ], True ) boneSpine1 = sfmUtils.FindFirstDag( [ "NPC Spine1 [Spn1]" ], True ) boneSpine2 = sfmUtils.FindFirstDag( [ "NPC Spine2 [Spn2]" ], True ) boneNeck = sfmUtils.FindFirstDag( [ "NPC Neck [Neck]" ], True ) boneHead = sfmUtils.FindFirstDag( [ "NPC Head [Head]" ], True ) boneUpperLegR = sfmUtils.FindFirstDag( [ "NPC R Thigh [RThg]" ], True ) boneLowerLegR = sfmUtils.FindFirstDag( [ "NPC R Calf [RClf]" ], True ) boneFootR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Foot", "Bip01_R_Foot", "bip_foot_R" ], True ) boneToeR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Toe0", "Bip01_R_Toe0", "bip_toe_R" ], True ) boneCollarR = sfmUtils.FindFirstDag( [ "NPC R Clavicle [RClv]" ], True ) boneUpperArmR = sfmUtils.FindFirstDag( [ "NPC R UpperArm [RUar]" ], True ) boneLowerArmR = sfmUtils.FindFirstDag( [ "NPC R Forearm [RLar]" ], True ) boneHandR = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Hand", "Bip01_R_Hand", "bip_hand_R" ], True ) boneUpperLegL = sfmUtils.FindFirstDag( [ "NPC L Thigh [LThg]" ], True ) boneLowerLegL = sfmUtils.FindFirstDag( [ "NPC L Calf [LClf]" ], True ) boneFootL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Foot", "Bip01_L_Foot", "bip_foot_L" ], True ) boneToeL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Toe0", "Bip01_L_Toe0", "bip_toe_L" ], True ) boneCollarL = sfmUtils.FindFirstDag( [ "NPC L Clavicle [LClv]" ], True ) boneUpperArmL = sfmUtils.FindFirstDag( [ "NPC L UpperArm [LUar]" ], True ) boneLowerArmL = sfmUtils.FindFirstDag( [ "NPC L Forearm [LLar]" ], True ) boneHandL = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Hand", "Bip01_L_Hand", "bip_hand_L" ], True ) #============================================================================================== # Create the rig handles and constrain them to existing bones #============================================================================================== rigRoot = sfmUtils.CreateConstrainedHandle( "rig_root", boneRoot, bCreateControls=False ) rigPelvis = sfmUtils.CreateConstrainedHandle( "rig_pelvis", bonePelvis, bCreateControls=False ) rigSpine0 = sfmUtils.CreateConstrainedHandle( "rig_spine_0", boneSpine0, bCreateControls=False ) rigSpine1 = sfmUtils.CreateConstrainedHandle( "rig_spine_1", boneSpine1, bCreateControls=False ) rigChest = sfmUtils.CreateConstrainedHandle( "rig_chest", boneSpine2, bCreateControls=False ) rigNeck = sfmUtils.CreateConstrainedHandle( "rig_neck", boneNeck, bCreateControls=False ) rigHead = sfmUtils.CreateConstrainedHandle( "rig_head", boneHead, bCreateControls=False ) rigFootR = sfmUtils.CreateConstrainedHandle( "rig_foot_R", boneFootR, bCreateControls=False ) rigToeR = sfmUtils.CreateConstrainedHandle( "rig_toe_R", boneToeR, bCreateControls=False ) rigCollarR = sfmUtils.CreateConstrainedHandle( "rig_collar_R", boneCollarR, bCreateControls=False ) rigHandR = sfmUtils.CreateConstrainedHandle( "rig_hand_R", boneHandR, bCreateControls=False ) rigFootL = sfmUtils.CreateConstrainedHandle( "rig_foot_L", boneFootL, bCreateControls=False ) rigToeL = sfmUtils.CreateConstrainedHandle( "rig_toe_L", boneToeL, bCreateControls=False ) rigCollarL = sfmUtils.CreateConstrainedHandle( "rig_collar_L", boneCollarL, bCreateControls=False ) rigHandL = sfmUtils.CreateConstrainedHandle( "rig_hand_L", boneHandL, bCreateControls=False ) # Use the direction from the heel to the toe to compute the knee offsets, # this makes the knee offset indpendent of the inital orientation of the model. vKneeOffsetR = ComputeVectorBetweenBones( boneFootR, boneToeR, 10 ) vKneeOffsetL = ComputeVectorBetweenBones( boneFootL, boneToeL, 10 ) rigKneeR = sfmUtils.CreateOffsetHandle( "rig_knee_R", boneLowerLegR, vKneeOffsetR, bCreateControls=False ) rigKneeL = sfmUtils.CreateOffsetHandle( "rig_knee_L", boneLowerLegL, vKneeOffsetL, bCreateControls=False ) rigElbowR = sfmUtils.CreateOffsetHandle( "rig_elbow_R", boneLowerArmR, -vKneeOffsetR, bCreateControls=False ) rigElbowL = sfmUtils.CreateOffsetHandle( "rig_elbow_L", boneLowerArmL, -vKneeOffsetL, bCreateControls=False ) # Create a helper handle which will remain constrained to the each foot position that can be used for parenting. rigFootHelperR = sfmUtils.CreateConstrainedHandle( "rig_footHelper_R", boneFootR, bCreateControls=False ) rigFootHelperL = sfmUtils.CreateConstrainedHandle( "rig_footHelper_L", boneFootL, bCreateControls=False ) # Create a list of all of the rig dags allRigHandles = [ rigRoot, rigPelvis, rigSpine0, rigSpine1, rigChest, rigNeck, rigHead, rigCollarR, rigElbowR, rigHandR, rigKneeR, rigFootR, rigToeR, rigCollarL, rigElbowL, rigHandL, rigKneeL, rigFootL, rigToeL ]; #============================================================================================== # Generate the world space logs for the rig handles and remove the constraints #============================================================================================== sfm.ClearSelection() sfmUtils.SelectDagList( allRigHandles ) sfm.GenerateSamples() sfm.RemoveConstraints() #============================================================================================== # Build the rig handle hierarchy #============================================================================================== sfmUtils.ParentMaintainWorld( rigPelvis, rigRoot ) sfmUtils.ParentMaintainWorld( rigSpine0, rigPelvis ) sfmUtils.ParentMaintainWorld( rigSpine1, rigSpine0 ) sfmUtils.ParentMaintainWorld( rigChest, rigSpine1 ) sfmUtils.ParentMaintainWorld( rigNeck, rigChest ) sfmUtils.ParentMaintainWorld( rigHead, rigNeck ) sfmUtils.ParentMaintainWorld( rigFootHelperR, rigRoot ) sfmUtils.ParentMaintainWorld( rigFootHelperL, rigRoot ) sfmUtils.ParentMaintainWorld( rigFootR, rigRoot ) sfmUtils.ParentMaintainWorld( rigFootL, rigRoot ) sfmUtils.ParentMaintainWorld( rigKneeR, rigFootR ) sfmUtils.ParentMaintainWorld( rigKneeL, rigFootL ) sfmUtils.ParentMaintainWorld( rigToeR, rigFootHelperR ) sfmUtils.ParentMaintainWorld( rigToeL, rigFootHelperL ) sfmUtils.ParentMaintainWorld( rigCollarR, rigChest ) sfmUtils.ParentMaintainWorld( rigElbowR, rigCollarR ) sfmUtils.ParentMaintainWorld( rigHandR, rigRoot ) sfmUtils.ParentMaintainWorld( rigCollarL, rigChest ) sfmUtils.ParentMaintainWorld( rigElbowL, rigCollarL ) sfmUtils.ParentMaintainWorld( rigHandL, rigRoot ) # Create the hips control, this allows a pelvis rotation that does not effect the spine, # it is only used for rotation so a position control is not created. Additionally add the # new control to the selection so the that set default call operates on it too. rigHips = sfmUtils.CreateHandleAt( "rig_hips", rigPelvis, False, True ) sfmUtils.Parent( rigHips, rigPelvis, vs.REPARENT_LOGS_OVERWRITE ) sfm.SelectDag( rigHips ) # Set the defaults of the rig transforms to the current locations. Defaults are stored in local # space, so while the parent operation tries to preserve default values it is cleaner to just # set them once the final hierarchy is constructed. sfm.SetDefault() #============================================================================================== # Create the reverse foot controls for both the left and right foot #============================================================================================== rigLegsGroup = rootGroup.CreateControlGroup( "RigLegs" ) rigHelpersGroup = rootGroup.CreateControlGroup( "RigHelpers" ) rigHelpersGroup.SetVisible( False ) rigHelpersGroup.SetSnappable( False ) footIKTargetR = rigFootR footIkTargetL = rigFootL if ( gameModel != None ) : footRollIkTargetR = CreateReverseFoot( "rig_footRoll", "R", gameModel, animSet, shot, rigHelpersGroup, rigLegsGroup ) footRollIkTargetL = CreateReverseFoot( "rig_footRoll", "L", gameModel, animSet, shot, rigHelpersGroup, rigLegsGroup ) if ( footRollIkTargetR != None ) : footIKTargetR = footRollIkTargetR if ( footRollIkTargetL != None ) : footIkTargetL = footRollIkTargetL #============================================================================================== # Create constraints to drive the bone transforms using the rig handles #============================================================================================== # The following bones are simply constrained directly to a rig handle sfmUtils.CreatePointOrientConstraint( rigRoot, boneRoot ) sfmUtils.CreatePointOrientConstraint( rigHips, bonePelvis ) sfmUtils.CreatePointOrientConstraint( rigSpine0, boneSpine0 ) sfmUtils.CreatePointOrientConstraint( rigSpine1, boneSpine1 ) sfmUtils.CreatePointOrientConstraint( rigChest, boneSpine2 ) sfmUtils.CreatePointOrientConstraint( rigNeck, boneNeck ) sfmUtils.CreatePointOrientConstraint( rigHead, boneHead ) sfmUtils.CreatePointOrientConstraint( rigCollarR, boneCollarR ) sfmUtils.CreatePointOrientConstraint( rigCollarL, boneCollarL ) sfmUtils.CreatePointOrientConstraint( rigToeR, boneToeR ) sfmUtils.CreatePointOrientConstraint( rigToeL, boneToeL ) # Create ik constraints for the arms and legs that will control the rotation of the hip / knee and # upper arm / elbow joints based on the position of the foot and hand respectively. sfmUtils.BuildArmLeg( rigKneeR, footIKTargetR, boneUpperLegR, boneFootR, True ) sfmUtils.BuildArmLeg( rigKneeL, footIkTargetL, boneUpperLegL, boneFootL, True ) sfmUtils.BuildArmLeg( rigElbowR, rigHandR, boneUpperArmR, boneHandR, True ) sfmUtils.BuildArmLeg( rigElbowL, rigHandL, boneUpperArmL, boneHandL, True ) #============================================================================================== # Create handles for the important attachment points #============================================================================================== attachmentGroup = rootGroup.CreateControlGroup( "Attachments" ) attachmentGroup.SetVisible( False ) sfmUtils.CreateAttachmentHandleInGroup( "pvt_heel_R", attachmentGroup ) sfmUtils.CreateAttachmentHandleInGroup( "pvt_toe_R", attachmentGroup ) sfmUtils.CreateAttachmentHandleInGroup( "pvt_outerFoot_R", attachmentGroup ) sfmUtils.CreateAttachmentHandleInGroup( "pvt_innerFoot_R", attachmentGroup ) sfmUtils.CreateAttachmentHandleInGroup( "pvt_heel_L", attachmentGroup ) sfmUtils.CreateAttachmentHandleInGroup( "pvt_toe_L", attachmentGroup ) sfmUtils.CreateAttachmentHandleInGroup( "pvt_outerFoot_L", attachmentGroup ) sfmUtils.CreateAttachmentHandleInGroup( "pvt_innerFoot_L", attachmentGroup ) #============================================================================================== # Re-organize the selection groups #============================================================================================== rigBodyGroup = rootGroup.CreateControlGroup( "RigBody" ) rigArmsGroup = rootGroup.CreateControlGroup( "RigArms" ) RightArmGroup = rootGroup.CreateControlGroup( "RightArm" ) LeftArmGroup = rootGroup.CreateControlGroup( "LeftArm" ) RightLegGroup = rootGroup.CreateControlGroup( "RightLeg" ) LeftLegGroup = rootGroup.CreateControlGroup( "LeftLeg" ) sfmUtils.AddDagControlsToGroup( rigBodyGroup, rigRoot, rigPelvis, rigHips, rigSpine0, rigSpine1, rigChest, rigNeck, rigHead ) rigArmsGroup.AddChild( RightArmGroup ) rigArmsGroup.AddChild( LeftArmGroup ) sfmUtils.AddDagControlsToGroup( RightArmGroup, rigHandR, rigElbowR, rigCollarR ) sfmUtils.AddDagControlsToGroup( LeftArmGroup, rigHandL, rigElbowL, rigCollarL ) rigLegsGroup.AddChild( RightLegGroup ) rigLegsGroup.AddChild( LeftLegGroup ) sfmUtils.AddDagControlsToGroup( RightLegGroup, rigKneeR, rigFootR, rigToeR ) sfmUtils.AddDagControlsToGroup( LeftLegGroup, rigKneeL, rigFootL, rigToeL ) sfmUtils.MoveControlGroup( "rig_footRoll_L", rigLegsGroup, LeftLegGroup ) sfmUtils.MoveControlGroup( "rig_footRoll_R", rigLegsGroup, RightLegGroup ) sfmUtils.AddDagControlsToGroup( rigHelpersGroup, rigFootHelperR, rigFootHelperL ) # Set the control group visiblity, this is done through the rig so it can track which # groups it hid, so they can be set back to being visible when the rig is detached. HideControlGroups( rig, rootGroup, "Body", "Arms", "Legs", "Unknown", "Other", "Root" ) #Re-order the groups fingersGroup = rootGroup.FindChildByName( "Fingers", False ) rootGroup.MoveChildToBottom( rigBodyGroup ) rootGroup.MoveChildToBottom( rigLegsGroup ) rootGroup.MoveChildToBottom( rigArmsGroup ) rootGroup.MoveChildToBottom( fingersGroup ) rightFingersGroup = rootGroup.FindChildByName( "RightFingers", True ) if ( rightFingersGroup != None ): RightArmGroup.AddChild( rightFingersGroup ) rightFingersGroup.SetSelectable( False ) leftFingersGroup = rootGroup.FindChildByName( "LeftFingers", True ) if ( leftFingersGroup != None ): LeftArmGroup.AddChild( leftFingersGroup ) leftFingersGroup.SetSelectable( False )[/spoiler:r0nw7jdl] And here's an image to give you an idea of the bones:
Sun, 24 Mar 2013 04:36:08

DemonicLemon

https://dl.dropbox.com/u/4670602/SFM/ri ... rgonian.py Here's the rig for Argonians and Khajiits, male and female. Compare the rig you made to this one.
Sun, 24 Mar 2013 05:24:55

Goron_Ozzy

I think i see the problem in the .py Obviously you have removed the rigSpine3 rig because it's redundant, however here: allRigHandles = [ rigRoot, rigPelvis, rigSpine0, rigSpine1, rigChest, rigNeck, rigHead, The rigChest is related to Spine3. So pretty much go through the file and delete all instances of Spine3 and rigChest you can find, and just redirect your collar bones to be rigged to Spine2 instead. God i probably worded that horribly XD
Sun, 24 Mar 2013 05:36:51

Nurb

"DemonicLemon" said ...
https://dl.dropbox.com/u/4670602/SFM/rig_biped_Argonian.py Here's the rig for Argonians and Khajiits, male and female. Compare the rig you made to this one.
Oh man thanks for the quick reply and this python script! I looked and about the only difference I saw was that I used NPC Pelvis for the rigRoot and they used NPC COM, but when I tried it, no go. (Though I missed the space in [COM ] >< ) However, I tried the script you have there, and it didn't take that either... BUT the rig DID work on the male and female Argonian and male khajiit and they all use the same bone naming system. Can models become corrupt and not take any rig at all? EDIT: I loaded up a model I didn't use; Khajiit Female in Draugr armor, and it took the provided rig just fine. So I don't know what's wrong with the female nude model not taking it :|
"The 'Strayan Snip3r" said ...
I think i see the problem in the .py Obviously you have removed the rigSpine3 rig because it's redundant, however here: allRigHandles = [ rigRoot, rigPelvis, rigSpine0, rigSpine1, rigChest, rigNeck, rigHead, The rigChest is related to Spine3. So pretty much go through the file and delete all instances of Spine3 and rigChest you can find, and just redirect your collar bones to be rigged to Spine2 instead. God i probably worded that horribly XD
Thanks for taking a look Hmm, I defined rigChest with boneSpine2. And I deleted all instances of boneSpine3 rigChest = sfmUtils.CreateConstrainedHandle( "rig_chest", boneSpine2, bCreateControls=False ) Does the chest screw everything up despite the definition being a spine bone?
Sun, 24 Mar 2013 05:54:25

Goron_Ozzy

I'd probably go as far as just deleting all the rigChest instances in the .py whereever they pop up :P
Sun, 24 Mar 2013 06:32:21

Nurb

I think I'll have to check my code later because every female khajiit model I've loaded took the rig DemonicLemon provided except the nude female khajiit model. Even copied over the skyrim files again and still no-go. This is nuts! I appreciate the help so far though!
Sun, 24 Mar 2013 06:45:35

Goron_Ozzy

If you want i could spare you the trouble and just do it myself :P
Sun, 24 Mar 2013 07:22:58

Nurb

"The 'Strayan Snip3r" said ...
If you want i could spare you the trouble and just do it myself :P
Thank you for the offer, maybe you can figure out why the khajiit_f_nude model is the only one out of this pack won't accept any rig (or the one from DemonicLemon up there) when the others do just fine. It's in the skyrim megapack if you have it. If yours works I'll look at mine because I have got to know what I screwed up on :D
Sun, 24 Mar 2013 08:17:38

Goron_Ozzy

Not sure i have the megapack, and i don't want to waste a few hundred odd mgb for a model :P Could you like pack up all the model and material files for it and just throw it on filesmelt? That'd be awesome :)
Mon, 25 Mar 2013 00:22:30

Nurb

"The 'Strayan Snip3r" said ...
Not sure i have the megapack, and i don't want to waste a few hundred odd mgb for a model :P Could you like pack up all the model and material files for it and just throw it on filesmelt? That'd be awesome :)
Well it seemed to work out at the last minute. I guess the file was corrupted somehow and replaced the skyrim files to make make sure. I started a fresh scene and the model took the rig, even mine! The only difference that screwed up my script initially was that I used "NPC Pelv" instead of "NPC COM" for the bonePelvis. So now all is well and my monitor gets to stay inside instead of thrown out the window :D Thanks for all the help though, guys! That provided script proved I wasn't actually going crazy 8-)
Mon, 25 Mar 2013 02:16:14

Goron_Ozzy

Glad to hear everything worked out :D