Rigging a Fish – Triple Joint Solution

Certainly not refined animation, but the goldfish is happy!

In my adventures of creating my thesis, I need one of my “scenes” to include a goldfish.  And as you can see by the above, the fish is stylized and not real looking – especially those dang fat fins… But this is necessary when prepping for 3D printing!  That aside, I struggled over a week on how to animate this fish to make it feel reel or believable.  I also wanted to refine controls while having the fish basically swim freely and automated.  After much scratching and flipping tables, I figured out a solution that ended in a good night’s rest!  I’ll share an overview and a couple scripts below so it may hopefully help out people later.  This can be applied to anything that involves ripple-like animation such as snakes, birds, sting-rays, etc!

So, basically what I’m asking for is a rig that allows for Forward Kinematics and Inverse Kinematics controls as well as Automation that can speak to each-other kindly.  In order to do this, we first need to make a joint system of the fish and then name it properly.  One thing I’ve learned in the game of rigging:  Name Conventions are KING!  …And you have to stick by that… Otherwise, you’ll get screwed in the end.  So the first thing you want to do is create that joint system that has the parenting of joints you want.  Besides, I have a script later in this post I’ll share to help you with the setup process!

Before you continue, you’ll want to keep in mind that you want to make sure you orient all your joints appropriately!  If you don’t do this now, you’ll run into problems later I’m sure.  This aside, you may wind up with a joint system similar to this:

Joints in mine were doubled on-top of each-other to allow for finer controls and more flexibility with the rig.

After this, you want to go ahead and duplicate the entire structure and rename one of the structures with “_AUTO” at the end of each joint like this:

Nothing different in naming other than tacking on “_AUTO” at the end of each one.

And, of course, our third joint set which will have the “_FKIK” at the end instead this time:

Remember, this is the third set of the rigging system and again, no surprises in naming here.

Now that you have your three sets, as you can guess, one will be skinned to the object (the standard name joint system) and the other two will be left in the exact same spot.  Keep in mind you do not want to move these at all – keep them in the same position, otherwise, if you’re goofing around with the joints, you may regret it later.

Now that you have all these guys, you’ll wonder “great, now I have all these joints, what do I do with them?”  Well, the reason why we have three joint systems is so that when you use FKIK controls on one and Automation on the other, they’ll avarage out their changes to influence the original joint system – of which you can fine tune to have only FKIK control OR Automation run your rig.  So, in order to do this, we need to do a very tedioius, but necessary task of having each FKIK and AUTO joint control the main joint system.  How we will do this is by constraining the main joint to both the FKIK and AUTO joints.  This way, it’ll share the load of each, or like I mentioned before, you can control how much it’s influenced.

So what you want to do is select, for example, the BaseJoint_FKIK joint first, then the BaseJoint_AUTO joint next and, lastly, select the BaseJoint joint.  The last object selected will be the one that is bound and restricted to the shared movement from the other two joints.  But keep in mind this very thing – Joints (at least in this rig design for very good reason) must be constrained using the orient constraint and not the parent constraint.  The simplified reason can be visually explained on how each one would look as seen below:

Notice the bad deformation in the fin as it moves from left to right… Stubby…

Notice the proper deformation in the fin as it moves from left to right – in this case, orient constraints for the fish are better suited.

Joints are typically used to rotate, not translate.  If they were parented, which affects both translate and rotate, then you get the poor deformation as illustrated above.  This is because when the constraints are working, they are averaging information – so if they interpret the translates of the joints as well, this results in a shortening between the three joints.  Using only orient constraints affect the rotations of the joints only and therefore, works properly.

Now that you learned this, you’ll want to go through the entire joint system and orient constraint each of the FKIK and AUTO clones of the main rig.  OR, if you are into scripting, here’s a simple solution for you that I worked up:

Simply – select all the main joints and then run the script!  This will save you the pain an agony that I went through manually doing it originally.  I quickly learned my lesson on why it’s important to invest into coding and this screen will happen for you Maya users once in a while!  Worst situation is when it happens when you save and then it appears.

There are times where I considered divorcing Maya… This was one of those situations! Who ever thought that crashing while saving was a funny idea and does that “Check online for a solution…” EVER ACTUALLY WORK?!?!?!?!

So, after running the script, you’ll notice your scene should look something like this:

This could have been a human-error nightmare!

I’ll assume you went through and created controllers for your joints and that you constrained each one of them correctly to the FKIK joint rig like you would any other rig.  This is pretty straight forward for a majority of animators.  The only addition I’d ad to your rig is a control that is connected to your character move controller so it follows the character wherever it goes.  Reason being is that the following will add many attributes to your controls, so it’ll be easier to create a system that separates that out.  Basically, I created a NURBS curve, named it “AutoCTRL” and parented to my FishCTRL which moves the entire fish along scene while the MasterMoverCTRL places the fish into scene.

An example of my control setup and hierarchy. I get great satisfaction out of being organized.

Now – after running through the controls for FKIK and constraining the joints to them, we move on!  The next step is a bit complex and has a ton of tedious work, but it’s great once it’s done.  Simply, we need to start making attributes for each joint and then create an expression that we all applying to the AutoCTRL object.  It will be a lot, but has many opportunities for fine controls or great opportunities for rigging artists to create special controls on the rig that gives it a cool interface (I did this for my Bean Caught character rigs in the past).

Before we continue adding attributes to the AutoCTRL, we want to figure how we want to actually automate the swimming effect!  Quite simply, we’ll create an expression and variables to help control a Sin Wave.  As we know from basic algebra, Sin waves oscillate between -1 and 1 and there are various factors that we should be aware of when breaking down how we can control the Sin wave for our needs:

  • Frequency – how often it occurs
  • Amplitude – how strong or weak
  • Delay – offset of the Sin wave’s start

Just a visual understanding of the variables and what they do.

When creating the expression to create the effect of the fish swimming automatically needs to have these three variables integrated for each joint.  This will become pretty daunting if done by hand, but luckily, I created a function to handle this very easily!  First off, let’s look at the function within the expression that we’ll use and how I broke it down:

With this function, we’ll want to apply the joint’s name in replace of “JointName” and then you can choose which rotation axis you want to use.  Since most of us Maya users use Scene Up prefs being Y, we’ll stick with “rotateY”.

So where do the values for the variables come from?  Well, it’ll need to come from each of the three attributes per joint we want assigned.  We’ll also want to include some Master Level attributes to help drive the entire equation. These attributes will reside on the AutoCTRL to make this process and level of control easy to access and manipulate.  So the Master Control Variables we’ll also add to the equation are:

  • Master Amp – Variable amplitude factor
  • Master Delay – Variable delay factor
  • Master Freq – Variable frequency factor
  • Master Auto Swim – Global factor – basically on or off, but a bit more than that

Normally, for an animator/rigger relationship, the rigger would put restriction and ranges for each attribute we’ll create.  But for me, I’d like to leave it wide open at least for myself to give me a great deal of flexibility.  That’s what these Master Attributes will do for each joint, applied as a factor to the variables before the fall into the equation.  So, if I was to pick out a Joint, such as one of the Spine Joints, the complete expression would look like this:

I believe most of this is self-explanatory, but to point out one factor is that the frequency is really a time/frame based operation.  So in this respect, for “AutoCTRL.MasterFreq/12″, I picked out to divide the Master frequency by 12 since there are 24 frames typically in film and it also allows the numbers to be a bit more manageable and not decimal in most cases or needs.  Also note that I added the “AutoCTRL.MasterAutoSwim”, as noted before, to influence the entire equation as a on/off or subtle adjustment piece to the refinement of the swim effect.  Also note that we are ONLY affecting the AUTO joints!  This is the only way we’ll be able to make things work properly in the end.

So, now that we need to make a ridiculous amount of attributes to our AutoCTRL object, I’ll save you the time and not only will the following code create the attributes by selecting the main joints, it’ll also apply each, unique, expression to the AutoCTRL object!  (I’m such a nice guy, right?)

After running through the code on the selected main joint rig, you’ll get something that looks like this where you can enter numbers and the expression takes care of the rest!

Overlay to show what the script will do with your joints by creating the crazy amount of attributes and expressions for all your joints. FULL LEVEL CONTROL!

So, by default, nothing will work on it’s own as all controls are set to zero.  You’ll need to go through and turn on what joints you want to do what.  To start, you can run through all the controls and set 1′s or even go into the code to do this by default.  There will be better ways to take it from here, but for my needs, I’m set with what I have.  If I wanted to go further, I would have edited the ranges and setup a GUI to run the automation using nurbs curves and controls often seen on advanced rigs.  Also to include are sliders to do a blending or turning on and off Automation on all or parts of the rig would be an advantage too.  To give you an idea what happens when you apply your FKIK controls on the beast, you’ll see the proper blending between both:

Here’s an example of futzing to show off the blending of FKIK and Auto with the Joint Overlay.

Just the joints – notice the averaging performed and how the other two “extremes” work together to create the animation effect.

No joints – simply better to see the controls and animation.

Hopefully the fruit of my efforts helped out those interested in this subject matter.  More importantly, I hope the fruit of my labor on my thesis makes all this worth it!

2 Comments

  • Vijay says:

    There is a saying in indian mythology :
    “Karmanye Vaadhika Raste, Ma phaleshu Kadhaa chana”
    it means.. do your duty and stop worrying about the fruits it will reap. :D
    But that being said… good writeup. Very useful for those that have pondered this very approach before. I follow a pretty similar approach to rigging the arm using IK/FK. (i am sure you guys do too)
    A good flexible rig and will be fun to animate this.

Leave a Reply

Your email address will not be published.