Jump to content

How to apply Inverse Kinematics (IK) in babylon


Recommended Posts

I have an arm like structure, it is loaded in to babylon as 3 different meshes. I would like to input the XYZ point in 3D space as to move the arm to that coordinate position.

Without Inverse kinematics (IK) is it possible ?. If yes, could you please share a sample code.

Link to comment
Share on other sites



If I understand correctly, you are looking to translate an end effector of a bone chain to an (x,y,z) position and have this single transform update each bone/joint orientation of an IK chain hierarchy?  If this is your goal, then I believe this is not currently possible the way you desire - to automatically update bone orientation in an IK chain.  At least not without a complex series of constraints to "simulate" the behavior of an IK joint/bone hierarchy.  The only other current possibility might be to constrain the centers of each joint/bone in a skeleton hierachy (with additional constraints required  to simulate the relationships in the skeleton hierarchy) and to constrain these joint centers to the points on a spline, and articulate/translate the points on the spline affecting the centers of the bone chain - known as spline IK ( if you are unfamiliar with this specific IK relationship.)  But the results are odd at best for any decent character animation.


However, I believe IK support is needed and essential for babylon.js.  I'll try and find code for a robust, flexible, and reliable IK chain method, as there are several we could choose from - however, we should only choose one method of function, attributes, and behaviors, and completely commit to that one method for all of eternity.  This function, attribute... whatever - IK - is far more difficult to impliment than most people probably perceive it might be, as it relies so heavily on multiple key functions such as parenting hierarchies, inherant dependancies, very specific constraint relationships, bone mesh attributes which specifically apply to the IK behavior, joint area limits and behaviors inherited from and between parent and child bones, "special" objects and unique object attribues and behaviors such as chain roots, end effectors, etc., and a plethera of quaternion formula no one will want to ever know - and that's simply a slice of what is ESSENTIAL for any IK chain worth using at all.


We could start out with a simple "simulated" IK chain constraint along with additional additive constraints to cover specific needs, but this would end up being a complete waste of time.  Please trust me on this, as I've been down this road many times and for many years - repreatedly.  I personally would suggest choosing the IK chain functions which Kaydara wrote (and was aquired by Autodesk) which is written into the .fbx file format and adopted by all Autodesk products following the Kaydara Filmbox software aquisition.  This will provide the most flexibility in the short term, and in the long term allow for maximum flexability in retargetting animation as well as simplifying a whole host of tools for blending animation, managing/handling bone "flipping" (rotation order matrix limitations in joint rotational behavior), allow for additional and rational joint/chain transforms such as translation and scaling, and a long, long list of functions that EVERYONE (even those not working with character animation, rigging, vertex weighting, etc.) will find useful and even essential in solving more complex animations in their scenes and projects.


When I return from vacation next week, I'll contact Andre Guatier who founded Kaydara, wrote the .fbx file format and the Motionbuilder software suite (originally licensed as Kaydara "Filmbox"), and ask if he might provide or assist in writing the support for IK in Babylon.  I'll do my best to post the scope of what he might contribute to let the community know if he is available (and even interested) for his invaluable guidance - however, the bad news for those who need this immediately, is that there will be virtually no movement and no IK available for at least a month or more - which actually is a VERY OPTIMISTIC timetable (regardless of who gets involved) - unless I can push Andre into a multi night / massive cigarette pack coding binge like we used to have in "the good old days."  Or unless someone unknown to me (which I strongly vote against any short term or temp solution) decides to write a simple IK solution which I can assure would be a mistake for a miriad of reasons - not to mention the ugly legacy that always survives when pushing an incomplete IK solution into a well oiled machine such as babylon.js.  The regret of doing so lasts indefinately, and limitations and incompatabilities makes this path a very poor choice.


As mentioned, I'll let the forum know as soon as I hear from Andre.  In the meantime, for those who believe they might try to tackle this one - "good luck with that."  But don't fret, we'll get it done; we have to - and hopefully in a reasonable time frame.  ;)



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...