// Converts given |position| and |rotation| from Unity space to audio space. private static void ConvertAudioTransformFromUnity(ref Vector3 position, ref Quaternion rotation) { transformMatrix = Pose3D.FlipHandedness(Matrix4x4.TRS(position, rotation, Vector3.one)); position = transformMatrix.GetColumn(3); rotation = Quaternion.LookRotation(transformMatrix.GetColumn(2), transformMatrix.GetColumn(1)); }
public Matrix4x4 ToMatrix4x4() { Matrix4x4 mat4 = (Matrix4x4)Marshal.PtrToStructure(valuePtr, typeof(Matrix4x4)); // Transpose the matrix from row-major (GVR) to column-major (Unity), // and change from LHS to RHS coordinates. return(Pose3D.FlipHandedness(mat4.transpose)); }
public void Show(Matrix4x4 userMatrix, bool useRecommended, float distance, Matrix4x4 model) { #if UNITY_ANDROID && !UNITY_EDITOR currentDistance = distance; #endif // UNITY_ANDROID && !UNITY_EDITOR if (useRecommended) { worldMatrix = getRecommendedMatrix(distance); } else { // Convert to GVR coordinates. worldMatrix = Pose3D.FlipHandedness(userMatrix).transpose; } Matrix4x4 matToSet = worldMatrix * model.transpose; IntPtr mat_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(matToSet)); Marshal.StructureToPtr(matToSet, mat_ptr, true); gvr_keyboard_set_world_from_keyboard_matrix(keyboard_context, mat_ptr); gvr_keyboard_show(keyboard_context); }