Page 1 of 1

Strange orientation of bones when applying quaternion

Posted: Fri Jan 16, 2015 1:24 pm
by Elenthidir
Hi
I am working with quaternions and bones.
When applying a quaternion to sinbad bones, I am encountering a strange behaviour. Here is an image of my problem:

Image

On the left side, you can see the kinect skeleton image.

It seems like the bones are rotated more than I expecting... Therefore I got this skinning problems. It looks like the arm is rotate around 360°+n. The quaternions are directly from the KinectV2 and are absolute in the KinectCameraSpace. The only difference between the kinect and ogre coordinate systems are, that the kinect is using a left handed and ogre a right handed system.

Here is the code of a method used below

Code: Select all

		static Ogre::Quaternion kinectOrientationToOgreQuaternion(Vector4* orientation)
		{
			return Ogre::Quaternion(orientation->w, orientation->x, orientation->y, orientation->z);
		}
What I am doing in general:

For the humerus.L:
- Get the orientation (Quaternion) of the right elbow joint (The elbow holds the orienttion of the shoulder in kinect data, so I will use this, and the right elbow as I want to use sinbad to work like a mirror, not a 1:1 copy of myself)

Code: Select all

	KinectHelper::BONE humerusL;
	humerusL.position = KinectHelper::kinectPositionToOgreVector(&positions[KinectHelper::getOpponentJoint(JointType_ElbowLeft)].Position);
	humerusL.orientation = KinectHelper::kinectOrientationToOgreQuaternion(&orientations[KinectHelper::getOpponentJoint(JointType_ElbowLeft)].Orientation);
	KinectHelper::convertCoordinateSystem(&humerusL.orientation);
	bones.insert(std::pair<KinectHelper::BONES, KinectHelper::BONE>(KinectHelper::BONES::HumerusL, humerusL));
- As I want a Mirror, I need to convert the coordinate systems. This is done by this short code

Code: Select all

		static void convertCoordinateSystem(Ogre::Quaternion* quat)
		{
			quat->w =  -quat->w;
			quat->x =  quat->x;
			quat->y =  quat->y;
			quat->z =  -quat->z;
		}
- Last step is to apply the quaternion to the bone. As Ogre uses an hierachical structure, I will multiply the orientation from the kinect with the inverse of the parents bone orientation.

Code: Select all

	bone = playerEntity->getSkeleton()->getBone("Humerus.L");
	orientation = bone->getParent()->_getFullTransform().extractQuaternion().Inverse() * skeleton->getBoneByName(KinectHelper::BONES::HumerusL).orientation;	
	bone->setOrientation(orientation);
currently I am only processing the arms (humerus and ulna). They are following my arms in front of the kinect perfectly! When I am moving the arm up, the correct arm of sinbad is doing the same, but there is this little skinning problem.

Can someone explain to me what is happening and maybe how I can solve this? I assume that it is possible to move a bone without this strange deformation of the skin.

Re: Strange orientation of bones when applying quaternion

Posted: Tue Jan 20, 2015 2:22 pm
by Elenthidir
It seems like there are other guys who are having the same problem. See this link: https://social.msdn.microsoft.com/Forum ... inectv2sdk