UE4 CALIKO port (FABRIK with connected chains and constraints)

The existing UE4 version of FABRIK doesn’t support chains or constraints so I created a port of CALIKO. I was originally planning to create new animation nodes and set it up as a plugin. I’ll probably use another type of system for IK so I don’t think I’ll continue working on this. It might be useful to someone so I thought I’d upload the source code.

Create a new project called “IK” and add the source code. Don’t forget to include the Log category in IK.cpp / IK.h. Add a FabrikDemoActor to the scene. Add a target object e.g cube scale 5%. In the AFabrikDemoActor settings set the “Target Actor” property to the cube. Add a FabrikDebug component to the FabrikDemoActor (draws lines). Use the FabrikDemoActor “Demo Type” setting to try different demos. The debug lines appear better in wireframe mode. This only supports 3d chains and is missing most of the validation in the setters (just using properties).

Issues:
[3D] Solutions involving local hinges may exhibit discontinuities · Issue #2 · FedUni/caliko · GitHub [3D] Solutions involving local hinges may exhibit discontinuities. Sounds like it can be fixed using quaternions.
I’ve only roughly ported it and checked if the demos work so it might have some porting bugs.

http://www.andreasaristidou.com/FABRIK.html

Thank you for this DividedByZero.

It will be really helpful in the future. I was thinking to add constraints to FABRIK. For now it is not urgent at all, but still good to have something to start if i need it.

That’s fantastic! Bravo, DivideByZero!

Sorry it didn’t quite meet your needs (and that you had to plow through all those code-comments, hope they were more use than hindrance!).

Cheers!

-Al [author of the Caliko library]

thanks:):slight_smile:

Dear Dividebyzero!

You are my hero of the day! I was just about start porting CALIKO myself and here you are saving the day/week/month (I am a lousy coder). I hope you dont mind a question or two. I am somewhat new to Unreal (I have more experience with unity and blender). Could you clarify what you’ve meant by adding log to IK.cpp/IK.h? Also as far as I understand the fabrikdemoactor is an empty object (in sense that it is not a skeletal mesh) that simply draws lines similarly to visualization_demo in caliko?

Best regards
Bukeikhan Omarali

Hi r3dux, thanks for making CALIKO open source. The structure made it easy to port, I normally have porting issues when the code includes nested dependencies. I was planing to add the method comments back in after I finished but I ran out of time. If anyone wants more details on how the code works they should check the original version.

Hey buky1992, I’m also fairly new to Unreal and have a Unity background. If you create a new project called IK then you can just add the code from IK.h and IK.cpp. If you create a project called something like Demo then you should have a Demo.h and Demo.cpp. Just add


DECLARE_LOG_CATEGORY_EXTERN(IKLog, Log, All);

to Demo.h and


DEFINE_LOG_CATEGORY(IKLog);

to the end of Demo.cpp. You also have to check some header files and replace IK_API with Demo_API.

For anyone stumbling upon this in the future, I managed to compile/test it under 4.20.x. Here is how to do it:

  • The test project to create has to be an empty C++ project named IK
  • When copy/pasting the source files in the Source/IK folder, you can safely overwrite the IK.cpp and IK.h files with those provided in the ZIP file
  • Next open the solution file in Visual Studio and manually add the others .h and .cpp in the Source/IK folder. Use Add Existing Item.
  • When Building, you will get errors because the IK.h file is the first include in some of the modules but the Build Tool expects the module specific one to be the first. Just move “IK.h” to the bottom of the include stack and the error will disappear
  • When Building, you will get multiple errors on the UE_LOG function. This is because each and every module using a custom log class needs to include the base header file (IK.h) and that is missing in some of the modules. If it is missing, just add it in the includes and the error will disappear
  • When Building, you will get errors on DrawDebugPoint and DrawDebugLine. This is because the #include “DrawDebugHelpers.h” is missing from those modules. Just add it and the error will disappear.

At this point you should be able to compile the module and setup your test project as described.To test the different demos, you can use Simulate instead of Play, which makes it easier to grab the Target cube (make it movable) and move it around to see how the kinematic chain tries to track it.

Have fun!

Thanks vr_marco! I’m learning some Unreal Engine, so would be fun to have a play with this Caliko port =D