The rotation coordinates are different depending on the hand that grabbed it

Currently, in the manipulation sample, when using glasses, the deviceRotation of the right hand and the left hand appear to be different.
I am working with Polyspatial 0.7.1.
Please advise.

Hi there! This is the expected behavior from the platform. We have an update to this sample coming down the pipe which will maintain the rotation of the grabbed object so it doesn’t “snap” to the hand rotation, which should help demonstrate how to deal with this discrepancy between hands. In short, we capture the rotation offset at the moment you grab it, and apply that in addition to the deviceRotation.

The gist of it is to store the offset from the object you are manipulating (piece, in this example) to the input pose, and then re-apply that offset as the pose changes to track the user’s hand movement. To compute the offset:

var pieceTransform = piece.transform;
var interactionPosition = primaryTouchData.interactionPosition;
var inverseDeviceRotation = Quaternion.Inverse(primaryTouchData.deviceRotation);
m_RotationOffset = inverseDeviceRotation * pieceTransform.rotation;
m_PositionOffset = inverseDeviceRotation * (pieceTransform.position - interactionPosition);

And then to apply it during move events:

var deviceRotation = primaryTouchData.deviceRotation;
var rotation = deviceRotation * m_RotationOffset;
var position = primaryTouchData.interactionPosition + deviceRotation * m_PositionOffset;
m_CurrentSelection.transform.SetPositionAndRotation(position, rotation);

As I said, our next version will update the manipulation sample to work this way. When you grab one of the cubes, its rotation stays exactly the way it was until you rotate your hand.

Hope this helps. Good luck!

2 Likes

Thanks for the advice. I am expecting an update.
I will try it on my device.

Following your advice, I built it for the device and checked it.
After much trial and error, I was able to confirm that it works correctly by saving the offset when Phase is in Begin state.
Thank you so much for your help.