I was inspired to create some basic inverse kinematics functionality for the Away3D open source library when I had read that they had added collada bones functionality to their project. My first demo of inverse kinematics with the Away3D version can be seen here. The dragon’s head, neck and tail can be controlled interactively with inverse kinematics but the flying animation is key-framed. The inverse kinematics code for the head, neck and tail simply overrides the key-framed animations.
I know a lot of you have been asking for the source to the robot arm demo that I did in PV3D but I would rather release the Away3D version because I’m going to continue to develop and debug it. I’ll see if I can provide the source to the dragon demo I did in Away soon.
A lot of people have been asking me what inverse kinematics (IK) is. Well, nothing explains inverse kinematics better than a demo of a robotic arm. The robotic arm in this demo should write on the flat drawing surface whatever you scribble on your screen while holding the left mouse button. This demonstrates interactive IK by figuring out the arm’s joint angles for you. These angles need to be calculated constantly according to where on the drawing surface you point to with your mouse. To use the demo:
- Move the mouse to manipulate the camera.
- Hold the left mouse button and move the mouse to move the target for the ‘piece of chalk’ the robot arm is using along the x/y axis of the drawing surfaces.
- Key ‘1′ negates the planes z position (try holding down the mouse button and hitting ‘1′).
- Key ‘2′ erases the writing on the drawing surface.
- Key ‘3′ toggles the visibility of the robot arm’s target.
I got the idea for this demo from this you tube video. I’m not using the same method the students in the video use (skip ahead to near the end of the video). Their method is more exact and converges to a solution more quickly than the one I’m using. I’m using the Jacobian Transpose method still for one simple reason…I can have any number of joints I choose and each of those joints can have one, two or three degrees of freedom without the need for writing a more robust matrix math class than is currently available for AS3.
How my IK implementation differs from the one provided with Flash CS4 is another question I get a lot. It’s almost like comparing apples and oranges because the context is so different but let me try and answer that question:
- The advantage of Adobe’s IK package is that it comes with a nice little graphical interface and is more user friendly. My implementation is strictly in code and is not very user friendly. You’ll have to really understand the hierarchy of your 3D model to use my classes.
- Adobe’s classes are limited to a single degree of freedom and My IK classes can let you realize 3 degrees of freedom for your joints and are designed for use with 3D DAE models and Papervision 3D. However, it would be quite simple for me to adopt my classes to something like 2D movie clips.
- I don’t handle bones or mesh deformation. Papervision already let’s you import models with bones and does the mesh deformation for you. CS4 let’s you create bones fairly easily.
- My joints can have up to 3 degrees of freedom while Adobe’s only has one.
*EDIT* I removed the source temporarily. I’m going to redo and release it again hopefully in a week or two.