Wednesday, June 14, 2017

Inverse Kinematics: Final

I implemented an inverse kinematics system using both analytic IK and cyclic-coordinate descent.

Analytic IK: 

It's fairly simple, just like how it was derived in class. Given the lengths of the two joints, it is possible to directly calculate the angles needed to achieve a target position. In my application, it only works on the first two joints and will ignore the rest.

Cyclic-Coordinate Descent:

This works by figuring out the vector between the base of the joint and the end position and using that to figure out the amount of and direction of rotation to reach the target. 

This is done for each joint, started from the end, and working back to the root.

In my application, CCD works quite well until getting to 5 joints, where it starts to break for unknown reasons. In the video I show several movements. 

I used this website as a reference: http://www.darwin3d.com/gdm1998.htm

Download:

https://drive.google.com/open?id=0B6PLHdK7QrvjckdrUWhWdUhnbkU

Controls:

Arrow keys to move target position. Denoted by the small cube.
A to decrease the number of joints
D to increase the number of joints
S to switch between analytic and cyclic-coordinate descent modes.

Saturday, June 3, 2017

Inverse Kinematics Checkpoint

For the final project, I'll be working on an inverse kinematics system.

So far I have modified my joint system that I created in CSE 169. It involves a hierarchy so that moving the parents affects the children. It takes in a file containing joints, sizes, and poses and creates a skeleton hierarchy that creates a box for each joint.

offset: Distance from the parent joint
boxmin: Lower corner of the box
boxmax: Upper corner of the box
rot*limit: Limit on rotation.
pose: Rotations required to get to a certain position, in radians.

Here's an example file:

balljoint hip_r {
offset 0.1 -0.3 0
boxmin -0.05 -0.3 -0.05
boxmax 0.05 0 0.05
balljoint knee_r {
offset 0 -0.3 0
boxmin -0.05 -0.3 -0.05
boxmax 0.05 0 0.05
rotxlimit -2 0
rotylimit 0 0
rotzlimit 0 0
pose -3 1 2
}
}


The file results in this skeleton.

Earlier, the project was written using old openGL, so I spent time converting it to new openGL by loading a cube obj and using some shaders. From here all I need to do is figure out the various methods for inverse kinematics.

For the final I want to get an inverse kinematic system working in two ways. Analytically, for a two joint system and numerically for a 4 joint system. I also want to animate the joints reaching their appropriate positions, so I am also planning on adding either a simple lerp or rotational velocity to smoothly move the joints into position.

I want to import the Oculus and Touch controllers and be able to specify target points in 3d space that way. If there's time, I want to have a simple sword fighting system, where it will attempt to block your attacks.