DigitalEro Offline

Tutorial - Making Custom Model IK Rigs.

Sat, 06 Apr 2013 02:40:10

Turbotom

I finally figured out how to do this...and it's very simple. :D This is the kind of movement you can make by just selecting the pelvis after applying IK it makes it a of A LOT easier if you want hands and feet to stay put so their joints don't look like rubber. This is very simple and all you need is: notepad++ http://notepad-plus-plus.org/ or basic notepad...notepad++ is better though and sfm...obviously I will try to make this as dummy proof as possible...so far this has worked for me. If anybody wants to add anything feel free to tell me because I am no expert whatsoever at coding or anything. 1. find this file ... rig_biped_simple.py .. and copy/paste it in same folder steamapps>common>SourceFilmmaker>game>platform>scripts>sfm>animset 2. open the copied file in notepad++ Look for this specific section in the file ... boneRoot = sfmUtils.FindFirstDag ... etc. This is the section where you are going to add all the "bones" that are currently named differently on the custom model. Launch SFM and load up a custom model you want to IK. examples of bone names: 3. Add appropriate bone names to the code in the square brackets... example, adding pelvis: change this
bonePelvis    = sfmUtils.FindFirstDag( ["ValveBiped.Bip01_Pelvis",		"Bip01_Pelvis",		"bip_pelvis" ], True )
to
bonePelvis    = sfmUtils.FindFirstDag( [ "pelvis",		"ValveBiped.Bip01_Pelvis",		"Bip01_Pelvis",		"bip_pelvis" ], True )
This is telling sfm to look for these specific bone's names to apply to the new rig.. Some bones are named very differently...for example the knee joint here is called "shin". so make sure you click on the bones in the motion editor to make sure you got the right ones. 4. IMPORTANT (i think)... you may not have enough bones to use for the rig...for example, this specific model does not have the same amount of spine bones (only 3..spine,spine1,spine2): Use your best judgement to pick which ones you want to label as "false" (turning it off). 5. Finish up the code and make sure you didn't fuck up on spelling and stuff. Keep filling it out all the way down to the hands. Example of some of the finished code: notice one of the spine bones is labeled as false 6. "Save as" your new rig file in notepad++ to whatever you want and load up your rig to see if it loads properly. 7. and hopefully it works! ...the skeleton rig should look something like this That's it! your done! enjoy easier animating! NOTE** If you still want access to the other controls (face posing, etc)... enable hidden controls. now the basic and IK rigs are available for use..be careful using both at the same time. ANOTHER NOTE*** Sometimes the rig won't load..when you check the console (~) you will see this warning
__main__:165: RuntimeWarning: Unable to create rig 'rig_biped_model_name'.
I don't know exactly what this means...I think it could be a memory issue. What I usually try is loading up a very basic map (like box) and seeing if it works there. If it works in that map...try going back to your previous scene and loading the rig again. This usually solves the issue for me. Or restart SFM. full IK code for manuella for reference.
#==============================================================================================
    # Find the dag nodes for all of the bones in the model which will be used by the script
    #==============================================================================================
    boneRoot      = sfmUtils.FindFirstDag( [ "RootTransform" ], True )
    bonePelvis    = sfmUtils.FindFirstDag( [ "pelvis",		"ValveBiped.Bip01_Pelvis",		"Bip01_Pelvis",		"bip_pelvis" ], True )
    boneSpine0    = sfmUtils.FindFirstDag( [ "spine",		"ValveBiped.Bip01_Spine",		"Bip01_Spine",		"bip_spine_0" ], True )
    boneSpine1    = sfmUtils.FindFirstDag( [ "spine",		"ValveBiped.Bip01_Spine1",		"Bip01_Spine1",		"bip_spine_1" ], False )
    boneSpine2    = sfmUtils.FindFirstDag( [ "spine1",		"ValveBiped.Bip01_Spine2",		"Bip01_Spine2",		"bip_spine_2" ], True ) 
    boneSpine3    = sfmUtils.FindFirstDag( [ "spine2",		"ValveBiped.Bip01_Spine3",		"Bip01_Spine3",		"bip_spine_3",	"ValveBiped.Bip01_Spine4" ], True )
    boneNeck      = sfmUtils.FindFirstDag( [ "neck",		"ValveBiped.Bip01_Neck",		"Bip01_Neck",		"bip_neck_0",	"bip_neck", "ValveBiped.Bip01_Neck1" ], True )
    boneHead      = sfmUtils.FindFirstDag( [ "head",		"ValveBiped.Bip01_Head",		"Bip01_Head",		"bip_head",		"ValveBiped.Bip01_Head1" ], True )
    
    boneUpperLegR = sfmUtils.FindFirstDag( [ "R_thigh",		"ValveBiped.Bip01_R_Thigh",    "Bip01_R_Thigh",    "bip_hip_R" ], True )
    boneLowerLegR = sfmUtils.FindFirstDag( [ "R_shin",		"ValveBiped.Bip01_R_Calf",     "Bip01_R_Calf",     "bip_knee_R" ], True )
    boneFootR     = sfmUtils.FindFirstDag( [ "R_foot",		"ValveBiped.Bip01_R_Foot",     "Bip01_R_Foot",     "bip_foot_R" ], True )
    boneToeR      = sfmUtils.FindFirstDag( [ "R_toe",		"ValveBiped.Bip01_R_Toe0",     "Bip01_R_Toe0",     "bip_toe_R" ], True ) 
    boneCollarR   = sfmUtils.FindFirstDag( [ "R_shoulder",	"ValveBiped.Bip01_R_Clavicle", "Bip01_R_Clavicle", "bip_collar_R" ], True )   
    boneUpperArmR = sfmUtils.FindFirstDag( [ "R_arm",		"ValveBiped.Bip01_R_UpperArm", "Bip01_R_UpperArm", "bip_upperArm_R" ], True ) 
    boneLowerArmR = sfmUtils.FindFirstDag( [ "R_forearm",	"ValveBiped.Bip01_R_Forearm",  "Bip01_R_Forearm",  "bip_lowerArm_R" ], True )
    boneHandR     = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_R_Hand",     "Bip01_R_Hand",     "bip_hand_R" ], True )
   
    boneUpperLegL = sfmUtils.FindFirstDag( [ "L_thigh",		"ValveBiped.Bip01_L_Thigh",    "Bip01_L_Thigh",    "bip_hip_L" ], True )
    boneLowerLegL = sfmUtils.FindFirstDag( [ "L_shin",		"ValveBiped.Bip01_L_Calf",     "Bip01_L_Calf",     "bip_knee_L" ], True )
    boneFootL     = sfmUtils.FindFirstDag( [ "L_foot",		"ValveBiped.Bip01_L_Foot",     "Bip01_L_Foot",     "bip_foot_L" ], True )
    boneToeL      = sfmUtils.FindFirstDag( [ "L_toe",		"ValveBiped.Bip01_L_Toe0",     "Bip01_L_Toe0",     "bip_toe_L" ], True ) 
    boneCollarL   = sfmUtils.FindFirstDag( [ "L_shoulder",	"ValveBiped.Bip01_L_Clavicle", "Bip01_L_Clavicle", "bip_collar_L" ], True )        
    boneUpperArmL = sfmUtils.FindFirstDag( [ "L_arm",		"ValveBiped.Bip01_L_UpperArm", "Bip01_L_UpperArm", "bip_upperArm_L" ], True ) 
    boneLowerArmL = sfmUtils.FindFirstDag( [ "L_forearm",	"ValveBiped.Bip01_L_Forearm",  "Bip01_L_Forearm",  "bip_lowerArm_L" ], True ) 
    boneHandL     = sfmUtils.FindFirstDag( [ "ValveBiped.Bip01_L_Hand",     "Bip01_L_Hand",     "bip_hand_L" ], True )
If I am missing anything feel free to add onto this!
Sun, 07 Apr 2013 07:35:47

Goron_Ozzy

Good job on the tut. Was going to make one earlier, thought 'Bugger it' and then this pops up :D
Sun, 07 Apr 2013 17:01:14

Turbotom

"The 'Strayan Snip3r" said ...
Good job on the tut. Was going to make one earlier, thought 'Bugger it' and then this pops up :D
Thanks! can you move this to the other "tutorials" page? I didn't realize there was an official page for finished ones.
Sun, 14 Apr 2013 17:14:52

Eddy

Hi, I followed your steps but the rig didn't work for me :/ I was trying to rig the nude version of Kitty Pousoix but the rig didn't attach to her. Here's a screencap of the text document.
Sun, 14 Apr 2013 18:07:53

LordAardvark

You can just disable the bones? All this time I've been deleting the unnecessary bones and then restructuring the entire bone hierarchy. This is a lot easier. Haha.
Sun, 14 Apr 2013 20:17:52

Eddy

"LordAardvark" said ...
You can just disable the bones? All this time I've been deleting the unnecessary bones and then restructuring the entire bone hierarchy. This is a lot easier. Haha.
I don't quite understand, how do I disable the bones? :)
Wed, 17 Apr 2013 02:34:37

Turbotom

"Eddy" said ...
"LordAardvark" said ...
You can just disable the bones? All this time I've been deleting the unnecessary bones and then restructuring the entire bone hierarchy. This is a lot easier. Haha.
I don't quite understand, how do I disable the bones? :)
Hey Eddy sorry for the late response. I tried making the nude kitty work but I couldn't get the hands to work for some reason...very odd. All the other limbs worked fine though... :????: I might have to redo a IK script again to see if it works. "disabling" the bones are the ones you mark as "false" in the script.
Thu, 18 Apr 2013 16:07:32

Eddy

"Turbotom" said ...
"Eddy" said ...
"LordAardvark" said ...
You can just disable the bones? All this time I've been deleting the unnecessary bones and then restructuring the entire bone hierarchy. This is a lot easier. Haha.
I don't quite understand, how do I disable the bones? :)
Hey Eddy sorry for the late response. I tried making the nude kitty work but I couldn't get the hands to work for some reason...very odd. All the other limbs worked fine though... :????: I might have to redo a IK script again to see if it works. "disabling" the bones are the ones you mark as "false" in the script.
Ah okay, thank you for the reply!
Wed, 08 May 2013 09:03:41

Freshmeat487

Very helpful, you should consider putting this on the SPUF as well.
Wed, 03 Jul 2013 20:01:59

Brother Antroz

Useful tutorial overall, but it flatout doesn't work with some models. Like the Catwoman one available on garrysmod.org I did everything you said, it loaded the rig up, but it didn't matter: nothing happened.
Wed, 03 Jul 2013 20:12:52

Ganonmaster

"Brother Antroz" said ...
Like the Catwoman one available on garrysmod.org I did everything you said, it loaded the rig up, but it didn't matter: nothing happened.
If the rig doesn't apply properly, you made a mistake. Take look at the console for a hint of what went wrong.
Wed, 03 Jul 2013 20:42:19

Brother Antroz

__main__:165: RuntimeWarning: Unable to create rig 'rig_biped_catwoman1'. And apparently there's no reason it does this or way to fix it, sooo...
Wed, 03 Jul 2013 20:58:42

Ganonmaster

"Brother Antroz" said ...
__main__:165: RuntimeWarning: Unable to create rig 'rig_biped_catwoman1'. And apparently there's no reason it does this or way to fix it, sooo...
That's can't be the whole error message. Usually there are more lines. It's definitely fixable.
Fri, 05 Jul 2013 02:32:43

Soulslayerzx

Or the skeleton isn't connected and is a bunch of dots :D
Fri, 05 Jul 2013 07:35:24

DemonicLemon

"Brother Antroz" said ...
__main__:165: RuntimeWarning: Unable to create rig 'rig_biped_catwoman1'. And apparently there's no reason it does this or way to fix it, sooo...
It does this because there is already an IK rig attached to the model. Ctrl Z until the first time you attached an IK rig to the model, or spawn a new model without deleting the other one and it should work.
Sat, 20 Jul 2013 03:33:24

daftkicks11

what if a model have more bone's like say the arm has 5 bone's and on the notepad show's only 3 to put in what do i do
Sat, 20 Jul 2013 04:29:33

Ganonmaster

"daftkicks11" said ...
what if a model have more bone's like say the arm has 5 bone's and on the notepad show's only 3 to put in what do i do
[barred:1b9qda8t]Sit in the darkest corner of your room, cry until your your tears run dry, and contemplate suicide. Should you actually proceed to kill yourself, use a knife, razor, gun or poison. I recommend the gun. Leaves a big mess to clean up for the people who find your dead body. They'll probably say "What an asshole. I've been scrubbing away bits of brain from the wall for over two hours now. Couldn't he just have taken some poison?"[/barred:1b9qda8t] Is it really that hard to use your own judgement and experiment? Try some different combinations? Use the bones with names that have the best fitting descriptions? If the two extra bones are simply helper bones (ie. bones with "twist" in the name), you can usually ignore those. If the model moves weirdly when the IK Rig has been applied, the structure might be incompatible with IK rigs.
Thu, 25 Jul 2013 20:12:45

Turbotom

"Brother Antroz" said ...
Useful tutorial overall, but it flatout doesn't work with some models. Like the Catwoman one available on garrysmod.org I did everything you said, it loaded the rig up, but it didn't matter: nothing happened.
catwoman script http://s000.tinyupload.com/index.php?fi ... 7598218760 Sometimes you have to disable certain spine bones to make it work. There have been a couple of models where there are problems...but you just gotta keep disabling random bones to see if it works. I am pretty sure that catwoman one works.
Mon, 12 Aug 2013 16:48:22

Pipedude

So long as the hand is parented to the twist bone or the lowerarm to the upperarmtwist then it should be fine. The rig script looks for 3 bones when it builds an arm or leg; so for the arm it would be Uperarm, lowerarm, hand and then it needs a place to put the aim controller, thats where the offset vector comes in. It puts the controller at the position of the lowerarm and offsets it by 10 so that its behind the elbow and not at it.
Mon, 12 Aug 2013 14:09:23

arrcs

Hey, I have a question. What if the model has multiple twist bones in between the main joints? (In my case, between the forearms and elbows) would I have to make lines for those bones too? I tried just turning off the random bones but somehow it wouldn't work for me still. Also, I see on some custom rigs that they have offset vectors? What are those for? ...I probably should stop asking so many questions... Great tut though! :D
Tue, 13 Aug 2013 05:01:31

arrcs

"Pipedude" said ...
So long as the hand is parented to the twist bone or the lowerarm to the upperarmtwist then it should be fine. The rig script looks for 3 bones when it builds an arm or leg; so for the arm it would be Uperarm, lowerarm, hand and then it needs a place to put the aim controller, thats where the offset vector comes in. It puts the controller at the position of the lowerarm and offsets it by 10 so that its behind the elbow and not at it.
Alright thanks for the explanation! :D But last question... For now... Do the joints have to be actually "connected"? Or can they just be points instead of having the (lines for the bones)?
Tue, 13 Aug 2013 05:16:34

Pipedude

I don't think so; but the way the system is set up its made for connected bones.
Sat, 17 Aug 2013 15:37:02

maddox991

I have double checked the names of all the bones just to be sure there arent any errors, the rig still refuses to attach to the character though. This is what I get, all the controls are there but they do absolutely nothing. http://imgur.com/GXMS6xP Any ideas?
Sat, 17 Aug 2013 17:14:42

Pipedude

Check console and see what its saying; if theres an error thats along the lines of "old style string" blah blah blah, it means somethings usually misspelled or it can't find a bone - it will give 2 lines of code to look at the first one is where the error is, the last one just ignore. If it says Cant create rig "name of model" then just unrig it and rename the animset.
Sat, 17 Aug 2013 17:58:03

maddox991

Thanks, that helped a lot with figuring it out. Had to swap around the spine bones as the model has only 2 and the rig wouldnt work with them being assigned to spine0 and 1 but rather 0 and 3. :roll:
Fri, 13 Sep 2013 06:10:41

Lokiblade

ok so what do you do when something like the toe is missing. i trying to work around but so far nothing has work. to give an example ba4ka(link to the script https://digitalero.org/phpbb/viewtopic.php?f=47&t=566&hilit=SOUL+Calibur) has made a script for taki from soul caliber which also works on lizard man and ivy(not sure who else) but doesn't worry on amy, talim and raven. i was trying to figure out why till i notice they don't have toe bones.
Fri, 13 Sep 2013 12:18:54

KaylaN

I made this one for talim a while back, I don't recall exactly what I had to change to get it to work but you can have a look. http://filesmelt.com/dl/rig_biped_simple_talim.py
Sat, 14 Sep 2013 01:27:45

Lokiblade

i will take a peak at the code for it later, but it seem to cover all the ones that ba4ka doesn't if you don't mind i would like to release these in their own topic for those who are looking for the script on SFMbox
Wed, 30 Oct 2013 04:21:10

fornaxtacular

Do you have any tips for creating a rig for a non-standardized model (i.e. mermaid or tentacle or something)?
Sun, 03 Nov 2013 15:18:48

Ganonmaster

If you want to animate tentacles or a mermaid's tail, you probably don't need an IK rig because those types of extremities don't bend like arms or legs. You can animate those by selecting the bones in the tentacle or tail, set the rotation mode to "Local". This video explains it pretty well: [youtube:6n4tu09a]u5CUNfNSGdU[/youtube:6n4tu09a] As for incorporating it into an IK rig, it will probably require some more advanced python scripting than this tutorial. If that's not scaring you away, you can look at the IK rig bundled with the Pregnator model. For its IK Rig, I had to modify it to accomodate the 6 legs. Maybe you'll find it helpful.
Mon, 04 Nov 2013 07:49:13

fornaxtacular

"Ganonmaster" said ...
If you want to animate tentacles or a mermaid's tail, you probably don't need an IK rig because those types of extremities don't bend like arms or legs. You can animate those by selecting the bones in the tentacle or tail, set the rotation mode to "Local". This video explains it pretty well: [youtube:3jk0vx7g]u5CUNfNSGdU[/youtube:3jk0vx7g] As for incorporating it into an IK rig, it will probably require some more advanced python scripting than this tutorial. If that's not scaring you away, you can look at the IK rig bundled with the Pregnator model. For its IK Rig, I had to modify it to accomodate the 6 legs. Maybe you'll find it helpful.
Thank you SO much I did not even know that mode existed. I think you've officially taught me more about SFM than the Valve tutorials...
Mon, 23 Dec 2013 08:02:16

Schrödinger

Hello, friend! First of all, let me thank you for this very helpful tutorial. It is very kind of you to share your knowledge of this. I have a problem with the first IK rig I'm working on. It seems to have worked, it applies itself to the model, the former skeleton is replaced by the IK handles, but when I try to use those handles the model does not move, only the handles do. I do not know what I have done wrong and my understanding of programing is very weak. Could you help me?
Mon, 23 Dec 2013 08:17:39

Ganonmaster

"Schrödinger" said ...
Hello, friend! First of all, let me thank you for this very helpful tutorial. It is very kind of you to share your knowledge of this. I have a problem with the first IK rig I'm working on. It seems to have worked, it applies itself to the model, the former skeleton is replaced by the IK handles, but when I try to use those handles the model does not move, only the handles do. I do not know what I have done wrong and my understanding of programing is very weak. Could you help me?
What does the console say?
Tue, 24 Dec 2013 07:15:48

Schrödinger

Hello! Thank you for reading my message. The console seems to show nothing referring to the attachment of the IK rig, not right after it has been applyed at least. When I try to move the handles o the hands or feet, it shows this: Binding uncached material "__utilwireframe", artificially incrementing refcount But as it appears in red after these lines that, I presume, refer to some issues with the model's materials: Binding uncached material "potterywheelpanelwireframe", artificially incrementing refcount Model file 'Evil-Ash\mxn.mdl' and associated vtx files are out of date Error! Variable "$phongexponent" is multiply defined in material "models/evil-ash/mxn/ety1_head"! Error! Variable "$phongexponent" is multiply defined in material "models/evil-ash/mxn/fightingdummy_male_diff"! Error! Variable "$phongexponent" is multiply defined in material "models/evil-ash/mxn/footmale"! I don't know if it has anything to do with the IK rig. What do you think is the problem? Thanks in advance.
Tue, 24 Dec 2013 10:37:15

Ganonmaster

Strange. That stuff has nothing to do with the IK Rig. Not what I was expecting. Which model are you trying to apply your rig to?
Thu, 26 Dec 2013 06:40:17

Schrödinger

I am trying to make an IK rig for Evil-Ash's MrX nude.
Tue, 29 Apr 2014 05:20:43

datdude50

sorry moved to support