private void _HandleRecenterEvent(ref HeadsetState state, gvr_recenter_event_data eventData) { state.recenterEventType = (GvrRecenterEventType)eventData.recenter_event_type; state.recenterEventFlags = eventData.recenter_event_flags; Matrix4x4 gvrMatrix = GvrMathHelpers.ConvertFloatArrayToMatrix(eventData.pose_transform); GvrMathHelpers.GvrMatrixToUnitySpace( gvrMatrix, out state.recenteredPosition, out state.recenteredRotation); }
private void _HandleRecenterEvent(ref HeadsetState state, gvr_recenter_event_data eventData) { state.recenterEventType = (GvrRecenterEventType)eventData.recenter_event_type; state.recenterEventFlags = eventData.recenter_event_flags; Matrix4x4 poseTransform = MATRIX4X4_IDENTITY; float[] poseRaw = eventData.pose_transform; for (int i = 0; i < 4; i++) { int j = i * 4; Vector4 row = new Vector4(poseRaw[j], poseRaw[j + 1], poseRaw[j + 2], poseRaw[j + 3]); poseTransform.SetRow(i, row); } // Invert the matrix to go from row-major (GVR) to column-major (Unity), // and change from LHS to RHS coordinates. transientRecenteredPose3d.SetRightHanded(poseTransform.transpose); state.recenteredPosition = transientRecenteredPose3d.Position; state.recenteredRotation = transientRecenteredPose3d.Orientation; }