- NOTICE: This project is a read-me ONLY. The codebase the project was developed on is confidential and thus cannot be shared.
Presentation (Presents outdated codebase. Branching, quaternion calcultions, and end effector movement have been remedied as explained below).
I implemented inverse kinematics in OpenGl
Development Process:
-
Find a way to represent and update the joint chain
-
Ended up finding all the bones with no children, and those endpoints would be the end effectors
-
The chain would be the bone with the end effector and all its parents
-
Because IK deals with joints, but we only have bones with A4, I had to add an extra layer of abstraction when updating joint positions:
-
-
Find a way to visualize and intersect the end effectors
-
Created and rendered a unit sphere (pain), and put it at all the end effector positions
-
Find when mouse intersects end effector
-
Highlight intersected end effector with gridded lines
-
-
Find way to tell end effector where I want it to go
-
Implement FABRIK
- Used http://andreasaristidou.com/publications/papers/FABRIK.pdf as main reference
- Code is inverseKinematicsTranslation(targetPos) in Scene.ts
- Results:
-
Fix branching issue
-
FABRIK doesn’t handle branching (updating positions of bones not in the joint chain)
-
I’m handling this by setting all children’s positions to their parents endpoint at the end of an IK iteration
- This works for most scenes, but breaks if the scene has disconnected bones (such as the mannequin and the head). I tried to remedy this, but didn’t have enough time to find a good solution.
-
-
Get Quaternion calculations working
-
This is what the professor and I were discussing for quite a while.
-
The solution ended up being quite simple:
Used https://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another as reference
-
-
Bugs/limitations
-
Codebase difficulties
- A4 is extremely difficult to deal with due to needing render passes and shaders for everything (rendering the sphere/gridded lines around the sphere alone was quite painful)
- A4 has bones, not joints, so had to add extra logic and abstractions to represent that
- FABRIK expects a single chain, not branching, which is required for A4 models
- FABRIK expects connected joints, but A4 models have separated joints (not enough time to fix this, unfortunately)
- I hate quaternions (that issue alone took forever, yet the solution was so simple ;-;)