# Bone Of Hand Rotation Problem

Hi, i am trying to rotate a bone but its not working like i imagined. So after long time without any clue. i came for help hahaha…
I try to control a hand model, I took the spatial coordinates of the four joints of each finger, and calculated the vector of the three bones on the finger. For the convenience of expression, I called them vector1, vector2, and vector3, which represent the first phalanx and the second. Root phalanx, third phalanx, I use vector1 and vector(0, 1, 0) to get the first quaternion and use it to rotate the first phalanx, use vector1 and vector2 to get the second quaternion and use Rotating the second phalanx, using vector2 and vector3 to get the third quaternion and rotating the third phalanx, but the result is terrible.
Will appreciate if some one can point me to correct implementation.

It’s kind of impossible to help really without seeing what you did and how it turned out.

Else it’s like trying to guess the length of a piece of string you’re holding in your hand.

This introductory presentation provides a high level overview of some of the concepts behind using chained rotations within a hierarchy, and the modelling of constraints:
Kinematics and Orientations (ppt as online pdf)

This does not cover much on implementation, but that is likely going to vary some anyway, depending on the specific use case.

1 Like

I have been trying for days to manipulate a hand model using information from a Kinect device.For example, if Bone A is a parent of Bone B, which is a parent of Bone C, and Bone C is a parent of Bone D, Bone A and Bone B are stationary, I got the vectors of Bone C and Bone D in space through kinect,however I cannot figure out how I can control Bone C and Bone D. Can you point me in the right direction for this? Clarification of the meaning of localRotation, worldBindInverseRotation, setUserTransform and modelSpaceRotation will also be useful as I am struggling to work out what they represent.

A direction vector is not sufficient to define a 3-D rotation. The direction vector has only 2 degrees of freedom, while a 3-D rotation requires 3 degrees of freedom.

What I want to do is make the hand model which has got a skeleton respond to finger movements captured by a kinect device.But I don’t know how to rotate a bone that has a parent，Could you please give me some advice? I have been puzzled by this problem for many days.

I assume you’ve using old-style (JME 3.2.4) bone animation and you’ve found the `Bone` you want to rotate (in the `Skeleton`).

1. override canned animations by enabling user control: `bone.setUserControl(true);`
2. set the desired local rotation: `bone.setLocalRotation(rotation);`

For a bone with a parent, local rotations are defined relative to the parent bone’s coordinate system.

But how can I get the parameter ‘rotation’, is it the quaternion between the parent bone vector and the child bone vector?

No. A bone’s position in space isn’t defined by a mere vector. Each bone has its own coordinate system: location, orientation, and scale.

I think the `Quaternion` you want is one that transforms the orientation of the parent bone to the orientation of the child.

I am new to jme3, so I am not clear about these concepts…I would appreciate it if you can show me code that how to get the ‘rotation’.

Or just tell me what to read and where I can find the tutorial.

I’ve never worked with a Kinect and don’t know what data it provides, so I can’t write your code for you.

I’m not aware of any tutorial on interfacing a Kinect with JME.

However …

A couple years ago, I dove deep into JME’s source code to figure out how bone animation works. I created a library for animation editing and retargeting. If I wanted to use a Kinect to control a 3-D model of a hand, I would start from that library:

View Page - jMonkeyEngine - Store

More particularly, I would start by studying the `Pose` class, which tries to encapsulate the instantaneous transforms of all the bones in a 3-D model:

Wes/Pose.java at for_jME3.2 · stephengold/Wes · GitHub

2 Likes

Thanks for your sharing.

2 Likes

I am sorry, I read the code you share to me, but I still do not know how to rotate a bone…If I had the time to take a closer look at your code, I’m sure I’d have a lot to gain, but the time left for me to develop the project doesn’t allow me to…So I can only ask for your help again. Sorry for taking up so much of your time.
The data that kinect can provide is the coordinates of the joint in space, Assume that there are three bones A - > B → C → D, the parent of A is B, B is the parent of C, C is the parent of D, obtained through access to the joint coordinates to further get A B C D in the space vector, assume they are vectorA, vectorB, vectorC and vectorD. And vectorA remains the same, how do I rotate B C D to keep the model in jme consistent with the bones in real space?

If you have time to answer my question, you just need to tell me how to get the quaternion that rotates the bone from vectorA, vectorB, vectorC and vectorD.

You can’t get where you want to go without inverse kinematics to ‘guess’ at what the rotations might be to make a vector point in a certain direction.

A direction vector is not enough to construct a rotation because it lacks information. Imagine a line in space… it can rotate freely around itself. So what axis rotation should a finger have? Depends on lots of factors.

2 Likes

I thought about this more.

For some bones, rotations around the long axis don’t matter because the bone has rotational symmetry around that axis. (In the OP’s case, that would mean no surface features such as fingernails.)

If:

• you don’t care about rotation around the long axis,
• you want to preserve existing scaling on the other 2 axes, and
• you want to preserve existing translation,

then then it’s usually possible to determine a `Transform` that transforms a specified location vector to a specified point on the long axis.