Hello and welcome!
We have worked on a Kinect project for a client, so we have bit of experience using Kinect. I have read several requests by now about using Kinect to animate a character in real-time - and I am interested in it myself. (I do not not need it for a specific project, but I like the challenge. ;-)
I hope to find the time to create a sample for this (but in 2011 there is not enough time left).
Here are some general thoughts:
Input data:
Joint positions (delivered by Kinect)
Joint contraints (defined manually)
Character skeleton (defined manually)
Output data:
The bone orientations for the skeleton (= SkeletonPose in DR terms), obeying the joint constraints.
Notes:
We could also control the position of the root bone using the Kinect data, which is a simpler task and I will ignore this for now.
In general, the Kinect input should always be validated and very bad input data should be filtered (e.g. impossible positions of limbs or sudden changes in the input data.)
I haven't searched the web, but we have internally discussed a few approaches.
Approach A: Manual mapping of bone orientations.
The character skeleton should have the same (or a very similar) bone hierarchy as the Kinect skeleton. (You can use the SkeletonMapper later to map the pose to different skeletons.)
Then for each bone:
Compute the direction vector of the bind pose of the bone using the start and end joints.
Also compute the direction vector using the kinect joint positions.
Create a rotation that rotates the bone from the two direction vectors (using QuaternionF.Create()).
Apply this orientation to the bone (using SkeletonHelper.RotateBoneAbsolute).
For the constraints:
Manually check if each bone orientation is in an allowed range. If necessary reduce the bone rotation before applying.
Or to get a smoother solution: After you have the unconstrained skeleton pose, iterate over all bones of the skeleton and if a bone rotation is invalid, correct the rotation by rotating the child bone AND the parent bone a bit. (Use weight factor to rotate parent bones and large bones less). Do this several times for the all skeleton and hope that it converges.
Approach B: Using IK-Solvers
Use only specific joint positions from the Kinect data (e.g. hand, head, feet) and use the IKSolvers to let the skeleton reach for those posititions. Some IKSolver support limits (using delegate functions in which you apply a manual correction).
Approach C: Using Radoll to solve contraints
Compute an unconstrained skeleton pose using one of the above methods.
Create a Ragdoll (including joint limits).
Use ragdoll motors to drive ragdoll to the unconstrained skeleton pose. The contraint solver in the physics simulation will take care of the constraints.
Then use the ragdoll to update the final skeleton (using Ragdoll.UpdateSkeletonFromBodies).
Approach D: Ragdoll with position contraints (The "Marionette" Approach)
Create a Ragdoll (including joint limits).
Add additional physics contraints (e.g. soft BallJoints) that pull important body parts to the Kinect joint positions.
Then use the ragdoll to update the final skeleton (using Ragdoll.UpdateSkeletonFromBodies).
Those are just some ideas we have been throwing around. I am sure there are other ideas out there.