private Quaternion?GetRotation(MRWSAInput.InteractionSourceState?state, MRWSAInput.InteractionSourceNode node)
        {
            if (state == null || !state.HasValue)
            {
                return(null);
            }

            Quaternion?rotation = null;

            Quaternion rot = Quaternion.identity;

#if UNITY_5
            bool succeeded = false;
            if (node == MRWSAInput.InteractionSourceNode.Grip)
            {
                succeeded = state.Value.sourcePose.TryGetRotation(out rot);
            }
            else if (node == MRWSAInput.InteractionSourceNode.Pointer)
            {
                succeeded = state.Value.sourcePose.TryGetPointerRotation(out rot);
            }

            if (succeeded)
#else
            if (state.Value.sourcePose.TryGetRotation(out rot, node))
#endif
            {
                rotation = rot;
            }

            return(rotation);
        }
        private Vector3?GetPosition(MRWSAInput.InteractionSourceState?state, MRWSAInput.InteractionSourceNode node)
        {
            if (state == null || !state.HasValue)
            {
                return(null);
            }

            Vector3?position = null;

            Vector3 pos = Vector3.zero;

#if UNITY_5
            bool succeeded = false;
            if (node == MRWSAInput.InteractionSourceNode.Grip)
            {
                succeeded = state.Value.sourcePose.TryGetPosition(out pos);
            }
            else if (node == MRWSAInput.InteractionSourceNode.Pointer)
            {
                succeeded = state.Value.sourcePose.TryGetPointerPosition(out pos);
            }

            if (succeeded)
#else
            if (state.Value.sourcePose.TryGetPosition(out pos, node))
#endif
            {
                position = pos;
            }

            return(position);
        }
        public Quaternion GetRotationDelta(MRWSAInput.InteractionSourceHandedness handedness, MRWSAInput.InteractionSourceNode node)
        {
            var state     = GetState(handedness, false);
            var lastState = GetState(handedness, true);

            var rotation     = GetRotation(state, node);
            var lastRotation = GetRotation(lastState, node);

            Quaternion delta = Quaternion.identity;

            if (rotation.HasValue && lastRotation.HasValue)
            {
                delta = rotation.Value * Quaternion.Inverse(lastRotation.Value);
            }

            return(delta);
        }
        // rotation
        public Quaternion?GetRotation(MRWSAInput.InteractionSourceHandedness handedness, MRWSAInput.InteractionSourceNode node, bool getPreviousValue = false)
        {
            var state = GetState(handedness, getPreviousValue);

            return(GetRotation(state, node));
        }
        public Vector3 GetPositionDelta(MRWSAInput.InteractionSourceHandedness handedness, MRWSAInput.InteractionSourceNode node)
        {
            var state     = GetState(handedness, false);
            var lastState = GetState(handedness, true);

            var position     = GetPosition(state, node);
            var lastPosition = GetPosition(lastState, node);

            Vector3 delta = Vector3.zero;

            if (position.HasValue && lastPosition.HasValue)
            {
                delta = position.Value - lastPosition.Value;
            }

            return(delta);
        }