public static void GetFramePoseData(ref FramePoseData outData) { GetFramePoseDataRaw(ref outData); foreach (var pose in outData.eyePoses) { makeIdentityIfZeroMatrix(pose.value); } foreach (var view in outData.views) { makeIdentityIfZeroMatrix(view.invViewMatrix); makeIdentityIfZeroMatrix(view.projectionMatrix); } }
public static void GetFramePoseData(ref FramePoseData outData) { IntPtr pNativeData = m_FramePoseNativeBuffer; GetFramePoseDataRaw(pNativeData); // The actual functionality: Fill out the native FramePoseData for (int viewI = 0; viewI < 4; ++viewI) { ViewInfo vi = outData.views[viewI]; Marshal.Copy(pNativeData, vi.projectionMatrix, 0, 16); pNativeData = (IntPtr)(pNativeData.ToInt64() + 16 * 8); Marshal.Copy(pNativeData, vi.invViewMatrix, 0, 16); pNativeData = (IntPtr)(pNativeData.ToInt64() + 16 * 8); vi.preferredWidth = Marshal.ReadInt32(pNativeData); pNativeData = (IntPtr)(pNativeData.ToInt64() + 4); vi.preferredHeight = Marshal.ReadInt32(pNativeData); pNativeData = (IntPtr)(pNativeData.ToInt64() + 4); vi.enabled = Marshal.ReadInt32(pNativeData); pNativeData = (IntPtr)(pNativeData.ToInt64() + 4); vi.reserved = Marshal.ReadInt32(pNativeData); pNativeData = (IntPtr)(pNativeData.ToInt64() + 4); outData.views[viewI] = vi; } for (int eyeI = 0; eyeI < 3; ++eyeI) { Marshal.Copy(pNativeData, outData.eyePoses[eyeI].value, 0, 16); pNativeData = (IntPtr)(pNativeData.ToInt64() + 16 * 8); } foreach (var pose in outData.eyePoses) { makeIdentityIfZeroMatrix(pose.value); } foreach (var view in outData.views) { makeIdentityIfZeroMatrix(view.invViewMatrix); makeIdentityIfZeroMatrix(view.projectionMatrix); } }
// Get the frame info and view poses atomically (guaranteed to all be from the same frame) [DllImport("VarjoUnity", EntryPoint = "GetFramePoseData")] private static extern void GetFramePoseDataRaw(ref FramePoseData outData);