Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5456 lines
141 KiB

  1. /************************************************************************************
  2. Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  3. Licensed under the Oculus Utilities SDK License Version 1.31 (the "License"); you may not use
  4. the Utilities SDK except in compliance with the License, which is provided at the time of installation
  5. or download, or which otherwise accompanies this software in either electronic or hard copy form.
  6. You may obtain a copy of the License at
  7. https://developer.oculus.com/licenses/utilities-1.31
  8. Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
  9. under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  10. ANY KIND, either express or implied. See the License for the specific language governing
  11. permissions and limitations under the License.
  12. ************************************************************************************/
  13. #if USING_XR_MANAGEMENT && USING_XR_SDK_OCULUS
  14. #define USING_XR_SDK
  15. #endif
  16. #if !(UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || (UNITY_ANDROID && !UNITY_EDITOR))
  17. #define OVRPLUGIN_UNSUPPORTED_PLATFORM
  18. #endif
  19. #if UNITY_ANDROID && !UNITY_EDITOR
  20. #define OVRPLUGIN_INCLUDE_MRC_ANDROID
  21. #endif
  22. using System;
  23. using System.Runtime.InteropServices;
  24. using UnityEngine;
  25. // Internal C# wrapper for OVRPlugin.
  26. public static class OVRPlugin
  27. {
  28. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  29. public const bool isSupportedPlatform = false;
  30. #else
  31. public const bool isSupportedPlatform = true;
  32. #endif
  33. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  34. public static readonly System.Version wrapperVersion = _versionZero;
  35. #else
  36. public static readonly System.Version wrapperVersion = OVRP_1_47_0.version;
  37. #endif
  38. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  39. private static System.Version _version;
  40. #endif
  41. public static System.Version version
  42. {
  43. get {
  44. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  45. Debug.LogWarning("Platform is not currently supported by OVRPlugin");
  46. return _versionZero;
  47. #else
  48. if (_version == null)
  49. {
  50. try
  51. {
  52. string pluginVersion = OVRP_1_1_0.ovrp_GetVersion();
  53. if (pluginVersion != null)
  54. {
  55. // Truncate unsupported trailing version info for System.Version. Original string is returned if not present.
  56. pluginVersion = pluginVersion.Split('-')[0];
  57. _version = new System.Version(pluginVersion);
  58. }
  59. else
  60. {
  61. _version = _versionZero;
  62. }
  63. }
  64. catch
  65. {
  66. _version = _versionZero;
  67. }
  68. // Unity 5.1.1f3-p3 have OVRPlugin version "0.5.0", which isn't accurate.
  69. if (_version == OVRP_0_5_0.version)
  70. _version = OVRP_0_1_0.version;
  71. if (_version > _versionZero && _version < OVRP_1_3_0.version)
  72. throw new PlatformNotSupportedException("Oculus Utilities version " + wrapperVersion + " is too new for OVRPlugin version " + _version.ToString() + ". Update to the latest version of Unity.");
  73. }
  74. return _version;
  75. #endif
  76. }
  77. }
  78. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  79. private static System.Version _nativeSDKVersion;
  80. #endif
  81. public static System.Version nativeSDKVersion
  82. {
  83. get {
  84. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  85. return _versionZero;
  86. #else
  87. if (_nativeSDKVersion == null)
  88. {
  89. try
  90. {
  91. string sdkVersion = string.Empty;
  92. if (version >= OVRP_1_1_0.version)
  93. sdkVersion = OVRP_1_1_0.ovrp_GetNativeSDKVersion();
  94. else
  95. sdkVersion = _versionZero.ToString();
  96. if (sdkVersion != null)
  97. {
  98. // Truncate unsupported trailing version info for System.Version. Original string is returned if not present.
  99. sdkVersion = sdkVersion.Split('-')[0];
  100. _nativeSDKVersion = new System.Version(sdkVersion);
  101. }
  102. else
  103. {
  104. _nativeSDKVersion = _versionZero;
  105. }
  106. }
  107. catch
  108. {
  109. _nativeSDKVersion = _versionZero;
  110. }
  111. }
  112. return _nativeSDKVersion;
  113. #endif
  114. }
  115. }
  116. [StructLayout(LayoutKind.Sequential)]
  117. private class GUID
  118. {
  119. public int a;
  120. public short b;
  121. public short c;
  122. public byte d0;
  123. public byte d1;
  124. public byte d2;
  125. public byte d3;
  126. public byte d4;
  127. public byte d5;
  128. public byte d6;
  129. public byte d7;
  130. }
  131. public enum Bool
  132. {
  133. False = 0,
  134. True
  135. }
  136. public enum Result
  137. {
  138. /// Success
  139. Success = 0,
  140. /// Failure
  141. Failure = -1000,
  142. Failure_InvalidParameter = -1001,
  143. Failure_NotInitialized = -1002,
  144. Failure_InvalidOperation = -1003,
  145. Failure_Unsupported = -1004,
  146. Failure_NotYetImplemented = -1005,
  147. Failure_OperationFailed = -1006,
  148. Failure_InsufficientSize = -1007,
  149. }
  150. public enum CameraStatus
  151. {
  152. CameraStatus_None,
  153. CameraStatus_Connected,
  154. CameraStatus_Calibrating,
  155. CameraStatus_CalibrationFailed,
  156. CameraStatus_Calibrated,
  157. CameraStatus_EnumSize = 0x7fffffff
  158. }
  159. public enum Eye
  160. {
  161. None = -1,
  162. Left = 0,
  163. Right = 1,
  164. Count = 2
  165. }
  166. public enum Tracker
  167. {
  168. None = -1,
  169. Zero = 0,
  170. One = 1,
  171. Two = 2,
  172. Three = 3,
  173. Count,
  174. }
  175. public enum Node
  176. {
  177. None = -1,
  178. EyeLeft = 0,
  179. EyeRight = 1,
  180. EyeCenter = 2,
  181. HandLeft = 3,
  182. HandRight = 4,
  183. TrackerZero = 5,
  184. TrackerOne = 6,
  185. TrackerTwo = 7,
  186. TrackerThree = 8,
  187. Head = 9,
  188. DeviceObjectZero = 10,
  189. Count,
  190. }
  191. public enum Controller
  192. {
  193. None = 0,
  194. LTouch = 0x00000001,
  195. RTouch = 0x00000002,
  196. Touch = LTouch | RTouch,
  197. Remote = 0x00000004,
  198. Gamepad = 0x00000010,
  199. LHand = 0x00000020,
  200. RHand = 0x00000040,
  201. Hands = LHand | RHand,
  202. Touchpad = 0x08000000,
  203. LTrackedRemote = 0x01000000,
  204. RTrackedRemote = 0x02000000,
  205. Active = unchecked((int)0x80000000),
  206. All = ~None,
  207. }
  208. public enum Handedness
  209. {
  210. Unsupported = 0,
  211. LeftHanded = 1,
  212. RightHanded = 2,
  213. }
  214. public enum TrackingOrigin
  215. {
  216. EyeLevel = 0,
  217. FloorLevel = 1,
  218. Stage = 2,
  219. Count,
  220. }
  221. public enum RecenterFlags
  222. {
  223. Default = 0,
  224. Controllers = 0x40000000,
  225. IgnoreAll = unchecked((int)0x80000000),
  226. Count,
  227. }
  228. public enum BatteryStatus
  229. {
  230. Charging = 0,
  231. Discharging,
  232. Full,
  233. NotCharging,
  234. Unknown,
  235. }
  236. public enum EyeTextureFormat
  237. {
  238. Default = 0,
  239. R8G8B8A8_sRGB = 0,
  240. R8G8B8A8 = 1,
  241. R16G16B16A16_FP = 2,
  242. R11G11B10_FP = 3,
  243. B8G8R8A8_sRGB = 4,
  244. B8G8R8A8 = 5,
  245. R5G6B5 = 11,
  246. EnumSize = 0x7fffffff
  247. }
  248. public enum PlatformUI
  249. {
  250. None = -1,
  251. ConfirmQuit = 1,
  252. GlobalMenuTutorial, // Deprecated
  253. }
  254. public enum SystemRegion
  255. {
  256. Unspecified = 0,
  257. Japan,
  258. China,
  259. }
  260. public enum SystemHeadset
  261. {
  262. None = 0,
  263. GearVR_R320, // Note4 Innovator
  264. GearVR_R321, // S6 Innovator
  265. GearVR_R322, // Commercial 1
  266. GearVR_R323, // Commercial 2 (USB Type C)
  267. GearVR_R324, // Commercial 3 (USB Type C)
  268. GearVR_R325, // Commercial 4 (USB Type C)
  269. Oculus_Go,
  270. Oculus_Quest,
  271. Rift_DK1 = 0x1000,
  272. Rift_DK2,
  273. Rift_CV1,
  274. Rift_CB,
  275. Rift_S,
  276. }
  277. public enum OverlayShape
  278. {
  279. Quad = 0,
  280. Cylinder = 1,
  281. Cubemap = 2,
  282. OffcenterCubemap = 4,
  283. Equirect = 5,
  284. }
  285. public enum Step
  286. {
  287. Render = -1,
  288. Physics = 0,
  289. }
  290. public enum CameraDevice
  291. {
  292. None = 0,
  293. WebCamera0 = 100,
  294. WebCamera1 = 101,
  295. ZEDCamera = 300,
  296. }
  297. public enum CameraDeviceDepthSensingMode
  298. {
  299. Standard = 0,
  300. Fill = 1,
  301. }
  302. public enum CameraDeviceDepthQuality
  303. {
  304. Low = 0,
  305. Medium = 1,
  306. High = 2,
  307. }
  308. public enum FixedFoveatedRenderingLevel
  309. {
  310. Off = 0,
  311. Low = 1,
  312. Medium = 2,
  313. High = 3,
  314. // High foveation setting with more detail toward the bottom of the view and more foveation near the top (Same as High on Oculus Go)
  315. HighTop = 4,
  316. EnumSize = 0x7FFFFFFF
  317. }
  318. [Obsolete("Please use FixedFoveatedRenderingLevel instead", false)]
  319. public enum TiledMultiResLevel
  320. {
  321. Off = 0,
  322. LMSLow = FixedFoveatedRenderingLevel.Low,
  323. LMSMedium = FixedFoveatedRenderingLevel.Medium,
  324. LMSHigh = FixedFoveatedRenderingLevel.High,
  325. // High foveation setting with more detail toward the bottom of the view and more foveation near the top (Same as High on Oculus Go)
  326. LMSHighTop = FixedFoveatedRenderingLevel.HighTop,
  327. EnumSize = 0x7FFFFFFF
  328. }
  329. public enum PerfMetrics
  330. {
  331. App_CpuTime_Float = 0,
  332. App_GpuTime_Float = 1,
  333. Compositor_CpuTime_Float = 3,
  334. Compositor_GpuTime_Float = 4,
  335. Compositor_DroppedFrameCount_Int = 5,
  336. System_GpuUtilPercentage_Float = 7,
  337. System_CpuUtilAveragePercentage_Float = 8,
  338. System_CpuUtilWorstPercentage_Float = 9,
  339. // 1.32.0
  340. Device_CpuClockFrequencyInMHz_Float = 10,
  341. Device_GpuClockFrequencyInMHz_Float = 11,
  342. Device_CpuClockLevel_Int = 12,
  343. Device_GpuClockLevel_Int = 13,
  344. Count,
  345. EnumSize = 0x7FFFFFFF
  346. }
  347. [StructLayout(LayoutKind.Sequential)]
  348. public struct CameraDeviceIntrinsicsParameters
  349. {
  350. float fx; /* Focal length in pixels along x axis. */
  351. float fy; /* Focal length in pixels along y axis. */
  352. float cx; /* Optical center along x axis, defined in pixels (usually close to width/2). */
  353. float cy; /* Optical center along y axis, defined in pixels (usually close to height/2). */
  354. double disto0; /* Distortion factor : [ k1, k2, p1, p2, k3 ]. Radial (k1,k2,k3) and Tangential (p1,p2) distortion.*/
  355. double disto1;
  356. double disto2;
  357. double disto3;
  358. double disto4;
  359. float v_fov; /* Vertical field of view after stereo rectification, in degrees. */
  360. float h_fov; /* Horizontal field of view after stereo rectification, in degrees.*/
  361. float d_fov; /* Diagonal field of view after stereo rectification, in degrees.*/
  362. int w; /* Resolution width */
  363. int h; /* Resolution height */
  364. }
  365. private const int OverlayShapeFlagShift = 4;
  366. private enum OverlayFlag
  367. {
  368. None = unchecked((int)0x00000000),
  369. OnTop = unchecked((int)0x00000001),
  370. HeadLocked = unchecked((int)0x00000002),
  371. NoDepth = unchecked((int)0x00000004),
  372. ExpensiveSuperSample = unchecked((int)0x00000008),
  373. // Using the 5-8 bits for shapes, total 16 potential shapes can be supported 0x000000[0]0 -> 0x000000[F]0
  374. ShapeFlag_Quad = unchecked((int)OverlayShape.Quad << OverlayShapeFlagShift),
  375. ShapeFlag_Cylinder = unchecked((int)OverlayShape.Cylinder << OverlayShapeFlagShift),
  376. ShapeFlag_Cubemap = unchecked((int)OverlayShape.Cubemap << OverlayShapeFlagShift),
  377. ShapeFlag_OffcenterCubemap = unchecked((int)OverlayShape.OffcenterCubemap << OverlayShapeFlagShift),
  378. ShapeFlagRangeMask = unchecked((int)0xF << OverlayShapeFlagShift),
  379. Hidden = unchecked((int)0x000000200),
  380. }
  381. [StructLayout(LayoutKind.Sequential)]
  382. public struct Vector2f
  383. {
  384. public float x;
  385. public float y;
  386. }
  387. [StructLayout(LayoutKind.Sequential)]
  388. public struct Vector3f
  389. {
  390. public float x;
  391. public float y;
  392. public float z;
  393. public static readonly Vector3f zero = new Vector3f { x = 0.0f, y = 0.0f, z = 0.0f };
  394. public override string ToString()
  395. {
  396. return string.Format("{0}, {1}, {2}", x, y, z);
  397. }
  398. }
  399. [StructLayout(LayoutKind.Sequential)]
  400. public struct Vector4f
  401. {
  402. public float x;
  403. public float y;
  404. public float z;
  405. public float w;
  406. public static readonly Vector4f zero = new Vector4f { x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f };
  407. public override string ToString()
  408. {
  409. return string.Format("{0}, {1}, {2}, {3}", x, y, z, w);
  410. }
  411. }
  412. [StructLayout(LayoutKind.Sequential)]
  413. public struct Vector4s
  414. {
  415. public short x;
  416. public short y;
  417. public short z;
  418. public short w;
  419. public static readonly Vector4s zero = new Vector4s { x = 0, y = 0, z = 0, w = 0 };
  420. public override string ToString()
  421. {
  422. return string.Format("{0}, {1}, {2}, {3}", x, y, z, w);
  423. }
  424. }
  425. [StructLayout(LayoutKind.Sequential)]
  426. public struct Quatf
  427. {
  428. public float x;
  429. public float y;
  430. public float z;
  431. public float w;
  432. public static readonly Quatf identity = new Quatf { x = 0.0f, y = 0.0f, z = 0.0f, w = 1.0f };
  433. public override string ToString()
  434. {
  435. return string.Format("{0}, {1}, {2}, {3}", x, y, z, w);
  436. }
  437. }
  438. [StructLayout(LayoutKind.Sequential)]
  439. public struct Posef
  440. {
  441. public Quatf Orientation;
  442. public Vector3f Position;
  443. public static readonly Posef identity = new Posef { Orientation = Quatf.identity, Position = Vector3f.zero };
  444. public override string ToString()
  445. {
  446. return string.Format("Position ({0}), Orientation({1})", Position, Orientation);
  447. }
  448. }
  449. [StructLayout(LayoutKind.Sequential)]
  450. public struct TextureRectMatrixf
  451. {
  452. public Rect leftRect;
  453. public Rect rightRect;
  454. public Vector4 leftScaleBias;
  455. public Vector4 rightScaleBias;
  456. public static readonly TextureRectMatrixf zero = new TextureRectMatrixf { leftRect = new Rect(0, 0, 1, 1), rightRect = new Rect(0, 0, 1, 1), leftScaleBias = new Vector4(1, 1, 0, 0), rightScaleBias = new Vector4(1, 1, 0, 0) };
  457. public override string ToString()
  458. {
  459. return string.Format("Rect Left ({0}), Rect Right({1}), Scale Bias Left ({2}), Scale Bias Right({3})", leftRect, rightRect, leftScaleBias, rightScaleBias);
  460. }
  461. }
  462. [StructLayout(LayoutKind.Sequential)]
  463. public struct PoseStatef
  464. {
  465. public Posef Pose;
  466. public Vector3f Velocity;
  467. public Vector3f Acceleration;
  468. public Vector3f AngularVelocity;
  469. public Vector3f AngularAcceleration;
  470. public double Time;
  471. public static readonly PoseStatef identity = new PoseStatef
  472. {
  473. Pose = Posef.identity,
  474. Velocity = Vector3f.zero,
  475. Acceleration = Vector3f.zero,
  476. AngularVelocity = Vector3f.zero,
  477. AngularAcceleration = Vector3f.zero
  478. };
  479. }
  480. [StructLayout(LayoutKind.Sequential)]
  481. public struct ControllerState4
  482. {
  483. public uint ConnectedControllers;
  484. public uint Buttons;
  485. public uint Touches;
  486. public uint NearTouches;
  487. public float LIndexTrigger;
  488. public float RIndexTrigger;
  489. public float LHandTrigger;
  490. public float RHandTrigger;
  491. public Vector2f LThumbstick;
  492. public Vector2f RThumbstick;
  493. public Vector2f LTouchpad;
  494. public Vector2f RTouchpad;
  495. public byte LBatteryPercentRemaining;
  496. public byte RBatteryPercentRemaining;
  497. public byte LRecenterCount;
  498. public byte RRecenterCount;
  499. public byte Reserved_27;
  500. public byte Reserved_26;
  501. public byte Reserved_25;
  502. public byte Reserved_24;
  503. public byte Reserved_23;
  504. public byte Reserved_22;
  505. public byte Reserved_21;
  506. public byte Reserved_20;
  507. public byte Reserved_19;
  508. public byte Reserved_18;
  509. public byte Reserved_17;
  510. public byte Reserved_16;
  511. public byte Reserved_15;
  512. public byte Reserved_14;
  513. public byte Reserved_13;
  514. public byte Reserved_12;
  515. public byte Reserved_11;
  516. public byte Reserved_10;
  517. public byte Reserved_09;
  518. public byte Reserved_08;
  519. public byte Reserved_07;
  520. public byte Reserved_06;
  521. public byte Reserved_05;
  522. public byte Reserved_04;
  523. public byte Reserved_03;
  524. public byte Reserved_02;
  525. public byte Reserved_01;
  526. public byte Reserved_00;
  527. public ControllerState4(ControllerState2 cs)
  528. {
  529. ConnectedControllers = cs.ConnectedControllers;
  530. Buttons = cs.Buttons;
  531. Touches = cs.Touches;
  532. NearTouches = cs.NearTouches;
  533. LIndexTrigger = cs.LIndexTrigger;
  534. RIndexTrigger = cs.RIndexTrigger;
  535. LHandTrigger = cs.LHandTrigger;
  536. RHandTrigger = cs.RHandTrigger;
  537. LThumbstick = cs.LThumbstick;
  538. RThumbstick = cs.RThumbstick;
  539. LTouchpad = cs.LTouchpad;
  540. RTouchpad = cs.RTouchpad;
  541. LBatteryPercentRemaining = 0;
  542. RBatteryPercentRemaining = 0;
  543. LRecenterCount = 0;
  544. RRecenterCount = 0;
  545. Reserved_27 = 0;
  546. Reserved_26 = 0;
  547. Reserved_25 = 0;
  548. Reserved_24 = 0;
  549. Reserved_23 = 0;
  550. Reserved_22 = 0;
  551. Reserved_21 = 0;
  552. Reserved_20 = 0;
  553. Reserved_19 = 0;
  554. Reserved_18 = 0;
  555. Reserved_17 = 0;
  556. Reserved_16 = 0;
  557. Reserved_15 = 0;
  558. Reserved_14 = 0;
  559. Reserved_13 = 0;
  560. Reserved_12 = 0;
  561. Reserved_11 = 0;
  562. Reserved_10 = 0;
  563. Reserved_09 = 0;
  564. Reserved_08 = 0;
  565. Reserved_07 = 0;
  566. Reserved_06 = 0;
  567. Reserved_05 = 0;
  568. Reserved_04 = 0;
  569. Reserved_03 = 0;
  570. Reserved_02 = 0;
  571. Reserved_01 = 0;
  572. Reserved_00 = 0;
  573. }
  574. }
  575. [StructLayout(LayoutKind.Sequential)]
  576. public struct ControllerState2
  577. {
  578. public uint ConnectedControllers;
  579. public uint Buttons;
  580. public uint Touches;
  581. public uint NearTouches;
  582. public float LIndexTrigger;
  583. public float RIndexTrigger;
  584. public float LHandTrigger;
  585. public float RHandTrigger;
  586. public Vector2f LThumbstick;
  587. public Vector2f RThumbstick;
  588. public Vector2f LTouchpad;
  589. public Vector2f RTouchpad;
  590. public ControllerState2(ControllerState cs)
  591. {
  592. ConnectedControllers = cs.ConnectedControllers;
  593. Buttons = cs.Buttons;
  594. Touches = cs.Touches;
  595. NearTouches = cs.NearTouches;
  596. LIndexTrigger = cs.LIndexTrigger;
  597. RIndexTrigger = cs.RIndexTrigger;
  598. LHandTrigger = cs.LHandTrigger;
  599. RHandTrigger = cs.RHandTrigger;
  600. LThumbstick = cs.LThumbstick;
  601. RThumbstick = cs.RThumbstick;
  602. LTouchpad = new Vector2f() { x = 0.0f, y = 0.0f };
  603. RTouchpad = new Vector2f() { x = 0.0f, y = 0.0f };
  604. }
  605. }
  606. [StructLayout(LayoutKind.Sequential)]
  607. public struct ControllerState
  608. {
  609. public uint ConnectedControllers;
  610. public uint Buttons;
  611. public uint Touches;
  612. public uint NearTouches;
  613. public float LIndexTrigger;
  614. public float RIndexTrigger;
  615. public float LHandTrigger;
  616. public float RHandTrigger;
  617. public Vector2f LThumbstick;
  618. public Vector2f RThumbstick;
  619. }
  620. [StructLayout(LayoutKind.Sequential)]
  621. public struct HapticsBuffer
  622. {
  623. public IntPtr Samples;
  624. public int SamplesCount;
  625. }
  626. [StructLayout(LayoutKind.Sequential)]
  627. public struct HapticsState
  628. {
  629. public int SamplesAvailable;
  630. public int SamplesQueued;
  631. }
  632. [StructLayout(LayoutKind.Sequential)]
  633. public struct HapticsDesc
  634. {
  635. public int SampleRateHz;
  636. public int SampleSizeInBytes;
  637. public int MinimumSafeSamplesQueued;
  638. public int MinimumBufferSamplesCount;
  639. public int OptimalBufferSamplesCount;
  640. public int MaximumBufferSamplesCount;
  641. }
  642. [StructLayout(LayoutKind.Sequential)]
  643. public struct AppPerfFrameStats
  644. {
  645. public int HmdVsyncIndex;
  646. public int AppFrameIndex;
  647. public int AppDroppedFrameCount;
  648. public float AppMotionToPhotonLatency;
  649. public float AppQueueAheadTime;
  650. public float AppCpuElapsedTime;
  651. public float AppGpuElapsedTime;
  652. public int CompositorFrameIndex;
  653. public int CompositorDroppedFrameCount;
  654. public float CompositorLatency;
  655. public float CompositorCpuElapsedTime;
  656. public float CompositorGpuElapsedTime;
  657. public float CompositorCpuStartToGpuEndElapsedTime;
  658. public float CompositorGpuEndToVsyncElapsedTime;
  659. }
  660. public const int AppPerfFrameStatsMaxCount = 5;
  661. [StructLayout(LayoutKind.Sequential)]
  662. public struct AppPerfStats
  663. {
  664. [MarshalAs(UnmanagedType.ByValArray, SizeConst = AppPerfFrameStatsMaxCount)]
  665. public AppPerfFrameStats[] FrameStats;
  666. public int FrameStatsCount;
  667. public Bool AnyFrameStatsDropped;
  668. public float AdaptiveGpuPerformanceScale;
  669. }
  670. [StructLayout(LayoutKind.Sequential)]
  671. public struct Sizei
  672. {
  673. public int w;
  674. public int h;
  675. public static readonly Sizei zero = new Sizei { w = 0, h = 0 };
  676. }
  677. [StructLayout(LayoutKind.Sequential)]
  678. public struct Sizef
  679. {
  680. public float w;
  681. public float h;
  682. public static readonly Sizef zero = new Sizef { w = 0, h = 0 };
  683. }
  684. [StructLayout(LayoutKind.Sequential)]
  685. public struct Vector2i
  686. {
  687. public int x;
  688. public int y;
  689. }
  690. [StructLayout(LayoutKind.Sequential)]
  691. public struct Recti {
  692. Vector2i Pos;
  693. Sizei Size;
  694. }
  695. [StructLayout(LayoutKind.Sequential)]
  696. public struct Rectf {
  697. Vector2f Pos;
  698. Sizef Size;
  699. }
  700. [StructLayout(LayoutKind.Sequential)]
  701. public struct Frustumf
  702. {
  703. public float zNear;
  704. public float zFar;
  705. public float fovX;
  706. public float fovY;
  707. }
  708. [StructLayout(LayoutKind.Sequential)]
  709. public struct Frustumf2
  710. {
  711. public float zNear;
  712. public float zFar;
  713. public Fovf Fov;
  714. }
  715. public enum BoundaryType
  716. {
  717. OuterBoundary = 0x0001,
  718. PlayArea = 0x0100,
  719. }
  720. [StructLayout(LayoutKind.Sequential)]
  721. public struct BoundaryTestResult
  722. {
  723. public Bool IsTriggering;
  724. public float ClosestDistance;
  725. public Vector3f ClosestPoint;
  726. public Vector3f ClosestPointNormal;
  727. }
  728. [StructLayout(LayoutKind.Sequential)]
  729. public struct BoundaryGeometry
  730. {
  731. public BoundaryType BoundaryType;
  732. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
  733. public Vector3f[] Points;
  734. public int PointsCount;
  735. }
  736. [StructLayout(LayoutKind.Sequential)]
  737. public struct Colorf
  738. {
  739. public float r;
  740. public float g;
  741. public float b;
  742. public float a;
  743. }
  744. [StructLayout(LayoutKind.Sequential)]
  745. public struct Fovf
  746. {
  747. public float UpTan;
  748. public float DownTan;
  749. public float LeftTan;
  750. public float RightTan;
  751. }
  752. [StructLayout(LayoutKind.Sequential)]
  753. public struct CameraIntrinsics
  754. {
  755. public Bool IsValid;
  756. public double LastChangedTimeSeconds;
  757. public Fovf FOVPort;
  758. public float VirtualNearPlaneDistanceMeters;
  759. public float VirtualFarPlaneDistanceMeters;
  760. public Sizei ImageSensorPixelResolution;
  761. }
  762. [StructLayout(LayoutKind.Sequential)]
  763. public struct CameraExtrinsics
  764. {
  765. public Bool IsValid;
  766. public double LastChangedTimeSeconds;
  767. public CameraStatus CameraStatusData;
  768. public Node AttachedToNode;
  769. public Posef RelativePose;
  770. }
  771. public enum LayerLayout
  772. {
  773. Stereo = 0,
  774. Mono = 1,
  775. DoubleWide = 2,
  776. Array = 3,
  777. EnumSize = 0xF
  778. }
  779. public enum LayerFlags
  780. {
  781. Static = (1 << 0),
  782. LoadingScreen = (1 << 1),
  783. SymmetricFov = (1 << 2),
  784. TextureOriginAtBottomLeft = (1 << 3),
  785. ChromaticAberrationCorrection = (1 << 4),
  786. NoAllocation = (1 << 5),
  787. ProtectedContent = (1 << 6),
  788. AndroidSurfaceSwapChain = (1 << 7),
  789. }
  790. [StructLayout(LayoutKind.Sequential)]
  791. public struct LayerDesc
  792. {
  793. public OverlayShape Shape;
  794. public LayerLayout Layout;
  795. public Sizei TextureSize;
  796. public int MipLevels;
  797. public int SampleCount;
  798. public EyeTextureFormat Format;
  799. public int LayerFlags;
  800. //Eye FOV-only members.
  801. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  802. public Fovf[] Fov;
  803. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  804. public Rectf[] VisibleRect;
  805. public Sizei MaxViewportSize;
  806. EyeTextureFormat DepthFormat;
  807. public override string ToString()
  808. {
  809. string delim = ", ";
  810. return Shape.ToString()
  811. + delim + Layout.ToString()
  812. + delim + TextureSize.w.ToString() + "x" + TextureSize.h.ToString()
  813. + delim + MipLevels.ToString()
  814. + delim + SampleCount.ToString()
  815. + delim + Format.ToString()
  816. + delim + LayerFlags.ToString();
  817. }
  818. }
  819. [StructLayout(LayoutKind.Sequential)]
  820. public struct LayerSubmit
  821. {
  822. int LayerId;
  823. int TextureStage;
  824. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  825. Recti[] ViewportRect;
  826. Posef Pose;
  827. int LayerSubmitFlags;
  828. }
  829. public enum TrackingConfidence
  830. {
  831. Low = 0,
  832. High = 0x3f800000,
  833. }
  834. public enum Hand
  835. {
  836. None = -1,
  837. HandLeft = 0,
  838. HandRight = 1,
  839. }
  840. [Flags]
  841. public enum HandStatus
  842. {
  843. HandTracked = (1 << 0), // if this is set the hand pose and bone rotations data is usable
  844. InputStateValid = (1 << 1), // if this is set the pointer pose and pinch data is usable
  845. SystemGestureInProgress = (1 << 6), // if this is set the hand is currently processing a system gesture
  846. }
  847. public enum BoneId
  848. {
  849. Invalid = -1,
  850. Hand_Start = 0,
  851. Hand_WristRoot = Hand_Start + 0, // root frame of the hand, where the wrist is located
  852. Hand_ForearmStub = Hand_Start + 1, // frame for user's forearm
  853. Hand_Thumb0 = Hand_Start + 2, // thumb trapezium bone
  854. Hand_Thumb1 = Hand_Start + 3, // thumb metacarpal bone
  855. Hand_Thumb2 = Hand_Start + 4, // thumb proximal phalange bone
  856. Hand_Thumb3 = Hand_Start + 5, // thumb distal phalange bone
  857. Hand_Index1 = Hand_Start + 6, // index proximal phalange bone
  858. Hand_Index2 = Hand_Start + 7, // index intermediate phalange bone
  859. Hand_Index3 = Hand_Start + 8, // index distal phalange bone
  860. Hand_Middle1 = Hand_Start + 9, // middle proximal phalange bone
  861. Hand_Middle2 = Hand_Start + 10, // middle intermediate phalange bone
  862. Hand_Middle3 = Hand_Start + 11, // middle distal phalange bone
  863. Hand_Ring1 = Hand_Start + 12, // ring proximal phalange bone
  864. Hand_Ring2 = Hand_Start + 13, // ring intermediate phalange bone
  865. Hand_Ring3 = Hand_Start + 14, // ring distal phalange bone
  866. Hand_Pinky0 = Hand_Start + 15, // pinky metacarpal bone
  867. Hand_Pinky1 = Hand_Start + 16, // pinky proximal phalange bone
  868. Hand_Pinky2 = Hand_Start + 17, // pinky intermediate phalange bone
  869. Hand_Pinky3 = Hand_Start + 18, // pinky distal phalange bone
  870. Hand_MaxSkinnable = Hand_Start + 19,
  871. // Bone tips are position only. They are not used for skinning but are useful for hit-testing.
  872. // NOTE: Hand_ThumbTip == Hand_MaxSkinnable since the extended tips need to be contiguous
  873. Hand_ThumbTip = Hand_Start + Hand_MaxSkinnable + 0, // tip of the thumb
  874. Hand_IndexTip = Hand_Start + Hand_MaxSkinnable + 1, // tip of the index finger
  875. Hand_MiddleTip = Hand_Start + Hand_MaxSkinnable + 2, // tip of the middle finger
  876. Hand_RingTip = Hand_Start + Hand_MaxSkinnable + 3, // tip of the ring finger
  877. Hand_PinkyTip = Hand_Start + Hand_MaxSkinnable + 4, // tip of the pinky
  878. Hand_End = Hand_Start + Hand_MaxSkinnable + 5,
  879. // add new bones here
  880. Max = Hand_End + 0,
  881. }
  882. public enum HandFinger
  883. {
  884. Thumb = 0,
  885. Index = 1,
  886. Middle = 2,
  887. Ring = 3,
  888. Pinky = 4,
  889. Max = 5,
  890. }
  891. [Flags]
  892. public enum HandFingerPinch
  893. {
  894. Thumb = (1 << HandFinger.Thumb),
  895. Index = (1 << HandFinger.Index),
  896. Middle = (1 << HandFinger.Middle),
  897. Ring = (1 << HandFinger.Ring),
  898. Pinky = (1 << HandFinger.Pinky),
  899. }
  900. [StructLayout(LayoutKind.Sequential)]
  901. public struct HandState
  902. {
  903. public HandStatus Status;
  904. public Posef RootPose;
  905. public Quatf[] BoneRotations;
  906. public HandFingerPinch Pinches;
  907. public float[] PinchStrength;
  908. public Posef PointerPose;
  909. public float HandScale;
  910. public TrackingConfidence HandConfidence;
  911. public TrackingConfidence[] FingerConfidences;
  912. public double RequestedTimeStamp;
  913. public double SampleTimeStamp;
  914. }
  915. [StructLayout(LayoutKind.Sequential)]
  916. private struct HandStateInternal
  917. {
  918. public HandStatus Status;
  919. public Posef RootPose;
  920. public Quatf BoneRotations_0;
  921. public Quatf BoneRotations_1;
  922. public Quatf BoneRotations_2;
  923. public Quatf BoneRotations_3;
  924. public Quatf BoneRotations_4;
  925. public Quatf BoneRotations_5;
  926. public Quatf BoneRotations_6;
  927. public Quatf BoneRotations_7;
  928. public Quatf BoneRotations_8;
  929. public Quatf BoneRotations_9;
  930. public Quatf BoneRotations_10;
  931. public Quatf BoneRotations_11;
  932. public Quatf BoneRotations_12;
  933. public Quatf BoneRotations_13;
  934. public Quatf BoneRotations_14;
  935. public Quatf BoneRotations_15;
  936. public Quatf BoneRotations_16;
  937. public Quatf BoneRotations_17;
  938. public Quatf BoneRotations_18;
  939. public Quatf BoneRotations_19;
  940. public Quatf BoneRotations_20;
  941. public Quatf BoneRotations_21;
  942. public Quatf BoneRotations_22;
  943. public Quatf BoneRotations_23;
  944. public HandFingerPinch Pinches;
  945. public float PinchStrength_0;
  946. public float PinchStrength_1;
  947. public float PinchStrength_2;
  948. public float PinchStrength_3;
  949. public float PinchStrength_4;
  950. public Posef PointerPose;
  951. public float HandScale;
  952. public TrackingConfidence HandConfidence;
  953. public TrackingConfidence FingerConfidences_0;
  954. public TrackingConfidence FingerConfidences_1;
  955. public TrackingConfidence FingerConfidences_2;
  956. public TrackingConfidence FingerConfidences_3;
  957. public TrackingConfidence FingerConfidences_4;
  958. public double RequestedTimeStamp;
  959. public double SampleTimeStamp;
  960. }
  961. [StructLayout(LayoutKind.Sequential)]
  962. public struct BoneCapsule
  963. {
  964. public short BoneIndex;
  965. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
  966. public Vector3f[] Points;
  967. public float Radius;
  968. }
  969. [StructLayout(LayoutKind.Sequential)]
  970. public struct Bone
  971. {
  972. public BoneId Id;
  973. public short ParentBoneIndex;
  974. public Posef Pose;
  975. }
  976. public enum SkeletonConstants
  977. {
  978. MaxBones = BoneId.Max,
  979. MaxBoneCapsules = 19,
  980. }
  981. public enum SkeletonType
  982. {
  983. None = -1,
  984. HandLeft = 0,
  985. HandRight = 1,
  986. }
  987. [StructLayout(LayoutKind.Sequential)]
  988. public struct Skeleton
  989. {
  990. public SkeletonType Type;
  991. public uint NumBones;
  992. public uint NumBoneCapsules;
  993. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)SkeletonConstants.MaxBones)]
  994. public Bone[] Bones;
  995. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)SkeletonConstants.MaxBoneCapsules)]
  996. public BoneCapsule[] BoneCapsules;
  997. }
  998. public enum MeshConstants
  999. {
  1000. MaxVertices = 3000,
  1001. MaxIndices = MaxVertices * 6,
  1002. }
  1003. public enum MeshType
  1004. {
  1005. None = -1,
  1006. HandLeft = 0,
  1007. HandRight = 1,
  1008. }
  1009. [StructLayout(LayoutKind.Sequential)]
  1010. public class Mesh
  1011. {
  1012. public MeshType Type;
  1013. public uint NumVertices;
  1014. public uint NumIndices;
  1015. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1016. public Vector3f[] VertexPositions;
  1017. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxIndices)]
  1018. public short[] Indices;
  1019. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1020. public Vector3f[] VertexNormals;
  1021. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1022. public Vector2f[] VertexUV0;
  1023. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1024. public Vector4s[] BlendIndices;
  1025. [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)MeshConstants.MaxVertices)]
  1026. public Vector4f[] BlendWeights;
  1027. }
  1028. public static bool initialized
  1029. {
  1030. get {
  1031. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1032. return false;
  1033. #else
  1034. return OVRP_1_1_0.ovrp_GetInitialized() == OVRPlugin.Bool.True;
  1035. #endif
  1036. }
  1037. }
  1038. public static bool chromatic
  1039. {
  1040. get {
  1041. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1042. return false;
  1043. #else
  1044. if (version >= OVRP_1_7_0.version)
  1045. return initialized && OVRP_1_7_0.ovrp_GetAppChromaticCorrection() == OVRPlugin.Bool.True;
  1046. #if UNITY_ANDROID && !UNITY_EDITOR
  1047. return false;
  1048. #else
  1049. return true;
  1050. #endif
  1051. #endif
  1052. }
  1053. set {
  1054. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1055. return;
  1056. #else
  1057. if (initialized && version >= OVRP_1_7_0.version)
  1058. OVRP_1_7_0.ovrp_SetAppChromaticCorrection(ToBool(value));
  1059. #endif
  1060. }
  1061. }
  1062. public static bool monoscopic
  1063. {
  1064. get {
  1065. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1066. return false;
  1067. #else
  1068. return initialized && OVRP_1_1_0.ovrp_GetAppMonoscopic() == OVRPlugin.Bool.True;
  1069. #endif
  1070. }
  1071. set {
  1072. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1073. return;
  1074. #else
  1075. if (initialized)
  1076. {
  1077. OVRP_1_1_0.ovrp_SetAppMonoscopic(ToBool(value));
  1078. }
  1079. #endif
  1080. }
  1081. }
  1082. public static bool rotation
  1083. {
  1084. get {
  1085. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1086. return false;
  1087. #else
  1088. return initialized && OVRP_1_1_0.ovrp_GetTrackingOrientationEnabled() == Bool.True;
  1089. #endif
  1090. }
  1091. set {
  1092. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1093. return;
  1094. #else
  1095. if (initialized)
  1096. {
  1097. OVRP_1_1_0.ovrp_SetTrackingOrientationEnabled(ToBool(value));
  1098. }
  1099. #endif
  1100. }
  1101. }
  1102. public static bool position
  1103. {
  1104. get {
  1105. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1106. return false;
  1107. #else
  1108. return initialized && OVRP_1_1_0.ovrp_GetTrackingPositionEnabled() == Bool.True;
  1109. #endif
  1110. }
  1111. set {
  1112. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1113. return;
  1114. #else
  1115. if (initialized)
  1116. {
  1117. OVRP_1_1_0.ovrp_SetTrackingPositionEnabled(ToBool(value));
  1118. }
  1119. #endif
  1120. }
  1121. }
  1122. public static bool useIPDInPositionTracking
  1123. {
  1124. get {
  1125. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1126. return false;
  1127. #else
  1128. if (initialized && version >= OVRP_1_6_0.version)
  1129. return OVRP_1_6_0.ovrp_GetTrackingIPDEnabled() == OVRPlugin.Bool.True;
  1130. return true;
  1131. #endif
  1132. }
  1133. set {
  1134. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1135. return;
  1136. #else
  1137. if (initialized && version >= OVRP_1_6_0.version)
  1138. OVRP_1_6_0.ovrp_SetTrackingIPDEnabled(ToBool(value));
  1139. #endif
  1140. }
  1141. }
  1142. public static bool positionSupported
  1143. {
  1144. get {
  1145. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1146. return false;
  1147. #else
  1148. return initialized && OVRP_1_1_0.ovrp_GetTrackingPositionSupported() == Bool.True;
  1149. #endif
  1150. }
  1151. }
  1152. public static bool positionTracked
  1153. {
  1154. get {
  1155. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1156. return false;
  1157. #else
  1158. return initialized && OVRP_1_1_0.ovrp_GetNodePositionTracked(Node.EyeCenter) == Bool.True;
  1159. #endif
  1160. }
  1161. }
  1162. public static bool powerSaving
  1163. {
  1164. get {
  1165. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1166. return false;
  1167. #else
  1168. return initialized && OVRP_1_1_0.ovrp_GetSystemPowerSavingMode() == Bool.True;
  1169. #endif
  1170. }
  1171. }
  1172. public static bool hmdPresent
  1173. {
  1174. get {
  1175. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1176. return false;
  1177. #else
  1178. return initialized && OVRP_1_1_0.ovrp_GetNodePresent(Node.EyeCenter) == Bool.True;
  1179. #endif
  1180. }
  1181. }
  1182. public static bool userPresent
  1183. {
  1184. get {
  1185. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1186. return false;
  1187. #else
  1188. return initialized && OVRP_1_1_0.ovrp_GetUserPresent() == Bool.True;
  1189. #endif
  1190. }
  1191. }
  1192. public static bool headphonesPresent
  1193. {
  1194. get {
  1195. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1196. return false;
  1197. #else
  1198. return initialized && OVRP_1_3_0.ovrp_GetSystemHeadphonesPresent() == OVRPlugin.Bool.True;
  1199. #endif
  1200. }
  1201. }
  1202. public static int recommendedMSAALevel
  1203. {
  1204. get {
  1205. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1206. return 2;
  1207. #else
  1208. if (initialized && version >= OVRP_1_6_0.version)
  1209. return OVRP_1_6_0.ovrp_GetSystemRecommendedMSAALevel();
  1210. else
  1211. return 2;
  1212. #endif
  1213. }
  1214. }
  1215. public static SystemRegion systemRegion
  1216. {
  1217. get {
  1218. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1219. return SystemRegion.Unspecified;
  1220. #else
  1221. if (initialized && version >= OVRP_1_5_0.version)
  1222. return OVRP_1_5_0.ovrp_GetSystemRegion();
  1223. else
  1224. return SystemRegion.Unspecified;
  1225. #endif
  1226. }
  1227. }
  1228. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  1229. private static GUID _nativeAudioOutGuid = new OVRPlugin.GUID();
  1230. private static Guid _cachedAudioOutGuid;
  1231. private static string _cachedAudioOutString;
  1232. #endif
  1233. public static string audioOutId
  1234. {
  1235. get {
  1236. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1237. return string.Empty;
  1238. #else
  1239. try
  1240. {
  1241. if (_nativeAudioOutGuid == null)
  1242. _nativeAudioOutGuid = new OVRPlugin.GUID();
  1243. IntPtr ptr = OVRP_1_1_0.ovrp_GetAudioOutId();
  1244. if (ptr != IntPtr.Zero)
  1245. {
  1246. Marshal.PtrToStructure(ptr, _nativeAudioOutGuid);
  1247. Guid managedGuid = new Guid(
  1248. _nativeAudioOutGuid.a,
  1249. _nativeAudioOutGuid.b,
  1250. _nativeAudioOutGuid.c,
  1251. _nativeAudioOutGuid.d0,
  1252. _nativeAudioOutGuid.d1,
  1253. _nativeAudioOutGuid.d2,
  1254. _nativeAudioOutGuid.d3,
  1255. _nativeAudioOutGuid.d4,
  1256. _nativeAudioOutGuid.d5,
  1257. _nativeAudioOutGuid.d6,
  1258. _nativeAudioOutGuid.d7);
  1259. if (managedGuid != _cachedAudioOutGuid)
  1260. {
  1261. _cachedAudioOutGuid = managedGuid;
  1262. _cachedAudioOutString = _cachedAudioOutGuid.ToString();
  1263. }
  1264. return _cachedAudioOutString;
  1265. }
  1266. }
  1267. catch { }
  1268. return string.Empty;
  1269. #endif
  1270. }
  1271. }
  1272. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  1273. private static GUID _nativeAudioInGuid = new OVRPlugin.GUID();
  1274. private static Guid _cachedAudioInGuid;
  1275. private static string _cachedAudioInString;
  1276. #endif
  1277. public static string audioInId
  1278. {
  1279. get {
  1280. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1281. return string.Empty;
  1282. #else
  1283. try
  1284. {
  1285. if (_nativeAudioInGuid == null)
  1286. _nativeAudioInGuid = new OVRPlugin.GUID();
  1287. IntPtr ptr = OVRP_1_1_0.ovrp_GetAudioInId();
  1288. if (ptr != IntPtr.Zero)
  1289. {
  1290. Marshal.PtrToStructure(ptr, _nativeAudioInGuid);
  1291. Guid managedGuid = new Guid(
  1292. _nativeAudioInGuid.a,
  1293. _nativeAudioInGuid.b,
  1294. _nativeAudioInGuid.c,
  1295. _nativeAudioInGuid.d0,
  1296. _nativeAudioInGuid.d1,
  1297. _nativeAudioInGuid.d2,
  1298. _nativeAudioInGuid.d3,
  1299. _nativeAudioInGuid.d4,
  1300. _nativeAudioInGuid.d5,
  1301. _nativeAudioInGuid.d6,
  1302. _nativeAudioInGuid.d7);
  1303. if (managedGuid != _cachedAudioInGuid)
  1304. {
  1305. _cachedAudioInGuid = managedGuid;
  1306. _cachedAudioInString = _cachedAudioInGuid.ToString();
  1307. }
  1308. return _cachedAudioInString;
  1309. }
  1310. }
  1311. catch { }
  1312. return string.Empty;
  1313. #endif
  1314. }
  1315. }
  1316. public static bool hasVrFocus
  1317. {
  1318. get {
  1319. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1320. return false;
  1321. #else
  1322. return OVRP_1_1_0.ovrp_GetAppHasVrFocus() == Bool.True;
  1323. #endif
  1324. }
  1325. }
  1326. public static bool hasInputFocus
  1327. {
  1328. get
  1329. {
  1330. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1331. return true;
  1332. #else
  1333. if (version >= OVRP_1_18_0.version)
  1334. {
  1335. Bool inputFocus = Bool.False;
  1336. Result result = OVRP_1_18_0.ovrp_GetAppHasInputFocus(out inputFocus);
  1337. if (Result.Success == result)
  1338. return inputFocus == Bool.True;
  1339. else
  1340. {
  1341. //Debug.LogWarning("ovrp_GetAppHasInputFocus return " + result);
  1342. return false;
  1343. }
  1344. }
  1345. return true;
  1346. #endif
  1347. }
  1348. }
  1349. public static bool shouldQuit
  1350. {
  1351. get {
  1352. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1353. return false;
  1354. #else
  1355. return OVRP_1_1_0.ovrp_GetAppShouldQuit() == Bool.True;
  1356. #endif
  1357. }
  1358. }
  1359. public static bool shouldRecenter
  1360. {
  1361. get {
  1362. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1363. return false;
  1364. #else
  1365. return OVRP_1_1_0.ovrp_GetAppShouldRecenter() == Bool.True;
  1366. #endif
  1367. }
  1368. }
  1369. public static string productName
  1370. {
  1371. get {
  1372. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1373. return string.Empty;
  1374. #else
  1375. return OVRP_1_1_0.ovrp_GetSystemProductName();
  1376. #endif
  1377. }
  1378. }
  1379. public static string latency
  1380. {
  1381. get {
  1382. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1383. return string.Empty;
  1384. #else
  1385. if (!initialized)
  1386. return string.Empty;
  1387. return OVRP_1_1_0.ovrp_GetAppLatencyTimings();
  1388. #endif
  1389. }
  1390. }
  1391. public static float eyeDepth
  1392. {
  1393. get {
  1394. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1395. return 0.0f;
  1396. #else
  1397. if (!initialized)
  1398. return 0.0f;
  1399. return OVRP_1_1_0.ovrp_GetUserEyeDepth();
  1400. #endif
  1401. }
  1402. set {
  1403. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1404. return;
  1405. #else
  1406. OVRP_1_1_0.ovrp_SetUserEyeDepth(value);
  1407. #endif
  1408. }
  1409. }
  1410. public static float eyeHeight
  1411. {
  1412. get {
  1413. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1414. return 0.0f;
  1415. #else
  1416. return OVRP_1_1_0.ovrp_GetUserEyeHeight();
  1417. #endif
  1418. }
  1419. set {
  1420. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1421. return;
  1422. #else
  1423. OVRP_1_1_0.ovrp_SetUserEyeHeight(value);
  1424. #endif
  1425. }
  1426. }
  1427. public static float batteryLevel
  1428. {
  1429. get {
  1430. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1431. return 0.0f;
  1432. #else
  1433. return OVRP_1_1_0.ovrp_GetSystemBatteryLevel();
  1434. #endif
  1435. }
  1436. }
  1437. public static float batteryTemperature
  1438. {
  1439. get {
  1440. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1441. return 0.0f;
  1442. #else
  1443. return OVRP_1_1_0.ovrp_GetSystemBatteryTemperature();
  1444. #endif
  1445. }
  1446. }
  1447. public static int cpuLevel
  1448. {
  1449. get {
  1450. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1451. return 0;
  1452. #else
  1453. return OVRP_1_1_0.ovrp_GetSystemCpuLevel();
  1454. #endif
  1455. }
  1456. set {
  1457. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1458. return;
  1459. #else
  1460. OVRP_1_1_0.ovrp_SetSystemCpuLevel(value);
  1461. #endif
  1462. }
  1463. }
  1464. public static int gpuLevel
  1465. {
  1466. get {
  1467. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1468. return 0;
  1469. #else
  1470. return OVRP_1_1_0.ovrp_GetSystemGpuLevel();
  1471. #endif
  1472. }
  1473. set {
  1474. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1475. return;
  1476. #else
  1477. OVRP_1_1_0.ovrp_SetSystemGpuLevel(value);
  1478. #endif
  1479. }
  1480. }
  1481. public static int vsyncCount
  1482. {
  1483. get {
  1484. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1485. return 0;
  1486. #else
  1487. return OVRP_1_1_0.ovrp_GetSystemVSyncCount();
  1488. #endif
  1489. }
  1490. set {
  1491. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1492. return;
  1493. #else
  1494. OVRP_1_2_0.ovrp_SetSystemVSyncCount(value);
  1495. #endif
  1496. }
  1497. }
  1498. public static float systemVolume
  1499. {
  1500. get {
  1501. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1502. return 0.0f;
  1503. #else
  1504. return OVRP_1_1_0.ovrp_GetSystemVolume();
  1505. #endif
  1506. }
  1507. }
  1508. public static float ipd
  1509. {
  1510. get {
  1511. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1512. return 0.0f;
  1513. #else
  1514. return OVRP_1_1_0.ovrp_GetUserIPD();
  1515. #endif
  1516. }
  1517. set {
  1518. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1519. return;
  1520. #else
  1521. OVRP_1_1_0.ovrp_SetUserIPD(value);
  1522. #endif
  1523. }
  1524. }
  1525. public static bool occlusionMesh
  1526. {
  1527. get {
  1528. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1529. return false;
  1530. #else
  1531. return initialized && (OVRP_1_3_0.ovrp_GetEyeOcclusionMeshEnabled() == Bool.True);
  1532. #endif
  1533. }
  1534. set {
  1535. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1536. return;
  1537. #else
  1538. if (!initialized)
  1539. return;
  1540. OVRP_1_3_0.ovrp_SetEyeOcclusionMeshEnabled(ToBool(value));
  1541. #endif
  1542. }
  1543. }
  1544. public static BatteryStatus batteryStatus
  1545. {
  1546. get {
  1547. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1548. return default(BatteryStatus);
  1549. #else
  1550. return OVRP_1_1_0.ovrp_GetSystemBatteryStatus();
  1551. #endif
  1552. }
  1553. }
  1554. public static Frustumf GetEyeFrustum(Eye eyeId)
  1555. {
  1556. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1557. return new Frustumf();
  1558. #else
  1559. return OVRP_1_1_0.ovrp_GetNodeFrustum((Node)eyeId);
  1560. #endif
  1561. }
  1562. public static Sizei GetEyeTextureSize(Eye eyeId)
  1563. {
  1564. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1565. return new Sizei();
  1566. #else
  1567. return OVRP_0_1_0.ovrp_GetEyeTextureSize(eyeId);
  1568. #endif
  1569. }
  1570. public static Posef GetTrackerPose(Tracker trackerId)
  1571. {
  1572. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1573. return Posef.identity;
  1574. #else
  1575. return GetNodePose((Node)((int)trackerId + (int)Node.TrackerZero), Step.Render);
  1576. #endif
  1577. }
  1578. public static Frustumf GetTrackerFrustum(Tracker trackerId)
  1579. {
  1580. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1581. return new Frustumf();
  1582. #else
  1583. return OVRP_1_1_0.ovrp_GetNodeFrustum((Node)((int)trackerId + (int)Node.TrackerZero));
  1584. #endif
  1585. }
  1586. public static bool ShowUI(PlatformUI ui)
  1587. {
  1588. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1589. return false;
  1590. #else
  1591. return OVRP_1_1_0.ovrp_ShowSystemUI(ui) == Bool.True;
  1592. #endif
  1593. }
  1594. public static bool EnqueueSubmitLayer(bool onTop, bool headLocked, bool noDepthBufferTesting, IntPtr leftTexture, IntPtr rightTexture, int layerId, int frameIndex, Posef pose, Vector3f scale, int layerIndex = 0, OverlayShape shape = OverlayShape.Quad,
  1595. bool overrideTextureRectMatrix = false, TextureRectMatrixf textureRectMatrix = default(TextureRectMatrixf), bool overridePerLayerColorScaleAndOffset = false, Vector4 colorScale = default(Vector4), Vector4 colorOffset = default(Vector4),
  1596. bool expensiveSuperSample = false, bool hidden = false)
  1597. {
  1598. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1599. return false;
  1600. #else
  1601. if (!initialized)
  1602. return false;
  1603. if (version >= OVRP_1_6_0.version)
  1604. {
  1605. uint flags = (uint)OverlayFlag.None;
  1606. if (onTop)
  1607. flags |= (uint)OverlayFlag.OnTop;
  1608. if (headLocked)
  1609. flags |= (uint)OverlayFlag.HeadLocked;
  1610. if (noDepthBufferTesting)
  1611. flags |= (uint)OverlayFlag.NoDepth;
  1612. if (expensiveSuperSample)
  1613. flags |= (uint)OverlayFlag.ExpensiveSuperSample;
  1614. if (hidden)
  1615. flags |= (uint)OverlayFlag.Hidden;
  1616. if (shape == OverlayShape.Cylinder || shape == OverlayShape.Cubemap)
  1617. {
  1618. #if UNITY_ANDROID
  1619. if (version >= OVRP_1_7_0.version)
  1620. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1621. else
  1622. #else
  1623. if (shape == OverlayShape.Cubemap && version >= OVRP_1_10_0.version)
  1624. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1625. else if (shape == OverlayShape.Cylinder && version >= OVRP_1_16_0.version)
  1626. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1627. else
  1628. #endif
  1629. return false;
  1630. }
  1631. if (shape == OverlayShape.OffcenterCubemap)
  1632. {
  1633. #if UNITY_ANDROID
  1634. if (version >= OVRP_1_11_0.version)
  1635. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1636. else
  1637. #endif
  1638. return false;
  1639. }
  1640. if (shape == OverlayShape.Equirect)
  1641. {
  1642. #if UNITY_ANDROID
  1643. if (version >= OVRP_1_21_0.version)
  1644. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1645. else
  1646. #endif
  1647. return false;
  1648. }
  1649. if (version >= OVRP_1_34_0.version && layerId != -1)
  1650. return OVRP_1_34_0.ovrp_EnqueueSubmitLayer2(flags, leftTexture, rightTexture, layerId, frameIndex, ref pose, ref scale, layerIndex,
  1651. overrideTextureRectMatrix ? Bool.True : Bool.False, ref textureRectMatrix, overridePerLayerColorScaleAndOffset ? Bool.True : Bool.False, ref colorScale, ref colorOffset) == Result.Success;
  1652. else if (version >= OVRP_1_15_0.version && layerId != -1)
  1653. return OVRP_1_15_0.ovrp_EnqueueSubmitLayer(flags, leftTexture, rightTexture, layerId, frameIndex, ref pose, ref scale, layerIndex) == Result.Success;
  1654. return OVRP_1_6_0.ovrp_SetOverlayQuad3(flags, leftTexture, rightTexture, IntPtr.Zero, pose, scale, layerIndex) == Bool.True;
  1655. }
  1656. if (layerIndex != 0)
  1657. return false;
  1658. return OVRP_0_1_1.ovrp_SetOverlayQuad2(ToBool(onTop), ToBool(headLocked), leftTexture, IntPtr.Zero, pose, scale) == Bool.True;
  1659. #endif
  1660. }
  1661. public static LayerDesc CalculateLayerDesc(OverlayShape shape, LayerLayout layout, Sizei textureSize,
  1662. int mipLevels, int sampleCount, EyeTextureFormat format, int layerFlags)
  1663. {
  1664. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1665. return new LayerDesc();
  1666. #else
  1667. LayerDesc layerDesc = new LayerDesc();
  1668. if (!initialized)
  1669. return layerDesc;
  1670. if (version >= OVRP_1_15_0.version)
  1671. {
  1672. OVRP_1_15_0.ovrp_CalculateLayerDesc(shape, layout, ref textureSize,
  1673. mipLevels, sampleCount, format, layerFlags, ref layerDesc);
  1674. }
  1675. return layerDesc;
  1676. #endif
  1677. }
  1678. public static bool EnqueueSetupLayer(LayerDesc desc, int compositionDepth, IntPtr layerID)
  1679. {
  1680. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1681. return false;
  1682. #else
  1683. if (!initialized)
  1684. return false;
  1685. if (version >= OVRP_1_28_0.version)
  1686. return OVRP_1_28_0.ovrp_EnqueueSetupLayer2(ref desc, compositionDepth, layerID) == Result.Success;
  1687. else if (version >= OVRP_1_15_0.version)
  1688. {
  1689. if (compositionDepth != 0)
  1690. {
  1691. Debug.LogWarning("Use Oculus Plugin 1.28.0 or above to support non-zero compositionDepth");
  1692. }
  1693. return OVRP_1_15_0.ovrp_EnqueueSetupLayer(ref desc, layerID) == Result.Success;
  1694. }
  1695. return false;
  1696. #endif
  1697. }
  1698. public static bool EnqueueDestroyLayer(IntPtr layerID)
  1699. {
  1700. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1701. return false;
  1702. #else
  1703. if (!initialized)
  1704. return false;
  1705. if (version >= OVRP_1_15_0.version)
  1706. return OVRP_1_15_0.ovrp_EnqueueDestroyLayer(layerID) == Result.Success;
  1707. return false;
  1708. #endif
  1709. }
  1710. public static IntPtr GetLayerTexture(int layerId, int stage, Eye eyeId)
  1711. {
  1712. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1713. return IntPtr.Zero;
  1714. #else
  1715. IntPtr textureHandle = IntPtr.Zero;
  1716. if (!initialized)
  1717. return textureHandle;
  1718. if (version >= OVRP_1_15_0.version)
  1719. OVRP_1_15_0.ovrp_GetLayerTexturePtr(layerId, stage, eyeId, ref textureHandle);
  1720. return textureHandle;
  1721. #endif
  1722. }
  1723. public static int GetLayerTextureStageCount(int layerId)
  1724. {
  1725. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1726. return 1;
  1727. #else
  1728. if (!initialized)
  1729. return 1;
  1730. int stageCount = 1;
  1731. if (version >= OVRP_1_15_0.version)
  1732. OVRP_1_15_0.ovrp_GetLayerTextureStageCount(layerId, ref stageCount);
  1733. return stageCount;
  1734. #endif
  1735. }
  1736. public static IntPtr GetLayerAndroidSurfaceObject(int layerId)
  1737. {
  1738. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1739. return IntPtr.Zero;
  1740. #else
  1741. IntPtr surfaceObject = IntPtr.Zero;
  1742. if (!initialized)
  1743. return surfaceObject;
  1744. if (version >= OVRP_1_29_0.version)
  1745. OVRP_1_29_0.ovrp_GetLayerAndroidSurfaceObject(layerId, ref surfaceObject);
  1746. return surfaceObject;
  1747. #endif
  1748. }
  1749. public static bool UpdateNodePhysicsPoses(int frameIndex, double predictionSeconds)
  1750. {
  1751. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1752. return false;
  1753. #else
  1754. if (version >= OVRP_1_8_0.version)
  1755. return OVRP_1_8_0.ovrp_Update2((int)Step.Physics, frameIndex, predictionSeconds) == Bool.True;
  1756. return false;
  1757. #endif
  1758. }
  1759. public static Posef GetNodePose(Node nodeId, Step stepId)
  1760. {
  1761. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1762. return Posef.identity;
  1763. #else
  1764. if (version >= OVRP_1_12_0.version)
  1765. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Pose;
  1766. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1767. return OVRP_1_8_0.ovrp_GetNodePose2(0, nodeId);
  1768. return OVRP_0_1_2.ovrp_GetNodePose(nodeId);
  1769. #endif
  1770. }
  1771. public static Vector3f GetNodeVelocity(Node nodeId, Step stepId)
  1772. {
  1773. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1774. return new Vector3f();
  1775. #else
  1776. if (version >= OVRP_1_12_0.version)
  1777. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Velocity;
  1778. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1779. return OVRP_1_8_0.ovrp_GetNodeVelocity2(0, nodeId).Position;
  1780. return OVRP_0_1_3.ovrp_GetNodeVelocity(nodeId).Position;
  1781. #endif
  1782. }
  1783. public static Vector3f GetNodeAngularVelocity(Node nodeId, Step stepId)
  1784. {
  1785. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1786. return new Vector3f();
  1787. #else
  1788. if (version >= OVRP_1_12_0.version)
  1789. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).AngularVelocity;
  1790. return new Vector3f(); //TODO: Convert legacy quat to vec3?
  1791. #endif
  1792. }
  1793. public static Vector3f GetNodeAcceleration(Node nodeId, Step stepId)
  1794. {
  1795. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1796. return new Vector3f();
  1797. #else
  1798. if (version >= OVRP_1_12_0.version)
  1799. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Acceleration;
  1800. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1801. return OVRP_1_8_0.ovrp_GetNodeAcceleration2(0, nodeId).Position;
  1802. return OVRP_0_1_3.ovrp_GetNodeAcceleration(nodeId).Position;
  1803. #endif
  1804. }
  1805. public static Vector3f GetNodeAngularAcceleration(Node nodeId, Step stepId)
  1806. {
  1807. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1808. return new Vector3f();
  1809. #else
  1810. if (version >= OVRP_1_12_0.version)
  1811. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).AngularAcceleration;
  1812. return new Vector3f(); //TODO: Convert legacy quat to vec3?
  1813. #endif
  1814. }
  1815. public static bool GetNodePresent(Node nodeId)
  1816. {
  1817. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1818. return false;
  1819. #else
  1820. return OVRP_1_1_0.ovrp_GetNodePresent(nodeId) == Bool.True;
  1821. #endif
  1822. }
  1823. public static bool GetNodeOrientationTracked(Node nodeId)
  1824. {
  1825. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1826. return false;
  1827. #else
  1828. return OVRP_1_1_0.ovrp_GetNodeOrientationTracked(nodeId) == Bool.True;
  1829. #endif
  1830. }
  1831. public static bool GetNodeOrientationValid(Node nodeId)
  1832. {
  1833. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1834. return false;
  1835. #else
  1836. if (version >= OVRP_1_38_0.version)
  1837. {
  1838. Bool orientationValid = Bool.False;
  1839. Result result = OVRP_1_38_0.ovrp_GetNodeOrientationValid(nodeId, ref orientationValid);
  1840. return result == Result.Success && orientationValid == Bool.True;
  1841. }
  1842. else
  1843. {
  1844. return GetNodeOrientationTracked(nodeId);
  1845. }
  1846. #endif
  1847. }
  1848. public static bool GetNodePositionTracked(Node nodeId)
  1849. {
  1850. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1851. return false;
  1852. #else
  1853. return OVRP_1_1_0.ovrp_GetNodePositionTracked(nodeId) == Bool.True;
  1854. #endif
  1855. }
  1856. public static bool GetNodePositionValid(Node nodeId)
  1857. {
  1858. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1859. return false;
  1860. #else
  1861. if (version >= OVRP_1_38_0.version)
  1862. {
  1863. Bool positionValid = Bool.False;
  1864. Result result = OVRP_1_38_0.ovrp_GetNodePositionValid(nodeId, ref positionValid);
  1865. return result == Result.Success && positionValid == Bool.True;
  1866. }
  1867. else
  1868. {
  1869. return GetNodePositionTracked(nodeId);
  1870. }
  1871. #endif
  1872. }
  1873. public static PoseStatef GetNodePoseStateRaw(Node nodeId, Step stepId)
  1874. {
  1875. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1876. return PoseStatef.identity;
  1877. #else
  1878. if (version >= OVRP_1_29_0.version)
  1879. {
  1880. PoseStatef nodePoseState;
  1881. Result result = OVRP_1_29_0.ovrp_GetNodePoseStateRaw(stepId, -1, nodeId, out nodePoseState);
  1882. if (result == Result.Success)
  1883. {
  1884. return nodePoseState;
  1885. }
  1886. else
  1887. {
  1888. return PoseStatef.identity;
  1889. }
  1890. }
  1891. if (version >= OVRP_1_12_0.version)
  1892. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId);
  1893. else
  1894. return PoseStatef.identity;
  1895. #endif
  1896. }
  1897. public static Posef GetCurrentTrackingTransformPose()
  1898. {
  1899. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1900. return Posef.identity;
  1901. #else
  1902. if (version >= OVRP_1_30_0.version)
  1903. {
  1904. Posef trackingTransformPose;
  1905. Result result = OVRP_1_30_0.ovrp_GetCurrentTrackingTransformPose(out trackingTransformPose);
  1906. if (result == Result.Success)
  1907. {
  1908. return trackingTransformPose;
  1909. }
  1910. else
  1911. {
  1912. return Posef.identity;
  1913. }
  1914. }
  1915. else
  1916. {
  1917. return Posef.identity;
  1918. }
  1919. #endif
  1920. }
  1921. public static Posef GetTrackingTransformRawPose()
  1922. {
  1923. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1924. return Posef.identity;
  1925. #else
  1926. if (version >= OVRP_1_30_0.version)
  1927. {
  1928. Posef trackingTransforRawPose;
  1929. Result result = OVRP_1_30_0.ovrp_GetTrackingTransformRawPose(out trackingTransforRawPose);
  1930. if (result == Result.Success)
  1931. {
  1932. return trackingTransforRawPose;
  1933. }
  1934. else
  1935. {
  1936. return Posef.identity;
  1937. }
  1938. }
  1939. else
  1940. {
  1941. return Posef.identity;
  1942. }
  1943. #endif
  1944. }
  1945. public static Posef GetTrackingTransformRelativePose(TrackingOrigin trackingOrigin)
  1946. {
  1947. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1948. return Posef.identity;
  1949. #else
  1950. if (version >= OVRP_1_38_0.version)
  1951. {
  1952. Posef trackingTransformRelativePose = Posef.identity;
  1953. Result result = OVRP_1_38_0.ovrp_GetTrackingTransformRelativePose(ref trackingTransformRelativePose, trackingOrigin);
  1954. if (result == Result.Success)
  1955. {
  1956. return trackingTransformRelativePose;
  1957. }
  1958. else
  1959. {
  1960. return Posef.identity;
  1961. }
  1962. }
  1963. else
  1964. {
  1965. return Posef.identity;
  1966. }
  1967. #endif
  1968. }
  1969. public static ControllerState GetControllerState(uint controllerMask)
  1970. {
  1971. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1972. return new ControllerState();
  1973. #else
  1974. return OVRP_1_1_0.ovrp_GetControllerState(controllerMask);
  1975. #endif
  1976. }
  1977. public static ControllerState2 GetControllerState2(uint controllerMask)
  1978. {
  1979. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1980. return new ControllerState2();
  1981. #else
  1982. if (version >= OVRP_1_12_0.version)
  1983. {
  1984. return OVRP_1_12_0.ovrp_GetControllerState2(controllerMask);
  1985. }
  1986. return new ControllerState2(OVRP_1_1_0.ovrp_GetControllerState(controllerMask));
  1987. #endif
  1988. }
  1989. public static ControllerState4 GetControllerState4(uint controllerMask)
  1990. {
  1991. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1992. return new ControllerState4();
  1993. #else
  1994. if (version >= OVRP_1_16_0.version)
  1995. {
  1996. ControllerState4 controllerState = new ControllerState4();
  1997. OVRP_1_16_0.ovrp_GetControllerState4(controllerMask, ref controllerState);
  1998. return controllerState;
  1999. }
  2000. return new ControllerState4(GetControllerState2(controllerMask));
  2001. #endif
  2002. }
  2003. public static bool SetControllerVibration(uint controllerMask, float frequency, float amplitude)
  2004. {
  2005. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2006. return false;
  2007. #else
  2008. return OVRP_0_1_2.ovrp_SetControllerVibration(controllerMask, frequency, amplitude) == Bool.True;
  2009. #endif
  2010. }
  2011. public static HapticsDesc GetControllerHapticsDesc(uint controllerMask)
  2012. {
  2013. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2014. return new HapticsDesc();
  2015. #else
  2016. if (version >= OVRP_1_6_0.version)
  2017. {
  2018. return OVRP_1_6_0.ovrp_GetControllerHapticsDesc(controllerMask);
  2019. }
  2020. else
  2021. {
  2022. return new HapticsDesc();
  2023. }
  2024. #endif
  2025. }
  2026. public static HapticsState GetControllerHapticsState(uint controllerMask)
  2027. {
  2028. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2029. return new HapticsState();
  2030. #else
  2031. if (version >= OVRP_1_6_0.version)
  2032. {
  2033. return OVRP_1_6_0.ovrp_GetControllerHapticsState(controllerMask);
  2034. }
  2035. else
  2036. {
  2037. return new HapticsState();
  2038. }
  2039. #endif
  2040. }
  2041. public static bool SetControllerHaptics(uint controllerMask, HapticsBuffer hapticsBuffer)
  2042. {
  2043. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2044. return false;
  2045. #else
  2046. if (version >= OVRP_1_6_0.version)
  2047. {
  2048. return OVRP_1_6_0.ovrp_SetControllerHaptics(controllerMask, hapticsBuffer) == Bool.True;
  2049. }
  2050. else
  2051. {
  2052. return false;
  2053. }
  2054. #endif
  2055. }
  2056. public static float GetEyeRecommendedResolutionScale()
  2057. {
  2058. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2059. return 1.0f;
  2060. #else
  2061. if (version >= OVRP_1_6_0.version)
  2062. {
  2063. return OVRP_1_6_0.ovrp_GetEyeRecommendedResolutionScale();
  2064. }
  2065. else
  2066. {
  2067. return 1.0f;
  2068. }
  2069. #endif
  2070. }
  2071. public static float GetAppCpuStartToGpuEndTime()
  2072. {
  2073. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2074. return 0.0f;
  2075. #else
  2076. if (version >= OVRP_1_6_0.version)
  2077. {
  2078. return OVRP_1_6_0.ovrp_GetAppCpuStartToGpuEndTime();
  2079. }
  2080. else
  2081. {
  2082. return 0.0f;
  2083. }
  2084. #endif
  2085. }
  2086. public static bool GetBoundaryConfigured()
  2087. {
  2088. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2089. return false;
  2090. #else
  2091. if (version >= OVRP_1_8_0.version)
  2092. {
  2093. return OVRP_1_8_0.ovrp_GetBoundaryConfigured() == OVRPlugin.Bool.True;
  2094. }
  2095. else
  2096. {
  2097. return false;
  2098. }
  2099. #endif
  2100. }
  2101. public static BoundaryTestResult TestBoundaryNode(Node nodeId, BoundaryType boundaryType)
  2102. {
  2103. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2104. return new BoundaryTestResult();
  2105. #else
  2106. if (version >= OVRP_1_8_0.version)
  2107. {
  2108. return OVRP_1_8_0.ovrp_TestBoundaryNode(nodeId, boundaryType);
  2109. }
  2110. else
  2111. {
  2112. return new BoundaryTestResult();
  2113. }
  2114. #endif
  2115. }
  2116. public static BoundaryTestResult TestBoundaryPoint(Vector3f point, BoundaryType boundaryType)
  2117. {
  2118. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2119. return new BoundaryTestResult();
  2120. #else
  2121. if (version >= OVRP_1_8_0.version)
  2122. {
  2123. return OVRP_1_8_0.ovrp_TestBoundaryPoint(point, boundaryType);
  2124. }
  2125. else
  2126. {
  2127. return new BoundaryTestResult();
  2128. }
  2129. #endif
  2130. }
  2131. public static BoundaryGeometry GetBoundaryGeometry(BoundaryType boundaryType)
  2132. {
  2133. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2134. return new BoundaryGeometry();
  2135. #else
  2136. if (version >= OVRP_1_8_0.version)
  2137. {
  2138. return OVRP_1_8_0.ovrp_GetBoundaryGeometry(boundaryType);
  2139. }
  2140. else
  2141. {
  2142. return new BoundaryGeometry();
  2143. }
  2144. #endif
  2145. }
  2146. public static bool GetBoundaryGeometry2(BoundaryType boundaryType, IntPtr points, ref int pointsCount)
  2147. {
  2148. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2149. pointsCount = 0;
  2150. return false;
  2151. #else
  2152. if (version >= OVRP_1_9_0.version)
  2153. {
  2154. return OVRP_1_9_0.ovrp_GetBoundaryGeometry2(boundaryType, points, ref pointsCount) == OVRPlugin.Bool.True;
  2155. }
  2156. else
  2157. {
  2158. pointsCount = 0;
  2159. return false;
  2160. }
  2161. #endif
  2162. }
  2163. public static AppPerfStats GetAppPerfStats()
  2164. {
  2165. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2166. return new AppPerfStats();
  2167. #else
  2168. if (version >= OVRP_1_9_0.version)
  2169. {
  2170. return OVRP_1_9_0.ovrp_GetAppPerfStats();
  2171. }
  2172. else
  2173. {
  2174. return new AppPerfStats();
  2175. }
  2176. #endif
  2177. }
  2178. public static bool ResetAppPerfStats()
  2179. {
  2180. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2181. return false;
  2182. #else
  2183. if (version >= OVRP_1_9_0.version)
  2184. {
  2185. return OVRP_1_9_0.ovrp_ResetAppPerfStats() == OVRPlugin.Bool.True;
  2186. }
  2187. else
  2188. {
  2189. return false;
  2190. }
  2191. #endif
  2192. }
  2193. public static float GetAppFramerate()
  2194. {
  2195. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2196. return 0.0f;
  2197. #else
  2198. if (version >= OVRP_1_12_0.version)
  2199. {
  2200. return OVRP_1_12_0.ovrp_GetAppFramerate();
  2201. }
  2202. else
  2203. {
  2204. return 0.0f;
  2205. }
  2206. #endif
  2207. }
  2208. public static bool SetHandNodePoseStateLatency(double latencyInSeconds)
  2209. {
  2210. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2211. return false;
  2212. #else
  2213. if (version >= OVRP_1_18_0.version)
  2214. {
  2215. Result result = OVRP_1_18_0.ovrp_SetHandNodePoseStateLatency(latencyInSeconds);
  2216. if (result == Result.Success)
  2217. {
  2218. return true;
  2219. }
  2220. else
  2221. {
  2222. //Debug.LogWarning("ovrp_SetHandNodePoseStateLatency return " + result);
  2223. return false;
  2224. }
  2225. }
  2226. else
  2227. {
  2228. return false;
  2229. }
  2230. #endif
  2231. }
  2232. public static double GetHandNodePoseStateLatency()
  2233. {
  2234. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2235. return 0.0;
  2236. #else
  2237. if (version >= OVRP_1_18_0.version)
  2238. {
  2239. double value = 0.0;
  2240. if (OVRP_1_18_0.ovrp_GetHandNodePoseStateLatency(out value) == OVRPlugin.Result.Success)
  2241. {
  2242. return value;
  2243. }
  2244. else
  2245. {
  2246. return 0.0;
  2247. }
  2248. }
  2249. else
  2250. {
  2251. return 0.0;
  2252. }
  2253. #endif
  2254. }
  2255. public static EyeTextureFormat GetDesiredEyeTextureFormat()
  2256. {
  2257. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2258. return EyeTextureFormat.Default;
  2259. #else
  2260. if (version >= OVRP_1_11_0.version)
  2261. {
  2262. uint eyeTextureFormatValue = (uint)OVRP_1_11_0.ovrp_GetDesiredEyeTextureFormat();
  2263. // convert both R8G8B8A8 and R8G8B8A8_SRGB to R8G8B8A8 here for avoid confusing developers
  2264. if (eyeTextureFormatValue == 1)
  2265. eyeTextureFormatValue = 0;
  2266. return (EyeTextureFormat)eyeTextureFormatValue;
  2267. }
  2268. else
  2269. {
  2270. return EyeTextureFormat.Default;
  2271. }
  2272. #endif
  2273. }
  2274. public static bool SetDesiredEyeTextureFormat(EyeTextureFormat value)
  2275. {
  2276. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2277. return false;
  2278. #else
  2279. if (version >= OVRP_1_11_0.version)
  2280. {
  2281. return OVRP_1_11_0.ovrp_SetDesiredEyeTextureFormat(value) == OVRPlugin.Bool.True;
  2282. }
  2283. else
  2284. {
  2285. return false;
  2286. }
  2287. #endif
  2288. }
  2289. public static bool InitializeMixedReality()
  2290. {
  2291. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2292. return false;
  2293. #else
  2294. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2295. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2296. #else
  2297. if (version >= OVRP_1_15_0.version)
  2298. #endif
  2299. {
  2300. Result result = OVRP_1_15_0.ovrp_InitializeMixedReality();
  2301. if (result != Result.Success)
  2302. {
  2303. //Debug.LogWarning("ovrp_InitializeMixedReality return " + result);
  2304. }
  2305. return result == Result.Success;
  2306. }
  2307. else
  2308. {
  2309. return false;
  2310. }
  2311. #endif
  2312. }
  2313. public static bool ShutdownMixedReality()
  2314. {
  2315. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2316. return false;
  2317. #else
  2318. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2319. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2320. #else
  2321. if (version >= OVRP_1_15_0.version)
  2322. #endif
  2323. {
  2324. Result result = OVRP_1_15_0.ovrp_ShutdownMixedReality();
  2325. if (result != Result.Success)
  2326. {
  2327. //Debug.LogWarning("ovrp_ShutdownMixedReality return " + result);
  2328. }
  2329. return result == Result.Success;
  2330. }
  2331. else
  2332. {
  2333. return false;
  2334. }
  2335. #endif
  2336. }
  2337. public static bool IsMixedRealityInitialized()
  2338. {
  2339. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2340. return false;
  2341. #else
  2342. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2343. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2344. #else
  2345. if (version >= OVRP_1_15_0.version)
  2346. #endif
  2347. {
  2348. return OVRP_1_15_0.ovrp_GetMixedRealityInitialized() == Bool.True;
  2349. }
  2350. else
  2351. {
  2352. return false;
  2353. }
  2354. #endif
  2355. }
  2356. public static int GetExternalCameraCount()
  2357. {
  2358. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2359. return 0;
  2360. #else
  2361. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2362. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2363. #else
  2364. if (version >= OVRP_1_15_0.version)
  2365. #endif
  2366. {
  2367. int cameraCount = 0;
  2368. Result result = OVRP_1_15_0.ovrp_GetExternalCameraCount(out cameraCount);
  2369. if (result != OVRPlugin.Result.Success)
  2370. {
  2371. //Debug.LogWarning("ovrp_GetExternalCameraCount return " + result);
  2372. return 0;
  2373. }
  2374. return cameraCount;
  2375. }
  2376. else
  2377. {
  2378. return 0;
  2379. }
  2380. #endif
  2381. }
  2382. public static bool UpdateExternalCamera()
  2383. {
  2384. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2385. return false;
  2386. #else
  2387. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2388. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2389. #else
  2390. if (version >= OVRP_1_15_0.version)
  2391. #endif
  2392. {
  2393. Result result = OVRP_1_15_0.ovrp_UpdateExternalCamera();
  2394. if (result != Result.Success)
  2395. {
  2396. //Debug.LogWarning("ovrp_UpdateExternalCamera return " + result);
  2397. }
  2398. return result == Result.Success;
  2399. }
  2400. else
  2401. {
  2402. return false;
  2403. }
  2404. #endif
  2405. }
  2406. public static bool GetMixedRealityCameraInfo(int cameraId, out CameraExtrinsics cameraExtrinsics, out CameraIntrinsics cameraIntrinsics, out Posef calibrationRawPose)
  2407. {
  2408. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2409. cameraExtrinsics = default(CameraExtrinsics);
  2410. cameraIntrinsics = default(CameraIntrinsics);
  2411. calibrationRawPose = Posef.identity;
  2412. return false;
  2413. #else
  2414. cameraExtrinsics = default(CameraExtrinsics);
  2415. cameraIntrinsics = default(CameraIntrinsics);
  2416. calibrationRawPose = Posef.identity;
  2417. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2418. if (version >= OVRP_1_38_0.version) // MRC functions are invalid before 1.38.0
  2419. #else
  2420. if (version >= OVRP_1_15_0.version)
  2421. #endif
  2422. {
  2423. bool retValue = true;
  2424. Result result = OVRP_1_15_0.ovrp_GetExternalCameraExtrinsics(cameraId, out cameraExtrinsics);
  2425. if (result != Result.Success)
  2426. {
  2427. retValue = false;
  2428. //Debug.LogWarning("ovrp_GetExternalCameraExtrinsics return " + result);
  2429. }
  2430. result = OVRP_1_15_0.ovrp_GetExternalCameraIntrinsics(cameraId, out cameraIntrinsics);
  2431. if (result != Result.Success)
  2432. {
  2433. retValue = false;
  2434. //Debug.LogWarning("ovrp_GetExternalCameraIntrinsics return " + result);
  2435. }
  2436. #if OVRPLUGIN_INCLUDE_MRC_ANDROID
  2437. result = OVRP_1_38_0.ovrp_GetExternalCameraCalibrationRawPose(cameraId, out calibrationRawPose);
  2438. if (result != Result.Success)
  2439. {
  2440. retValue = false;
  2441. //Debug.LogWarning("ovrp_GetExternalCameraCalibrationRawPose return " + result);
  2442. }
  2443. #endif
  2444. return retValue;
  2445. }
  2446. else
  2447. {
  2448. return false;
  2449. }
  2450. #endif
  2451. }
  2452. public static bool OverrideExternalCameraFov(int cameraId, bool useOverriddenFov, Fovf fov)
  2453. {
  2454. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2455. return false;
  2456. #else
  2457. if (version >= OVRP_1_44_0.version)
  2458. {
  2459. bool retValue = true;
  2460. Result result = OVRP_1_44_0.ovrp_OverrideExternalCameraFov(cameraId, useOverriddenFov ? Bool.True : Bool.False, ref fov);
  2461. if (result != Result.Success)
  2462. {
  2463. retValue = false;
  2464. }
  2465. return retValue;
  2466. }
  2467. else
  2468. {
  2469. return false;
  2470. }
  2471. #endif
  2472. }
  2473. public static bool GetUseOverriddenExternalCameraFov(int cameraId)
  2474. {
  2475. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2476. return false;
  2477. #else
  2478. if (version >= OVRP_1_44_0.version)
  2479. {
  2480. bool retValue = true;
  2481. Bool useOverriddenFov = Bool.False;
  2482. Result result = OVRP_1_44_0.ovrp_GetUseOverriddenExternalCameraFov(cameraId, out useOverriddenFov);
  2483. if (result != Result.Success)
  2484. {
  2485. retValue = false;
  2486. }
  2487. if (useOverriddenFov == Bool.False)
  2488. {
  2489. retValue = false;
  2490. }
  2491. return retValue;
  2492. }
  2493. else
  2494. {
  2495. return false;
  2496. }
  2497. #endif
  2498. }
  2499. public static bool OverrideExternalCameraStaticPose(int cameraId, bool useOverriddenPose, Posef pose)
  2500. {
  2501. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2502. return false;
  2503. #else
  2504. if (version >= OVRP_1_44_0.version)
  2505. {
  2506. bool retValue = true;
  2507. Result result = OVRP_1_44_0.ovrp_OverrideExternalCameraStaticPose(cameraId, useOverriddenPose ? Bool.True : Bool.False, ref pose);
  2508. if (result != Result.Success)
  2509. {
  2510. retValue = false;
  2511. }
  2512. return retValue;
  2513. }
  2514. else
  2515. {
  2516. return false;
  2517. }
  2518. #endif
  2519. }
  2520. public static bool GetUseOverriddenExternalCameraStaticPose(int cameraId)
  2521. {
  2522. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2523. return false;
  2524. #else
  2525. if (version >= OVRP_1_44_0.version)
  2526. {
  2527. bool retValue = true;
  2528. Bool useOverriddenStaticPose = Bool.False;
  2529. Result result = OVRP_1_44_0.ovrp_GetUseOverriddenExternalCameraStaticPose(cameraId, out useOverriddenStaticPose);
  2530. if (result != Result.Success)
  2531. {
  2532. retValue = false;
  2533. }
  2534. if (useOverriddenStaticPose == Bool.False)
  2535. {
  2536. retValue = false;
  2537. }
  2538. return retValue;
  2539. }
  2540. else
  2541. {
  2542. return false;
  2543. }
  2544. #endif
  2545. }
  2546. public static bool ResetDefaultExternalCamera()
  2547. {
  2548. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2549. return false;
  2550. #else
  2551. if (version >= OVRP_1_44_0.version)
  2552. {
  2553. Result result = OVRP_1_44_0.ovrp_ResetDefaultExternalCamera();
  2554. if (result != Result.Success)
  2555. {
  2556. return false;
  2557. }
  2558. return true;
  2559. }
  2560. else
  2561. {
  2562. return false;
  2563. }
  2564. #endif
  2565. }
  2566. public static bool SetDefaultExternalCamera(string cameraName, ref CameraIntrinsics cameraIntrinsics, ref CameraExtrinsics cameraExtrinsics)
  2567. {
  2568. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2569. return false;
  2570. #else
  2571. if (version >= OVRP_1_44_0.version)
  2572. {
  2573. Result result = OVRP_1_44_0.ovrp_SetDefaultExternalCamera(cameraName, ref cameraIntrinsics, ref cameraExtrinsics);
  2574. if (result != Result.Success)
  2575. {
  2576. return false;
  2577. }
  2578. return true;
  2579. }
  2580. else
  2581. {
  2582. return false;
  2583. }
  2584. #endif
  2585. }
  2586. public static Vector3f GetBoundaryDimensions(BoundaryType boundaryType)
  2587. {
  2588. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2589. return new Vector3f();
  2590. #else
  2591. if (version >= OVRP_1_8_0.version)
  2592. {
  2593. return OVRP_1_8_0.ovrp_GetBoundaryDimensions(boundaryType);
  2594. }
  2595. else
  2596. {
  2597. return new Vector3f();
  2598. }
  2599. #endif
  2600. }
  2601. public static bool GetBoundaryVisible()
  2602. {
  2603. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2604. return false;
  2605. #else
  2606. if (version >= OVRP_1_8_0.version)
  2607. {
  2608. return OVRP_1_8_0.ovrp_GetBoundaryVisible() == OVRPlugin.Bool.True;
  2609. }
  2610. else
  2611. {
  2612. return false;
  2613. }
  2614. #endif
  2615. }
  2616. public static bool SetBoundaryVisible(bool value)
  2617. {
  2618. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2619. return false;
  2620. #else
  2621. if (version >= OVRP_1_8_0.version)
  2622. {
  2623. return OVRP_1_8_0.ovrp_SetBoundaryVisible(ToBool(value)) == OVRPlugin.Bool.True;
  2624. }
  2625. else
  2626. {
  2627. return false;
  2628. }
  2629. #endif
  2630. }
  2631. public static SystemHeadset GetSystemHeadsetType()
  2632. {
  2633. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2634. return SystemHeadset.None;
  2635. #else
  2636. if (version >= OVRP_1_9_0.version)
  2637. return OVRP_1_9_0.ovrp_GetSystemHeadsetType();
  2638. return SystemHeadset.None;
  2639. #endif
  2640. }
  2641. public static Controller GetActiveController()
  2642. {
  2643. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2644. return Controller.None;
  2645. #else
  2646. if (version >= OVRP_1_9_0.version)
  2647. return OVRP_1_9_0.ovrp_GetActiveController();
  2648. return Controller.None;
  2649. #endif
  2650. }
  2651. public static Controller GetConnectedControllers()
  2652. {
  2653. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2654. return Controller.None;
  2655. #else
  2656. if (version >= OVRP_1_9_0.version)
  2657. return OVRP_1_9_0.ovrp_GetConnectedControllers();
  2658. return Controller.None;
  2659. #endif
  2660. }
  2661. private static Bool ToBool(bool b)
  2662. {
  2663. return (b) ? OVRPlugin.Bool.True : OVRPlugin.Bool.False;
  2664. }
  2665. public static TrackingOrigin GetTrackingOriginType()
  2666. {
  2667. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2668. return default(TrackingOrigin);
  2669. #else
  2670. return OVRP_1_0_0.ovrp_GetTrackingOriginType();
  2671. #endif
  2672. }
  2673. public static bool SetTrackingOriginType(TrackingOrigin originType)
  2674. {
  2675. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2676. return false;
  2677. #else
  2678. return OVRP_1_0_0.ovrp_SetTrackingOriginType(originType) == Bool.True;
  2679. #endif
  2680. }
  2681. public static Posef GetTrackingCalibratedOrigin()
  2682. {
  2683. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2684. return Posef.identity;
  2685. #else
  2686. return OVRP_1_0_0.ovrp_GetTrackingCalibratedOrigin();
  2687. #endif
  2688. }
  2689. public static bool SetTrackingCalibratedOrigin()
  2690. {
  2691. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2692. return false;
  2693. #else
  2694. return OVRP_1_2_0.ovrpi_SetTrackingCalibratedOrigin() == Bool.True;
  2695. #endif
  2696. }
  2697. public static bool RecenterTrackingOrigin(RecenterFlags flags)
  2698. {
  2699. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2700. return false;
  2701. #else
  2702. return OVRP_1_0_0.ovrp_RecenterTrackingOrigin((uint)flags) == Bool.True;
  2703. #endif
  2704. }
  2705. #if UNITY_EDITOR || UNITY_STANDALONE_WIN
  2706. public static bool UpdateCameraDevices()
  2707. {
  2708. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2709. return false;
  2710. #else
  2711. if (version >= OVRP_1_16_0.version)
  2712. {
  2713. Result result = OVRP_1_16_0.ovrp_UpdateCameraDevices();
  2714. if (result != Result.Success)
  2715. {
  2716. //Debug.LogWarning("ovrp_UpdateCameraDevices return " + result);
  2717. }
  2718. return result == Result.Success;
  2719. }
  2720. else
  2721. {
  2722. return false;
  2723. }
  2724. #endif
  2725. }
  2726. public static bool IsCameraDeviceAvailable(CameraDevice cameraDevice)
  2727. {
  2728. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2729. return false;
  2730. #else
  2731. if (version >= OVRP_1_16_0.version)
  2732. {
  2733. Bool result = OVRP_1_16_0.ovrp_IsCameraDeviceAvailable(cameraDevice);
  2734. return result == Bool.True;
  2735. }
  2736. else
  2737. {
  2738. return false;
  2739. }
  2740. #endif
  2741. }
  2742. public static bool SetCameraDevicePreferredColorFrameSize(CameraDevice cameraDevice, int width, int height)
  2743. {
  2744. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2745. return false;
  2746. #else
  2747. if (version >= OVRP_1_16_0.version)
  2748. {
  2749. Sizei size = new Sizei();
  2750. size.w = width;
  2751. size.h = height;
  2752. Result result = OVRP_1_16_0.ovrp_SetCameraDevicePreferredColorFrameSize(cameraDevice, size);
  2753. if (result != Result.Success)
  2754. {
  2755. //Debug.LogWarning("ovrp_SetCameraDevicePreferredColorFrameSize return " + result);
  2756. }
  2757. return result == Result.Success;
  2758. }
  2759. else
  2760. {
  2761. return false;
  2762. }
  2763. #endif
  2764. }
  2765. public static bool OpenCameraDevice(CameraDevice cameraDevice)
  2766. {
  2767. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2768. return false;
  2769. #else
  2770. if (version >= OVRP_1_16_0.version)
  2771. {
  2772. Result result = OVRP_1_16_0.ovrp_OpenCameraDevice(cameraDevice);
  2773. if (result != Result.Success)
  2774. {
  2775. //Debug.LogWarning("ovrp_OpenCameraDevice return " + result);
  2776. }
  2777. return result == Result.Success;
  2778. }
  2779. else
  2780. {
  2781. return false;
  2782. }
  2783. #endif
  2784. }
  2785. public static bool CloseCameraDevice(CameraDevice cameraDevice)
  2786. {
  2787. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2788. return false;
  2789. #else
  2790. if (version >= OVRP_1_16_0.version)
  2791. {
  2792. Result result = OVRP_1_16_0.ovrp_CloseCameraDevice(cameraDevice);
  2793. if (result != Result.Success)
  2794. {
  2795. //Debug.LogWarning("ovrp_OpenCameraDevice return " + result);
  2796. }
  2797. return result == Result.Success;
  2798. }
  2799. else
  2800. {
  2801. return false;
  2802. }
  2803. #endif
  2804. }
  2805. public static bool HasCameraDeviceOpened(CameraDevice cameraDevice)
  2806. {
  2807. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2808. return false;
  2809. #else
  2810. if (version >= OVRP_1_16_0.version)
  2811. {
  2812. Bool result = OVRP_1_16_0.ovrp_HasCameraDeviceOpened(cameraDevice);
  2813. return result == Bool.True;
  2814. }
  2815. else
  2816. {
  2817. return false;
  2818. }
  2819. #endif
  2820. }
  2821. public static bool IsCameraDeviceColorFrameAvailable(CameraDevice cameraDevice)
  2822. {
  2823. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2824. return false;
  2825. #else
  2826. if (version >= OVRP_1_16_0.version)
  2827. {
  2828. Bool result = OVRP_1_16_0.ovrp_IsCameraDeviceColorFrameAvailable(cameraDevice);
  2829. return result == Bool.True;
  2830. }
  2831. else
  2832. {
  2833. return false;
  2834. }
  2835. #endif
  2836. }
  2837. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  2838. private static Texture2D cachedCameraFrameTexture = null;
  2839. #endif
  2840. public static Texture2D GetCameraDeviceColorFrameTexture(CameraDevice cameraDevice)
  2841. {
  2842. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2843. return null;
  2844. #else
  2845. if (version >= OVRP_1_16_0.version)
  2846. {
  2847. Sizei size = new Sizei();
  2848. Result result = OVRP_1_16_0.ovrp_GetCameraDeviceColorFrameSize(cameraDevice, out size);
  2849. if (result != Result.Success)
  2850. {
  2851. //Debug.LogWarning("ovrp_GetCameraDeviceColorFrameSize return " + result);
  2852. return null;
  2853. }
  2854. IntPtr pixels;
  2855. int rowPitch;
  2856. result = OVRP_1_16_0.ovrp_GetCameraDeviceColorFrameBgraPixels(cameraDevice, out pixels, out rowPitch);
  2857. if (result != Result.Success)
  2858. {
  2859. //Debug.LogWarning("ovrp_GetCameraDeviceColorFrameBgraPixels return " + result);
  2860. return null;
  2861. }
  2862. if (rowPitch != size.w * 4)
  2863. {
  2864. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  2865. return null;
  2866. }
  2867. if (!cachedCameraFrameTexture || cachedCameraFrameTexture.width != size.w || cachedCameraFrameTexture.height != size.h)
  2868. {
  2869. cachedCameraFrameTexture = new Texture2D(size.w, size.h, TextureFormat.BGRA32, false);
  2870. }
  2871. cachedCameraFrameTexture.LoadRawTextureData(pixels, rowPitch * size.h);
  2872. cachedCameraFrameTexture.Apply();
  2873. return cachedCameraFrameTexture;
  2874. }
  2875. else
  2876. {
  2877. return null;
  2878. }
  2879. #endif
  2880. }
  2881. public static bool DoesCameraDeviceSupportDepth(CameraDevice cameraDevice)
  2882. {
  2883. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2884. return false;
  2885. #else
  2886. if (version >= OVRP_1_17_0.version)
  2887. {
  2888. Bool supportDepth;
  2889. Result result = OVRP_1_17_0.ovrp_DoesCameraDeviceSupportDepth(cameraDevice, out supportDepth);
  2890. return result == Result.Success && supportDepth == Bool.True;
  2891. }
  2892. else
  2893. {
  2894. return false;
  2895. }
  2896. #endif
  2897. }
  2898. public static bool SetCameraDeviceDepthSensingMode(CameraDevice camera, CameraDeviceDepthSensingMode depthSensoringMode)
  2899. {
  2900. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2901. return false;
  2902. #else
  2903. if (version >= OVRP_1_17_0.version)
  2904. {
  2905. Result result = OVRP_1_17_0.ovrp_SetCameraDeviceDepthSensingMode(camera, depthSensoringMode);
  2906. return result == Result.Success;
  2907. }
  2908. else
  2909. {
  2910. return false;
  2911. }
  2912. #endif
  2913. }
  2914. public static bool SetCameraDevicePreferredDepthQuality(CameraDevice camera, CameraDeviceDepthQuality depthQuality)
  2915. {
  2916. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2917. return false;
  2918. #else
  2919. if (version >= OVRP_1_17_0.version)
  2920. {
  2921. Result result = OVRP_1_17_0.ovrp_SetCameraDevicePreferredDepthQuality(camera, depthQuality);
  2922. return result == Result.Success;
  2923. }
  2924. else
  2925. {
  2926. return false;
  2927. }
  2928. #endif
  2929. }
  2930. public static bool IsCameraDeviceDepthFrameAvailable(CameraDevice cameraDevice)
  2931. {
  2932. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2933. return false;
  2934. #else
  2935. if (version >= OVRP_1_17_0.version)
  2936. {
  2937. Bool available;
  2938. Result result = OVRP_1_17_0.ovrp_IsCameraDeviceDepthFrameAvailable(cameraDevice, out available);
  2939. return result == Result.Success && available == Bool.True;
  2940. }
  2941. else
  2942. {
  2943. return false;
  2944. }
  2945. #endif
  2946. }
  2947. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  2948. private static Texture2D cachedCameraDepthTexture = null;
  2949. #endif
  2950. public static Texture2D GetCameraDeviceDepthFrameTexture(CameraDevice cameraDevice)
  2951. {
  2952. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2953. return null;
  2954. #else
  2955. if (version >= OVRP_1_17_0.version)
  2956. {
  2957. Sizei size = new Sizei();
  2958. Result result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFrameSize(cameraDevice, out size);
  2959. if (result != Result.Success)
  2960. {
  2961. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFrameSize return " + result);
  2962. return null;
  2963. }
  2964. IntPtr depthData;
  2965. int rowPitch;
  2966. result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFramePixels(cameraDevice, out depthData, out rowPitch);
  2967. if (result != Result.Success)
  2968. {
  2969. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFramePixels return " + result);
  2970. return null;
  2971. }
  2972. if (rowPitch != size.w * 4)
  2973. {
  2974. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  2975. return null;
  2976. }
  2977. if (!cachedCameraDepthTexture || cachedCameraDepthTexture.width != size.w || cachedCameraDepthTexture.height != size.h)
  2978. {
  2979. cachedCameraDepthTexture = new Texture2D(size.w, size.h, TextureFormat.RFloat, false);
  2980. cachedCameraDepthTexture.filterMode = FilterMode.Point;
  2981. }
  2982. cachedCameraDepthTexture.LoadRawTextureData(depthData, rowPitch * size.h);
  2983. cachedCameraDepthTexture.Apply();
  2984. return cachedCameraDepthTexture;
  2985. }
  2986. else
  2987. {
  2988. return null;
  2989. }
  2990. #endif
  2991. }
  2992. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  2993. private static Texture2D cachedCameraDepthConfidenceTexture = null;
  2994. #endif
  2995. public static Texture2D GetCameraDeviceDepthConfidenceTexture(CameraDevice cameraDevice)
  2996. {
  2997. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2998. return null;
  2999. #else
  3000. if (version >= OVRP_1_17_0.version)
  3001. {
  3002. Sizei size = new Sizei();
  3003. Result result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFrameSize(cameraDevice, out size);
  3004. if (result != Result.Success)
  3005. {
  3006. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFrameSize return " + result);
  3007. return null;
  3008. }
  3009. IntPtr confidenceData;
  3010. int rowPitch;
  3011. result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthConfidencePixels(cameraDevice, out confidenceData, out rowPitch);
  3012. if (result != Result.Success)
  3013. {
  3014. //Debug.LogWarning("ovrp_GetCameraDeviceDepthConfidencePixels return " + result);
  3015. return null;
  3016. }
  3017. if (rowPitch != size.w * 4)
  3018. {
  3019. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  3020. return null;
  3021. }
  3022. if (!cachedCameraDepthConfidenceTexture || cachedCameraDepthConfidenceTexture.width != size.w || cachedCameraDepthConfidenceTexture.height != size.h)
  3023. {
  3024. cachedCameraDepthConfidenceTexture = new Texture2D(size.w, size.h, TextureFormat.RFloat, false);
  3025. }
  3026. cachedCameraDepthConfidenceTexture.LoadRawTextureData(confidenceData, rowPitch * size.h);
  3027. cachedCameraDepthConfidenceTexture.Apply();
  3028. return cachedCameraDepthConfidenceTexture;
  3029. }
  3030. else
  3031. {
  3032. return null;
  3033. }
  3034. #endif
  3035. }
  3036. #endif
  3037. public static bool fixedFoveatedRenderingSupported
  3038. {
  3039. get
  3040. {
  3041. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3042. return false;
  3043. #else
  3044. if (version >= OVRP_1_21_0.version)
  3045. {
  3046. Bool supported;
  3047. Result result = OVRP_1_21_0.ovrp_GetTiledMultiResSupported(out supported);
  3048. if (result == Result.Success)
  3049. {
  3050. return supported == Bool.True;
  3051. }
  3052. else
  3053. {
  3054. //Debug.LogWarning("ovrp_GetTiledMultiResSupported return " + result);
  3055. return false;
  3056. }
  3057. }
  3058. else
  3059. {
  3060. return false;
  3061. }
  3062. #endif
  3063. }
  3064. }
  3065. public static FixedFoveatedRenderingLevel fixedFoveatedRenderingLevel
  3066. {
  3067. get
  3068. {
  3069. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3070. return FixedFoveatedRenderingLevel.Off;
  3071. #else
  3072. if (version >= OVRP_1_21_0.version && fixedFoveatedRenderingSupported)
  3073. {
  3074. FixedFoveatedRenderingLevel level;
  3075. Result result = OVRP_1_21_0.ovrp_GetTiledMultiResLevel(out level);
  3076. if (result != Result.Success)
  3077. {
  3078. //Debug.LogWarning("ovrp_GetTiledMultiResLevel return " + result);
  3079. }
  3080. return level;
  3081. }
  3082. else
  3083. {
  3084. return FixedFoveatedRenderingLevel.Off;
  3085. }
  3086. #endif
  3087. }
  3088. set
  3089. {
  3090. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3091. return;
  3092. #else
  3093. if (version >= OVRP_1_21_0.version && fixedFoveatedRenderingSupported)
  3094. {
  3095. Result result = OVRP_1_21_0.ovrp_SetTiledMultiResLevel(value);
  3096. if (result != Result.Success)
  3097. {
  3098. //Debug.LogWarning("ovrp_SetTiledMultiResLevel return " + result);
  3099. }
  3100. }
  3101. #endif
  3102. }
  3103. }
  3104. public static bool useDynamicFixedFoveatedRendering
  3105. {
  3106. get
  3107. {
  3108. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3109. return false;
  3110. #else
  3111. if (version >= OVRP_1_46_0.version && fixedFoveatedRenderingSupported)
  3112. {
  3113. Bool isDynamic = Bool.False;
  3114. Result result = OVRP_1_46_0.ovrp_GetTiledMultiResDynamic(out isDynamic);
  3115. if (result != Result.Success)
  3116. {
  3117. //Debug.LogWarning("ovrp_GetTiledMultiResDynamic return " + result);
  3118. }
  3119. return isDynamic != Bool.False;
  3120. }
  3121. else
  3122. {
  3123. return false;
  3124. }
  3125. #endif
  3126. }
  3127. set
  3128. {
  3129. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3130. return;
  3131. #else
  3132. if (version >= OVRP_1_46_0.version && fixedFoveatedRenderingSupported)
  3133. {
  3134. Result result = OVRP_1_46_0.ovrp_SetTiledMultiResDynamic(value ? Bool.True : Bool.False);
  3135. if (result != Result.Success)
  3136. {
  3137. //Debug.LogWarning("ovrp_SetTiledMultiResDynamic return " + result);
  3138. }
  3139. }
  3140. #endif
  3141. }
  3142. }
  3143. [Obsolete("Please use fixedFoveatedRenderingSupported instead", false)]
  3144. public static bool tiledMultiResSupported
  3145. {
  3146. get
  3147. {
  3148. return fixedFoveatedRenderingSupported;
  3149. }
  3150. }
  3151. [Obsolete("Please use fixedFoveatedRenderingLevel instead", false)]
  3152. public static TiledMultiResLevel tiledMultiResLevel
  3153. {
  3154. get
  3155. {
  3156. return (TiledMultiResLevel)fixedFoveatedRenderingLevel;
  3157. }
  3158. set
  3159. {
  3160. fixedFoveatedRenderingLevel = (FixedFoveatedRenderingLevel)value;
  3161. }
  3162. }
  3163. public static bool gpuUtilSupported
  3164. {
  3165. get
  3166. {
  3167. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3168. return false;
  3169. #else
  3170. if (version >= OVRP_1_21_0.version)
  3171. {
  3172. Bool supported;
  3173. Result result = OVRP_1_21_0.ovrp_GetGPUUtilSupported(out supported);
  3174. if (result == Result.Success)
  3175. {
  3176. return supported == Bool.True;
  3177. }
  3178. else
  3179. {
  3180. //Debug.LogWarning("ovrp_GetGPUUtilSupported return " + result);
  3181. return false;
  3182. }
  3183. }
  3184. else
  3185. {
  3186. return false;
  3187. }
  3188. #endif
  3189. }
  3190. }
  3191. public static float gpuUtilLevel
  3192. {
  3193. get
  3194. {
  3195. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3196. return 0.0f;
  3197. #else
  3198. if (version >= OVRP_1_21_0.version && gpuUtilSupported)
  3199. {
  3200. float level;
  3201. Result result = OVRP_1_21_0.ovrp_GetGPUUtilLevel(out level);
  3202. if (result == Result.Success)
  3203. {
  3204. return level;
  3205. }
  3206. else
  3207. {
  3208. //Debug.LogWarning("ovrp_GetGPUUtilLevel return " + result);
  3209. return 0.0f;
  3210. }
  3211. }
  3212. else
  3213. {
  3214. return 0.0f;
  3215. }
  3216. #endif
  3217. }
  3218. }
  3219. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  3220. private static OVRNativeBuffer _nativeSystemDisplayFrequenciesAvailable = null;
  3221. private static float[] _cachedSystemDisplayFrequenciesAvailable = null;
  3222. #endif
  3223. public static float[] systemDisplayFrequenciesAvailable
  3224. {
  3225. get
  3226. {
  3227. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3228. return new float[0];
  3229. #else
  3230. if (_cachedSystemDisplayFrequenciesAvailable == null)
  3231. {
  3232. _cachedSystemDisplayFrequenciesAvailable = new float[0];
  3233. if (version >= OVRP_1_21_0.version)
  3234. {
  3235. int numFrequencies = 0;
  3236. Result result = OVRP_1_21_0.ovrp_GetSystemDisplayAvailableFrequencies(IntPtr.Zero, ref numFrequencies);
  3237. if (result == Result.Success)
  3238. {
  3239. if (numFrequencies > 0)
  3240. {
  3241. int maxNumElements = numFrequencies;
  3242. _nativeSystemDisplayFrequenciesAvailable = new OVRNativeBuffer(sizeof(float) * maxNumElements);
  3243. result = OVRP_1_21_0.ovrp_GetSystemDisplayAvailableFrequencies(_nativeSystemDisplayFrequenciesAvailable.GetPointer(), ref numFrequencies);
  3244. if (result == Result.Success)
  3245. {
  3246. int numElementsToCopy = (numFrequencies <= maxNumElements) ? numFrequencies : maxNumElements;
  3247. if (numElementsToCopy > 0)
  3248. {
  3249. _cachedSystemDisplayFrequenciesAvailable = new float[numElementsToCopy];
  3250. Marshal.Copy(_nativeSystemDisplayFrequenciesAvailable.GetPointer(), _cachedSystemDisplayFrequenciesAvailable, 0, numElementsToCopy);
  3251. }
  3252. }
  3253. }
  3254. }
  3255. }
  3256. }
  3257. return _cachedSystemDisplayFrequenciesAvailable;
  3258. #endif
  3259. }
  3260. }
  3261. public static float systemDisplayFrequency
  3262. {
  3263. get
  3264. {
  3265. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3266. return 0.0f;
  3267. #else
  3268. if (version >= OVRP_1_21_0.version)
  3269. {
  3270. float displayFrequency;
  3271. Result result = OVRP_1_21_0.ovrp_GetSystemDisplayFrequency2(out displayFrequency);
  3272. if (result == Result.Success)
  3273. {
  3274. return displayFrequency;
  3275. }
  3276. return 0.0f;
  3277. }
  3278. else if (version >= OVRP_1_1_0.version)
  3279. {
  3280. return OVRP_1_1_0.ovrp_GetSystemDisplayFrequency();
  3281. }
  3282. else
  3283. {
  3284. return 0.0f;
  3285. }
  3286. #endif
  3287. }
  3288. set
  3289. {
  3290. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3291. return;
  3292. #else
  3293. if (version >= OVRP_1_21_0.version)
  3294. {
  3295. OVRP_1_21_0.ovrp_SetSystemDisplayFrequency(value);
  3296. }
  3297. #endif
  3298. }
  3299. }
  3300. public static bool GetNodeFrustum2(Node nodeId, out Frustumf2 frustum)
  3301. {
  3302. frustum = default(Frustumf2);
  3303. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3304. return false;
  3305. #else
  3306. if (version >= OVRP_1_15_0.version)
  3307. {
  3308. Result result = OVRP_1_15_0.ovrp_GetNodeFrustum2(nodeId, out frustum);
  3309. if (result != Result.Success)
  3310. {
  3311. return false;
  3312. }
  3313. else
  3314. {
  3315. return true;
  3316. }
  3317. }
  3318. else
  3319. {
  3320. return false;
  3321. }
  3322. #endif
  3323. }
  3324. public static bool AsymmetricFovEnabled
  3325. {
  3326. get
  3327. {
  3328. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3329. return false;
  3330. #else
  3331. if (version >= OVRP_1_21_0.version)
  3332. {
  3333. Bool asymmetricFovEnabled = Bool.False;
  3334. Result result = OVRP_1_21_0.ovrp_GetAppAsymmetricFov(out asymmetricFovEnabled);
  3335. if (result != Result.Success)
  3336. {
  3337. return false;
  3338. }
  3339. else
  3340. {
  3341. return asymmetricFovEnabled == Bool.True;
  3342. }
  3343. }
  3344. else
  3345. {
  3346. return false;
  3347. }
  3348. #endif
  3349. }
  3350. }
  3351. public static bool EyeTextureArrayEnabled
  3352. {
  3353. get
  3354. {
  3355. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3356. return false;
  3357. #else
  3358. if (version >= OVRP_1_15_0.version)
  3359. {
  3360. Bool enabled = Bool.False;
  3361. enabled = OVRP_1_15_0.ovrp_GetEyeTextureArrayEnabled();
  3362. return enabled == Bool.True;
  3363. }
  3364. else
  3365. {
  3366. return false;
  3367. }
  3368. #endif
  3369. }
  3370. }
  3371. public static Handedness GetDominantHand()
  3372. {
  3373. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3374. return Handedness.Unsupported;
  3375. #else
  3376. Handedness dominantHand;
  3377. if (version >= OVRP_1_28_0.version && OVRP_1_28_0.ovrp_GetDominantHand(out dominantHand) == Result.Success)
  3378. {
  3379. return dominantHand;
  3380. }
  3381. return Handedness.Unsupported;
  3382. #endif
  3383. }
  3384. public static bool GetReorientHMDOnControllerRecenter()
  3385. {
  3386. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3387. return false;
  3388. #else
  3389. Bool recenterMode;
  3390. if (version < OVRP_1_28_0.version || OVRP_1_28_0.ovrp_GetReorientHMDOnControllerRecenter(out recenterMode) != Result.Success)
  3391. return false;
  3392. return (recenterMode == Bool.True);
  3393. #endif
  3394. }
  3395. public static bool SetReorientHMDOnControllerRecenter(bool recenterSetting)
  3396. {
  3397. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3398. return false;
  3399. #else
  3400. Bool ovrpBoolRecenterSetting = recenterSetting ? Bool.True : Bool.False;
  3401. if (version < OVRP_1_28_0.version || OVRP_1_28_0.ovrp_SetReorientHMDOnControllerRecenter(ovrpBoolRecenterSetting) != Result.Success)
  3402. return false;
  3403. return true;
  3404. #endif
  3405. }
  3406. public static bool SendEvent(string name, string param = "", string source = "")
  3407. {
  3408. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3409. return false;
  3410. #else
  3411. if (version >= OVRP_1_30_0.version)
  3412. {
  3413. return OVRP_1_30_0.ovrp_SendEvent2(name, param, source.Length == 0 ? "integration": source) == Result.Success;
  3414. }
  3415. else if (version >= OVRP_1_28_0.version)
  3416. {
  3417. return OVRP_1_28_0.ovrp_SendEvent(name, param) == Result.Success;
  3418. }
  3419. else
  3420. {
  3421. return false;
  3422. }
  3423. #endif
  3424. }
  3425. public static bool SetHeadPoseModifier(ref Quatf relativeRotation, ref Vector3f relativeTranslation)
  3426. {
  3427. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3428. return false;
  3429. #else
  3430. if (version >= OVRP_1_29_0.version)
  3431. {
  3432. return OVRP_1_29_0.ovrp_SetHeadPoseModifier(ref relativeRotation, ref relativeTranslation) == Result.Success;
  3433. }
  3434. else
  3435. {
  3436. return false;
  3437. }
  3438. #endif
  3439. }
  3440. public static bool GetHeadPoseModifier(out Quatf relativeRotation, out Vector3f relativeTranslation)
  3441. {
  3442. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3443. relativeRotation = Quatf.identity;
  3444. relativeTranslation = Vector3f.zero;
  3445. return false;
  3446. #else
  3447. if (version >= OVRP_1_29_0.version)
  3448. {
  3449. return OVRP_1_29_0.ovrp_GetHeadPoseModifier(out relativeRotation, out relativeTranslation) == Result.Success;
  3450. }
  3451. else
  3452. {
  3453. relativeRotation = Quatf.identity;
  3454. relativeTranslation = Vector3f.zero;
  3455. return false;
  3456. }
  3457. #endif
  3458. }
  3459. public static bool IsPerfMetricsSupported(PerfMetrics perfMetrics)
  3460. {
  3461. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3462. return false;
  3463. #else
  3464. if (version >= OVRP_1_30_0.version)
  3465. {
  3466. Bool isSupported;
  3467. Result result = OVRP_1_30_0.ovrp_IsPerfMetricsSupported(perfMetrics, out isSupported);
  3468. if (result == Result.Success)
  3469. {
  3470. return isSupported == Bool.True;
  3471. }
  3472. else
  3473. {
  3474. return false;
  3475. }
  3476. }
  3477. else
  3478. {
  3479. return false;
  3480. }
  3481. #endif
  3482. }
  3483. public static float? GetPerfMetricsFloat(PerfMetrics perfMetrics)
  3484. {
  3485. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3486. return null;
  3487. #else
  3488. if (version >= OVRP_1_30_0.version)
  3489. {
  3490. float value;
  3491. Result result = OVRP_1_30_0.ovrp_GetPerfMetricsFloat(perfMetrics, out value);
  3492. if (result == Result.Success)
  3493. {
  3494. return value;
  3495. }
  3496. else
  3497. {
  3498. return null;
  3499. }
  3500. }
  3501. else
  3502. {
  3503. return null;
  3504. }
  3505. #endif
  3506. }
  3507. public static int? GetPerfMetricsInt(PerfMetrics perfMetrics)
  3508. {
  3509. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3510. return null;
  3511. #else
  3512. if (version >= OVRP_1_30_0.version)
  3513. {
  3514. int value;
  3515. Result result = OVRP_1_30_0.ovrp_GetPerfMetricsInt(perfMetrics, out value);
  3516. if (result == Result.Success)
  3517. {
  3518. return value;
  3519. }
  3520. else
  3521. {
  3522. return null;
  3523. }
  3524. }
  3525. else
  3526. {
  3527. return null;
  3528. }
  3529. #endif
  3530. }
  3531. public static double GetTimeInSeconds()
  3532. {
  3533. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3534. return 0.0;
  3535. #else
  3536. if (version >= OVRP_1_31_0.version)
  3537. {
  3538. double value;
  3539. Result result = OVRP_1_31_0.ovrp_GetTimeInSeconds(out value);
  3540. if (result == Result.Success)
  3541. {
  3542. return value;
  3543. }
  3544. else
  3545. {
  3546. return 0.0;
  3547. }
  3548. }
  3549. else
  3550. {
  3551. return 0.0;
  3552. }
  3553. #endif
  3554. }
  3555. public static bool SetColorScaleAndOffset(Vector4 colorScale, Vector4 colorOffset, bool applyToAllLayers)
  3556. {
  3557. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3558. return false;
  3559. #else
  3560. #if USING_XR_SDK
  3561. OculusXRPlugin.SetColorScale(colorScale.x, colorScale.y, colorScale.z, colorScale.w);
  3562. OculusXRPlugin.SetColorOffset(colorOffset.x, colorOffset.y, colorOffset.z, colorOffset.w);
  3563. return true;
  3564. #else
  3565. if (version >= OVRP_1_31_0.version)
  3566. {
  3567. Bool ovrpApplyToAllLayers = applyToAllLayers ? Bool.True : Bool.False;
  3568. return OVRP_1_31_0.ovrp_SetColorScaleAndOffset(colorScale, colorOffset, ovrpApplyToAllLayers) == Result.Success;
  3569. }
  3570. else
  3571. {
  3572. return false;
  3573. }
  3574. #endif
  3575. #endif
  3576. }
  3577. public static bool AddCustomMetadata(string name, string param = "")
  3578. {
  3579. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3580. return false;
  3581. #else
  3582. if (version >= OVRP_1_32_0.version)
  3583. {
  3584. return OVRP_1_32_0.ovrp_AddCustomMetadata(name, param) == Result.Success;
  3585. }
  3586. else
  3587. {
  3588. return false;
  3589. }
  3590. #endif
  3591. }
  3592. public class Media
  3593. {
  3594. public enum MrcActivationMode
  3595. {
  3596. Automatic = 0,
  3597. Disabled = 1,
  3598. EnumSize = 0x7fffffff
  3599. }
  3600. public enum InputVideoBufferType
  3601. {
  3602. Memory = 0,
  3603. TextureHandle = 1,
  3604. EnumSize = 0x7fffffff
  3605. }
  3606. public static bool Initialize()
  3607. {
  3608. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3609. return false;
  3610. #else
  3611. if (version >= OVRP_1_38_0.version)
  3612. {
  3613. return OVRP_1_38_0.ovrp_Media_Initialize() == Result.Success;
  3614. }
  3615. else
  3616. {
  3617. return false;
  3618. }
  3619. #endif
  3620. }
  3621. public static bool Shutdown()
  3622. {
  3623. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3624. return false;
  3625. #else
  3626. if (version >= OVRP_1_38_0.version)
  3627. {
  3628. return OVRP_1_38_0.ovrp_Media_Shutdown() == Result.Success;
  3629. }
  3630. else
  3631. {
  3632. return false;
  3633. }
  3634. #endif
  3635. }
  3636. public static bool GetInitialized()
  3637. {
  3638. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3639. return false;
  3640. #else
  3641. if (version >= OVRP_1_38_0.version)
  3642. {
  3643. Bool initialized = Bool.False;
  3644. Result result = OVRP_1_38_0.ovrp_Media_GetInitialized(out initialized);
  3645. if (result == Result.Success)
  3646. {
  3647. return initialized == Bool.True ? true : false;
  3648. }
  3649. else
  3650. {
  3651. return false;
  3652. }
  3653. }
  3654. else
  3655. {
  3656. return false;
  3657. }
  3658. #endif
  3659. }
  3660. public static bool Update()
  3661. {
  3662. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3663. return false;
  3664. #else
  3665. if (version >= OVRP_1_38_0.version)
  3666. {
  3667. return OVRP_1_38_0.ovrp_Media_Update() == Result.Success;
  3668. }
  3669. else
  3670. {
  3671. return false;
  3672. }
  3673. #endif
  3674. }
  3675. public static MrcActivationMode GetMrcActivationMode()
  3676. {
  3677. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3678. return MrcActivationMode.Disabled;
  3679. #else
  3680. if (version >= OVRP_1_38_0.version)
  3681. {
  3682. MrcActivationMode mode;
  3683. if (OVRP_1_38_0.ovrp_Media_GetMrcActivationMode(out mode) == Result.Success)
  3684. {
  3685. return mode;
  3686. }
  3687. else
  3688. {
  3689. return default(MrcActivationMode);
  3690. }
  3691. }
  3692. else
  3693. {
  3694. return default(MrcActivationMode);
  3695. }
  3696. #endif
  3697. }
  3698. public static bool SetMrcActivationMode(MrcActivationMode mode)
  3699. {
  3700. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3701. return false;
  3702. #else
  3703. if (version >= OVRP_1_38_0.version)
  3704. {
  3705. return OVRP_1_38_0.ovrp_Media_SetMrcActivationMode(mode) == Result.Success;
  3706. }
  3707. else
  3708. {
  3709. return false;
  3710. }
  3711. #endif
  3712. }
  3713. public static bool IsMrcEnabled()
  3714. {
  3715. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3716. return false;
  3717. #else
  3718. if (version >= OVRP_1_38_0.version)
  3719. {
  3720. Bool b;
  3721. if (OVRP_1_38_0.ovrp_Media_IsMrcEnabled(out b) == Result.Success)
  3722. {
  3723. return b == Bool.True ? true : false;
  3724. }
  3725. else
  3726. {
  3727. return false;
  3728. }
  3729. }
  3730. else
  3731. {
  3732. return false;
  3733. }
  3734. #endif
  3735. }
  3736. public static bool IsMrcActivated()
  3737. {
  3738. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3739. return false;
  3740. #else
  3741. if (version >= OVRP_1_38_0.version)
  3742. {
  3743. Bool b;
  3744. if (OVRP_1_38_0.ovrp_Media_IsMrcActivated(out b) == Result.Success)
  3745. {
  3746. return b == Bool.True ? true : false;
  3747. }
  3748. else
  3749. {
  3750. return false;
  3751. }
  3752. }
  3753. else
  3754. {
  3755. return false;
  3756. }
  3757. #endif
  3758. }
  3759. public static bool UseMrcDebugCamera()
  3760. {
  3761. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3762. return false;
  3763. #else
  3764. if (version >= OVRP_1_38_0.version)
  3765. {
  3766. Bool b;
  3767. if (OVRP_1_38_0.ovrp_Media_UseMrcDebugCamera(out b) == Result.Success)
  3768. {
  3769. return b == Bool.True ? true : false;
  3770. }
  3771. else
  3772. {
  3773. return false;
  3774. }
  3775. }
  3776. else
  3777. {
  3778. return false;
  3779. }
  3780. #endif
  3781. }
  3782. public static bool SetMrcInputVideoBufferType(InputVideoBufferType videoBufferType)
  3783. {
  3784. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3785. return false;
  3786. #else
  3787. if (version >= OVRP_1_38_0.version)
  3788. {
  3789. if (OVRP_1_38_0.ovrp_Media_SetMrcInputVideoBufferType(videoBufferType) == Result.Success)
  3790. {
  3791. return true;
  3792. }
  3793. else
  3794. {
  3795. return false;
  3796. }
  3797. }
  3798. else
  3799. {
  3800. return false;
  3801. }
  3802. #endif
  3803. }
  3804. public static InputVideoBufferType GetMrcInputVideoBufferType()
  3805. {
  3806. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3807. return InputVideoBufferType.Memory;
  3808. #else
  3809. if (version >= OVRP_1_38_0.version)
  3810. {
  3811. InputVideoBufferType videoBufferType = InputVideoBufferType.Memory;
  3812. OVRP_1_38_0.ovrp_Media_GetMrcInputVideoBufferType(ref videoBufferType);
  3813. return videoBufferType;
  3814. }
  3815. else
  3816. {
  3817. return InputVideoBufferType.Memory;
  3818. }
  3819. #endif
  3820. }
  3821. public static bool SetMrcFrameSize(int frameWidth, int frameHeight)
  3822. {
  3823. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3824. return false;
  3825. #else
  3826. if (version >= OVRP_1_38_0.version)
  3827. {
  3828. if (OVRP_1_38_0.ovrp_Media_SetMrcFrameSize(frameWidth, frameHeight) == Result.Success)
  3829. {
  3830. return true;
  3831. }
  3832. else
  3833. {
  3834. return false;
  3835. }
  3836. }
  3837. else
  3838. {
  3839. return false;
  3840. }
  3841. #endif
  3842. }
  3843. public static void GetMrcFrameSize(out int frameWidth, out int frameHeight)
  3844. {
  3845. frameWidth = -1;
  3846. frameHeight = -1;
  3847. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  3848. if (version >= OVRP_1_38_0.version)
  3849. {
  3850. OVRP_1_38_0.ovrp_Media_GetMrcFrameSize(ref frameWidth, ref frameHeight);
  3851. }
  3852. #endif
  3853. }
  3854. public static bool SetMrcAudioSampleRate(int sampleRate)
  3855. {
  3856. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3857. return false;
  3858. #else
  3859. if (version >= OVRP_1_38_0.version)
  3860. {
  3861. if (OVRP_1_38_0.ovrp_Media_SetMrcAudioSampleRate(sampleRate) == Result.Success)
  3862. {
  3863. return true;
  3864. }
  3865. else
  3866. {
  3867. return false;
  3868. }
  3869. }
  3870. else
  3871. {
  3872. return false;
  3873. }
  3874. #endif
  3875. }
  3876. public static int GetMrcAudioSampleRate()
  3877. {
  3878. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3879. return 0;
  3880. #else
  3881. int sampleRate = 0;
  3882. if (version >= OVRP_1_38_0.version)
  3883. {
  3884. OVRP_1_38_0.ovrp_Media_GetMrcAudioSampleRate(ref sampleRate);
  3885. }
  3886. return sampleRate;
  3887. #endif
  3888. }
  3889. public static bool SetMrcFrameImageFlipped(bool imageFlipped)
  3890. {
  3891. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3892. return false;
  3893. #else
  3894. if (version >= OVRP_1_38_0.version)
  3895. {
  3896. Bool flipped = imageFlipped ? Bool.True : Bool.False;
  3897. if (OVRP_1_38_0.ovrp_Media_SetMrcFrameImageFlipped(flipped) == Result.Success)
  3898. {
  3899. return true;
  3900. }
  3901. else
  3902. {
  3903. return false;
  3904. }
  3905. }
  3906. else
  3907. {
  3908. return false;
  3909. }
  3910. #endif
  3911. }
  3912. public static bool GetMrcFrameImageFlipped()
  3913. {
  3914. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3915. return false;
  3916. #else
  3917. Bool flipped = 0;
  3918. if (version >= OVRP_1_38_0.version)
  3919. {
  3920. OVRP_1_38_0.ovrp_Media_GetMrcFrameImageFlipped(ref flipped);
  3921. }
  3922. return flipped == Bool.True ? true : false;
  3923. #endif
  3924. }
  3925. public static bool EncodeMrcFrame(System.IntPtr textureHandle, float[] audioData, int audioFrames, int audioChannels, double timestamp, ref int outSyncId)
  3926. {
  3927. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3928. return false;
  3929. #else
  3930. if (version >= OVRP_1_38_0.version)
  3931. {
  3932. if (textureHandle == System.IntPtr.Zero)
  3933. {
  3934. Debug.LogError("EncodeMrcFrame: textureHandle is null");
  3935. return false;
  3936. }
  3937. InputVideoBufferType videoBufferType = GetMrcInputVideoBufferType();
  3938. if (videoBufferType != InputVideoBufferType.TextureHandle)
  3939. {
  3940. Debug.LogError("EncodeMrcFrame: videoBufferType mismatch");
  3941. return false;
  3942. }
  3943. GCHandle pinnedAudioData = new GCHandle();
  3944. IntPtr audioDataPtr = IntPtr.Zero;
  3945. int audioDataLen = 0;
  3946. if (audioData != null)
  3947. {
  3948. pinnedAudioData = GCHandle.Alloc(audioData, GCHandleType.Pinned);
  3949. audioDataPtr = pinnedAudioData.AddrOfPinnedObject();
  3950. audioDataLen = audioFrames * 4;
  3951. }
  3952. Result result = OVRP_1_38_0.ovrp_Media_EncodeMrcFrame(textureHandle, audioDataPtr, audioDataLen, audioChannels, timestamp, ref outSyncId);
  3953. if (audioData != null)
  3954. {
  3955. pinnedAudioData.Free();
  3956. }
  3957. return result == Result.Success;
  3958. }
  3959. else
  3960. {
  3961. return false;
  3962. }
  3963. #endif
  3964. }
  3965. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  3966. static Texture2D cachedTexture = null;
  3967. #endif
  3968. public static bool EncodeMrcFrame(RenderTexture frame, float[] audioData, int audioFrames, int audioChannels, double timestamp, ref int outSyncId)
  3969. {
  3970. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  3971. return false;
  3972. #else
  3973. if (version >= OVRP_1_38_0.version)
  3974. {
  3975. if (frame == null)
  3976. {
  3977. Debug.LogError("EncodeMrcFrame: frame is null");
  3978. return false;
  3979. }
  3980. InputVideoBufferType videoBufferType = GetMrcInputVideoBufferType();
  3981. if (videoBufferType != InputVideoBufferType.Memory)
  3982. {
  3983. Debug.LogError("EncodeMrcFrame: videoBufferType mismatch");
  3984. return false;
  3985. }
  3986. GCHandle pinnedArray = new GCHandle();
  3987. IntPtr pointer = IntPtr.Zero;
  3988. if (cachedTexture == null || cachedTexture.width != frame.width || cachedTexture.height != frame.height)
  3989. {
  3990. cachedTexture = new Texture2D(frame.width, frame.height, TextureFormat.ARGB32, false);
  3991. }
  3992. RenderTexture lastActive = RenderTexture.active;
  3993. RenderTexture.active = frame;
  3994. cachedTexture.ReadPixels(new Rect(0, 0, frame.width, frame.height), 0, 0);
  3995. RenderTexture.active = lastActive;
  3996. Color32[] bytes = cachedTexture.GetPixels32(0);
  3997. pinnedArray = GCHandle.Alloc(bytes, GCHandleType.Pinned);
  3998. pointer = pinnedArray.AddrOfPinnedObject();
  3999. GCHandle pinnedAudioData = new GCHandle();
  4000. IntPtr audioDataPtr = IntPtr.Zero;
  4001. int audioDataLen = 0;
  4002. if (audioData != null)
  4003. {
  4004. pinnedAudioData = GCHandle.Alloc(audioData, GCHandleType.Pinned);
  4005. audioDataPtr = pinnedAudioData.AddrOfPinnedObject();
  4006. audioDataLen = audioFrames * 4;
  4007. }
  4008. Result result = OVRP_1_38_0.ovrp_Media_EncodeMrcFrame(pointer, audioDataPtr, audioDataLen, audioChannels, timestamp, ref outSyncId);
  4009. pinnedArray.Free();
  4010. if (audioData != null)
  4011. {
  4012. pinnedAudioData.Free();
  4013. }
  4014. return result == Result.Success;
  4015. }
  4016. else
  4017. {
  4018. return false;
  4019. }
  4020. #endif
  4021. }
  4022. public static bool SyncMrcFrame(int syncId)
  4023. {
  4024. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4025. return false;
  4026. #else
  4027. if (version >= OVRP_1_38_0.version)
  4028. {
  4029. return OVRP_1_38_0.ovrp_Media_SyncMrcFrame(syncId) == Result.Success;
  4030. }
  4031. else
  4032. {
  4033. return false;
  4034. }
  4035. #endif
  4036. }
  4037. }
  4038. public static bool SetDeveloperMode(Bool active)
  4039. {
  4040. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4041. return false;
  4042. #else
  4043. if(version >= OVRP_1_38_0.version)
  4044. {
  4045. return OVRP_1_38_0.ovrp_SetDeveloperMode(active) == Result.Success;
  4046. }
  4047. else
  4048. {
  4049. return false;
  4050. }
  4051. #endif
  4052. }
  4053. public static float GetAdaptiveGPUPerformanceScale()
  4054. {
  4055. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4056. return 1.0f;
  4057. #else
  4058. if (version >= OVRP_1_42_0.version)
  4059. {
  4060. float adaptiveScale = 1.0f;
  4061. if (OVRP_1_42_0.ovrp_GetAdaptiveGpuPerformanceScale2(ref adaptiveScale) == Result.Success)
  4062. {
  4063. return adaptiveScale;
  4064. }
  4065. return 1.0f;
  4066. }
  4067. else
  4068. {
  4069. return 1.0f;
  4070. }
  4071. #endif
  4072. }
  4073. public static bool GetHandTrackingEnabled()
  4074. {
  4075. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4076. return false;
  4077. #else
  4078. if (version >= OVRP_1_44_0.version)
  4079. {
  4080. Bool val = OVRPlugin.Bool.False;
  4081. Result res = OVRP_1_44_0.ovrp_GetHandTrackingEnabled(ref val);
  4082. if (res == Result.Success)
  4083. {
  4084. return val == OVRPlugin.Bool.True;
  4085. }
  4086. return false;
  4087. }
  4088. else
  4089. {
  4090. return false;
  4091. }
  4092. #endif
  4093. }
  4094. private static HandStateInternal cachedHandState = new HandStateInternal();
  4095. public static bool GetHandState(Step stepId, Hand hand, ref HandState handState)
  4096. {
  4097. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4098. return false;
  4099. #else
  4100. if (version >= OVRP_1_44_0.version)
  4101. {
  4102. Result res = OVRP_1_44_0.ovrp_GetHandState(stepId, hand, out cachedHandState);
  4103. if (res == Result.Success)
  4104. {
  4105. // attempt to avoid allocations if client provides appropriately pre-initialized HandState
  4106. if (handState.BoneRotations == null || handState.BoneRotations.Length != ((int)BoneId.Hand_End - (int)BoneId.Hand_Start))
  4107. {
  4108. handState.BoneRotations = new Quatf[(int)BoneId.Hand_End - (int)BoneId.Hand_Start];
  4109. }
  4110. if (handState.PinchStrength == null || handState.PinchStrength.Length != (int)HandFinger.Max)
  4111. {
  4112. handState.PinchStrength = new float[(int)HandFinger.Max];
  4113. }
  4114. if (handState.FingerConfidences == null || handState.FingerConfidences.Length != (int)HandFinger.Max)
  4115. {
  4116. handState.FingerConfidences = new TrackingConfidence[(int)HandFinger.Max];
  4117. }
  4118. // unrolling the arrays is necessary to avoid per-frame allocations during marshaling
  4119. handState.Status = cachedHandState.Status;
  4120. handState.RootPose = cachedHandState.RootPose;
  4121. handState.BoneRotations[0] = cachedHandState.BoneRotations_0;
  4122. handState.BoneRotations[1] = cachedHandState.BoneRotations_1;
  4123. handState.BoneRotations[2] = cachedHandState.BoneRotations_2;
  4124. handState.BoneRotations[3] = cachedHandState.BoneRotations_3;
  4125. handState.BoneRotations[4] = cachedHandState.BoneRotations_4;
  4126. handState.BoneRotations[5] = cachedHandState.BoneRotations_5;
  4127. handState.BoneRotations[6] = cachedHandState.BoneRotations_6;
  4128. handState.BoneRotations[7] = cachedHandState.BoneRotations_7;
  4129. handState.BoneRotations[8] = cachedHandState.BoneRotations_8;
  4130. handState.BoneRotations[9] = cachedHandState.BoneRotations_9;
  4131. handState.BoneRotations[10] = cachedHandState.BoneRotations_10;
  4132. handState.BoneRotations[11] = cachedHandState.BoneRotations_11;
  4133. handState.BoneRotations[12] = cachedHandState.BoneRotations_12;
  4134. handState.BoneRotations[13] = cachedHandState.BoneRotations_13;
  4135. handState.BoneRotations[14] = cachedHandState.BoneRotations_14;
  4136. handState.BoneRotations[15] = cachedHandState.BoneRotations_15;
  4137. handState.BoneRotations[16] = cachedHandState.BoneRotations_16;
  4138. handState.BoneRotations[17] = cachedHandState.BoneRotations_17;
  4139. handState.BoneRotations[18] = cachedHandState.BoneRotations_18;
  4140. handState.BoneRotations[19] = cachedHandState.BoneRotations_19;
  4141. handState.BoneRotations[20] = cachedHandState.BoneRotations_20;
  4142. handState.BoneRotations[21] = cachedHandState.BoneRotations_21;
  4143. handState.BoneRotations[22] = cachedHandState.BoneRotations_22;
  4144. handState.BoneRotations[23] = cachedHandState.BoneRotations_23;
  4145. handState.Pinches = cachedHandState.Pinches;
  4146. handState.PinchStrength[0] = cachedHandState.PinchStrength_0;
  4147. handState.PinchStrength[1] = cachedHandState.PinchStrength_1;
  4148. handState.PinchStrength[2] = cachedHandState.PinchStrength_2;
  4149. handState.PinchStrength[3] = cachedHandState.PinchStrength_3;
  4150. handState.PinchStrength[4] = cachedHandState.PinchStrength_4;
  4151. handState.PointerPose = cachedHandState.PointerPose;
  4152. handState.HandScale = cachedHandState.HandScale;
  4153. handState.HandConfidence = cachedHandState.HandConfidence;
  4154. handState.FingerConfidences[0] = cachedHandState.FingerConfidences_0;
  4155. handState.FingerConfidences[1] = cachedHandState.FingerConfidences_1;
  4156. handState.FingerConfidences[2] = cachedHandState.FingerConfidences_2;
  4157. handState.FingerConfidences[3] = cachedHandState.FingerConfidences_3;
  4158. handState.FingerConfidences[4] = cachedHandState.FingerConfidences_4;
  4159. handState.RequestedTimeStamp = cachedHandState.RequestedTimeStamp;
  4160. handState.SampleTimeStamp = cachedHandState.SampleTimeStamp;
  4161. return true;
  4162. }
  4163. else
  4164. {
  4165. return false;
  4166. }
  4167. }
  4168. else
  4169. {
  4170. return false;
  4171. }
  4172. #endif
  4173. }
  4174. public static bool GetSkeleton(SkeletonType skeletonType, out Skeleton skeleton)
  4175. {
  4176. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4177. skeleton = default(Skeleton);
  4178. return false;
  4179. #else
  4180. if (version >= OVRP_1_44_0.version)
  4181. {
  4182. return OVRP_1_44_0.ovrp_GetSkeleton(skeletonType, out skeleton) == Result.Success;
  4183. }
  4184. else
  4185. {
  4186. skeleton = default(Skeleton);
  4187. return false;
  4188. }
  4189. #endif
  4190. }
  4191. public static bool GetMesh(MeshType meshType, out Mesh mesh)
  4192. {
  4193. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4194. mesh = new Mesh();
  4195. return false;
  4196. #else
  4197. if (version >= OVRP_1_44_0.version)
  4198. {
  4199. mesh = new Mesh();
  4200. int meshSize = Marshal.SizeOf(mesh);
  4201. System.IntPtr meshPtr = Marshal.AllocHGlobal(meshSize);
  4202. Result result = OVRP_1_44_0.ovrp_GetMesh(meshType, meshPtr);
  4203. if (result == Result.Success)
  4204. {
  4205. Marshal.PtrToStructure(meshPtr, mesh);
  4206. }
  4207. Marshal.FreeHGlobal(meshPtr);
  4208. return (result == Result.Success);
  4209. }
  4210. else
  4211. {
  4212. mesh = new Mesh();
  4213. return false;
  4214. }
  4215. #endif
  4216. }
  4217. public static bool GetSystemHmd3DofModeEnabled()
  4218. {
  4219. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  4220. return false;
  4221. #else
  4222. if (version >= OVRP_1_45_0.version)
  4223. {
  4224. Bool val = Bool.False;
  4225. Result res = OVRP_1_45_0.ovrp_GetSystemHmd3DofModeEnabled(ref val);
  4226. if (res == Result.Success)
  4227. {
  4228. return val == Bool.True;
  4229. }
  4230. return false;
  4231. }
  4232. else
  4233. {
  4234. return false;
  4235. }
  4236. #endif
  4237. }
  4238. private const string pluginName = "OVRPlugin";
  4239. private static System.Version _versionZero = new System.Version(0, 0, 0);
  4240. // Disable all the DllImports when the platform is not supported
  4241. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  4242. private static class OVRP_0_1_0
  4243. {
  4244. public static readonly System.Version version = new System.Version(0, 1, 0);
  4245. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4246. public static extern Sizei ovrp_GetEyeTextureSize(Eye eyeId);
  4247. }
  4248. private static class OVRP_0_1_1
  4249. {
  4250. public static readonly System.Version version = new System.Version(0, 1, 1);
  4251. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4252. public static extern Bool ovrp_SetOverlayQuad2(Bool onTop, Bool headLocked, IntPtr texture, IntPtr device, Posef pose, Vector3f scale);
  4253. }
  4254. private static class OVRP_0_1_2
  4255. {
  4256. public static readonly System.Version version = new System.Version(0, 1, 2);
  4257. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4258. public static extern Posef ovrp_GetNodePose(Node nodeId);
  4259. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4260. public static extern Bool ovrp_SetControllerVibration(uint controllerMask, float frequency, float amplitude);
  4261. }
  4262. private static class OVRP_0_1_3
  4263. {
  4264. public static readonly System.Version version = new System.Version(0, 1, 3);
  4265. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4266. public static extern Posef ovrp_GetNodeVelocity(Node nodeId);
  4267. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4268. public static extern Posef ovrp_GetNodeAcceleration(Node nodeId);
  4269. }
  4270. private static class OVRP_0_5_0
  4271. {
  4272. public static readonly System.Version version = new System.Version(0, 5, 0);
  4273. }
  4274. private static class OVRP_1_0_0
  4275. {
  4276. public static readonly System.Version version = new System.Version(1, 0, 0);
  4277. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4278. public static extern TrackingOrigin ovrp_GetTrackingOriginType();
  4279. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4280. public static extern Bool ovrp_SetTrackingOriginType(TrackingOrigin originType);
  4281. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4282. public static extern Posef ovrp_GetTrackingCalibratedOrigin();
  4283. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4284. public static extern Bool ovrp_RecenterTrackingOrigin(uint flags);
  4285. }
  4286. private static class OVRP_1_1_0
  4287. {
  4288. public static readonly System.Version version = new System.Version(1, 1, 0);
  4289. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4290. public static extern Bool ovrp_GetInitialized();
  4291. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetVersion")]
  4292. private static extern IntPtr _ovrp_GetVersion();
  4293. public static string ovrp_GetVersion() { return Marshal.PtrToStringAnsi(_ovrp_GetVersion()); }
  4294. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetNativeSDKVersion")]
  4295. private static extern IntPtr _ovrp_GetNativeSDKVersion();
  4296. public static string ovrp_GetNativeSDKVersion() { return Marshal.PtrToStringAnsi(_ovrp_GetNativeSDKVersion()); }
  4297. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4298. public static extern IntPtr ovrp_GetAudioOutId();
  4299. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4300. public static extern IntPtr ovrp_GetAudioInId();
  4301. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4302. public static extern float ovrp_GetEyeTextureScale();
  4303. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4304. public static extern Bool ovrp_SetEyeTextureScale(float value);
  4305. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4306. public static extern Bool ovrp_GetTrackingOrientationSupported();
  4307. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4308. public static extern Bool ovrp_GetTrackingOrientationEnabled();
  4309. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4310. public static extern Bool ovrp_SetTrackingOrientationEnabled(Bool value);
  4311. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4312. public static extern Bool ovrp_GetTrackingPositionSupported();
  4313. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4314. public static extern Bool ovrp_GetTrackingPositionEnabled();
  4315. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4316. public static extern Bool ovrp_SetTrackingPositionEnabled(Bool value);
  4317. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4318. public static extern Bool ovrp_GetNodePresent(Node nodeId);
  4319. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4320. public static extern Bool ovrp_GetNodeOrientationTracked(Node nodeId);
  4321. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4322. public static extern Bool ovrp_GetNodePositionTracked(Node nodeId);
  4323. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4324. public static extern Frustumf ovrp_GetNodeFrustum(Node nodeId);
  4325. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4326. public static extern ControllerState ovrp_GetControllerState(uint controllerMask);
  4327. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4328. public static extern int ovrp_GetSystemCpuLevel();
  4329. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4330. public static extern Bool ovrp_SetSystemCpuLevel(int value);
  4331. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4332. public static extern int ovrp_GetSystemGpuLevel();
  4333. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4334. public static extern Bool ovrp_SetSystemGpuLevel(int value);
  4335. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4336. public static extern Bool ovrp_GetSystemPowerSavingMode();
  4337. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4338. public static extern float ovrp_GetSystemDisplayFrequency();
  4339. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4340. public static extern int ovrp_GetSystemVSyncCount();
  4341. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4342. public static extern float ovrp_GetSystemVolume();
  4343. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4344. public static extern BatteryStatus ovrp_GetSystemBatteryStatus();
  4345. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4346. public static extern float ovrp_GetSystemBatteryLevel();
  4347. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4348. public static extern float ovrp_GetSystemBatteryTemperature();
  4349. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetSystemProductName")]
  4350. private static extern IntPtr _ovrp_GetSystemProductName();
  4351. public static string ovrp_GetSystemProductName() { return Marshal.PtrToStringAnsi(_ovrp_GetSystemProductName()); }
  4352. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4353. public static extern Bool ovrp_ShowSystemUI(PlatformUI ui);
  4354. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4355. public static extern Bool ovrp_GetAppMonoscopic();
  4356. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4357. public static extern Bool ovrp_SetAppMonoscopic(Bool value);
  4358. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4359. public static extern Bool ovrp_GetAppHasVrFocus();
  4360. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4361. public static extern Bool ovrp_GetAppShouldQuit();
  4362. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4363. public static extern Bool ovrp_GetAppShouldRecenter();
  4364. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetAppLatencyTimings")]
  4365. private static extern IntPtr _ovrp_GetAppLatencyTimings();
  4366. public static string ovrp_GetAppLatencyTimings() { return Marshal.PtrToStringAnsi(_ovrp_GetAppLatencyTimings()); }
  4367. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4368. public static extern Bool ovrp_GetUserPresent();
  4369. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4370. public static extern float ovrp_GetUserIPD();
  4371. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4372. public static extern Bool ovrp_SetUserIPD(float value);
  4373. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4374. public static extern float ovrp_GetUserEyeDepth();
  4375. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4376. public static extern Bool ovrp_SetUserEyeDepth(float value);
  4377. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4378. public static extern float ovrp_GetUserEyeHeight();
  4379. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4380. public static extern Bool ovrp_SetUserEyeHeight(float value);
  4381. }
  4382. private static class OVRP_1_2_0
  4383. {
  4384. public static readonly System.Version version = new System.Version(1, 2, 0);
  4385. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4386. public static extern Bool ovrp_SetSystemVSyncCount(int vsyncCount);
  4387. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4388. public static extern Bool ovrpi_SetTrackingCalibratedOrigin();
  4389. }
  4390. private static class OVRP_1_3_0
  4391. {
  4392. public static readonly System.Version version = new System.Version(1, 3, 0);
  4393. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4394. public static extern Bool ovrp_GetEyeOcclusionMeshEnabled();
  4395. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4396. public static extern Bool ovrp_SetEyeOcclusionMeshEnabled(Bool value);
  4397. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4398. public static extern Bool ovrp_GetSystemHeadphonesPresent();
  4399. }
  4400. private static class OVRP_1_5_0
  4401. {
  4402. public static readonly System.Version version = new System.Version(1, 5, 0);
  4403. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4404. public static extern SystemRegion ovrp_GetSystemRegion();
  4405. }
  4406. private static class OVRP_1_6_0
  4407. {
  4408. public static readonly System.Version version = new System.Version(1, 6, 0);
  4409. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4410. public static extern Bool ovrp_GetTrackingIPDEnabled();
  4411. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4412. public static extern Bool ovrp_SetTrackingIPDEnabled(Bool value);
  4413. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4414. public static extern HapticsDesc ovrp_GetControllerHapticsDesc(uint controllerMask);
  4415. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4416. public static extern HapticsState ovrp_GetControllerHapticsState(uint controllerMask);
  4417. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4418. public static extern Bool ovrp_SetControllerHaptics(uint controllerMask, HapticsBuffer hapticsBuffer);
  4419. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4420. public static extern Bool ovrp_SetOverlayQuad3(uint flags, IntPtr textureLeft, IntPtr textureRight, IntPtr device, Posef pose, Vector3f scale, int layerIndex);
  4421. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4422. public static extern float ovrp_GetEyeRecommendedResolutionScale();
  4423. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4424. public static extern float ovrp_GetAppCpuStartToGpuEndTime();
  4425. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4426. public static extern int ovrp_GetSystemRecommendedMSAALevel();
  4427. }
  4428. private static class OVRP_1_7_0
  4429. {
  4430. public static readonly System.Version version = new System.Version(1, 7, 0);
  4431. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4432. public static extern Bool ovrp_GetAppChromaticCorrection();
  4433. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4434. public static extern Bool ovrp_SetAppChromaticCorrection(Bool value);
  4435. }
  4436. private static class OVRP_1_8_0
  4437. {
  4438. public static readonly System.Version version = new System.Version(1, 8, 0);
  4439. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4440. public static extern Bool ovrp_GetBoundaryConfigured();
  4441. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4442. public static extern BoundaryTestResult ovrp_TestBoundaryNode(Node nodeId, BoundaryType boundaryType);
  4443. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4444. public static extern BoundaryTestResult ovrp_TestBoundaryPoint(Vector3f point, BoundaryType boundaryType);
  4445. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4446. public static extern BoundaryGeometry ovrp_GetBoundaryGeometry(BoundaryType boundaryType);
  4447. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4448. public static extern Vector3f ovrp_GetBoundaryDimensions(BoundaryType boundaryType);
  4449. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4450. public static extern Bool ovrp_GetBoundaryVisible();
  4451. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4452. public static extern Bool ovrp_SetBoundaryVisible(Bool value);
  4453. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4454. public static extern Bool ovrp_Update2(int stateId, int frameIndex, double predictionSeconds);
  4455. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4456. public static extern Posef ovrp_GetNodePose2(int stateId, Node nodeId);
  4457. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4458. public static extern Posef ovrp_GetNodeVelocity2(int stateId, Node nodeId);
  4459. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4460. public static extern Posef ovrp_GetNodeAcceleration2(int stateId, Node nodeId);
  4461. }
  4462. private static class OVRP_1_9_0
  4463. {
  4464. public static readonly System.Version version = new System.Version(1, 9, 0);
  4465. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4466. public static extern SystemHeadset ovrp_GetSystemHeadsetType();
  4467. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4468. public static extern Controller ovrp_GetActiveController();
  4469. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4470. public static extern Controller ovrp_GetConnectedControllers();
  4471. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4472. public static extern Bool ovrp_GetBoundaryGeometry2(BoundaryType boundaryType, IntPtr points, ref int pointsCount);
  4473. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4474. public static extern AppPerfStats ovrp_GetAppPerfStats();
  4475. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4476. public static extern Bool ovrp_ResetAppPerfStats();
  4477. }
  4478. private static class OVRP_1_10_0
  4479. {
  4480. public static readonly System.Version version = new System.Version(1, 10, 0);
  4481. }
  4482. private static class OVRP_1_11_0
  4483. {
  4484. public static readonly System.Version version = new System.Version(1, 11, 0);
  4485. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4486. public static extern Bool ovrp_SetDesiredEyeTextureFormat(EyeTextureFormat value);
  4487. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4488. public static extern EyeTextureFormat ovrp_GetDesiredEyeTextureFormat();
  4489. }
  4490. private static class OVRP_1_12_0
  4491. {
  4492. public static readonly System.Version version = new System.Version(1, 12, 0);
  4493. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4494. public static extern float ovrp_GetAppFramerate();
  4495. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4496. public static extern PoseStatef ovrp_GetNodePoseState(Step stepId, Node nodeId);
  4497. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4498. public static extern ControllerState2 ovrp_GetControllerState2(uint controllerMask);
  4499. }
  4500. private static class OVRP_1_15_0
  4501. {
  4502. public static readonly System.Version version = new System.Version(1, 15, 0);
  4503. public const int OVRP_EXTERNAL_CAMERA_NAME_SIZE = 32;
  4504. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4505. public static extern Result ovrp_InitializeMixedReality();
  4506. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4507. public static extern Result ovrp_ShutdownMixedReality();
  4508. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4509. public static extern Bool ovrp_GetMixedRealityInitialized();
  4510. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4511. public static extern Result ovrp_UpdateExternalCamera();
  4512. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4513. public static extern Result ovrp_GetExternalCameraCount(out int cameraCount);
  4514. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4515. public static extern Result ovrp_GetExternalCameraName(int cameraId, [MarshalAs(UnmanagedType.LPArray, SizeConst = OVRP_EXTERNAL_CAMERA_NAME_SIZE)] char[] cameraName);
  4516. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4517. public static extern Result ovrp_GetExternalCameraIntrinsics(int cameraId, out CameraIntrinsics cameraIntrinsics);
  4518. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4519. public static extern Result ovrp_GetExternalCameraExtrinsics(int cameraId, out CameraExtrinsics cameraExtrinsics);
  4520. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4521. public static extern Result ovrp_CalculateLayerDesc(OverlayShape shape, LayerLayout layout, ref Sizei textureSize,
  4522. int mipLevels, int sampleCount, EyeTextureFormat format, int layerFlags, ref LayerDesc layerDesc);
  4523. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4524. public static extern Result ovrp_EnqueueSetupLayer(ref LayerDesc desc, IntPtr layerId);
  4525. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4526. public static extern Result ovrp_EnqueueDestroyLayer(IntPtr layerId);
  4527. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4528. public static extern Result ovrp_GetLayerTextureStageCount(int layerId, ref int layerTextureStageCount);
  4529. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4530. public static extern Result ovrp_GetLayerTexturePtr(int layerId, int stage, Eye eyeId, ref IntPtr textureHandle);
  4531. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4532. public static extern Result ovrp_EnqueueSubmitLayer(uint flags, IntPtr textureLeft, IntPtr textureRight, int layerId, int frameIndex, ref Posef pose, ref Vector3f scale, int layerIndex);
  4533. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4534. public static extern Result ovrp_GetNodeFrustum2(Node nodeId, out Frustumf2 nodeFrustum);
  4535. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4536. public static extern Bool ovrp_GetEyeTextureArrayEnabled();
  4537. }
  4538. private static class OVRP_1_16_0
  4539. {
  4540. public static readonly System.Version version = new System.Version(1, 16, 0);
  4541. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4542. public static extern Result ovrp_UpdateCameraDevices();
  4543. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4544. public static extern Bool ovrp_IsCameraDeviceAvailable(CameraDevice cameraDevice);
  4545. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4546. public static extern Result ovrp_SetCameraDevicePreferredColorFrameSize(CameraDevice cameraDevice, Sizei preferredColorFrameSize);
  4547. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4548. public static extern Result ovrp_OpenCameraDevice(CameraDevice cameraDevice);
  4549. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4550. public static extern Result ovrp_CloseCameraDevice(CameraDevice cameraDevice);
  4551. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4552. public static extern Bool ovrp_HasCameraDeviceOpened(CameraDevice cameraDevice);
  4553. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4554. public static extern Bool ovrp_IsCameraDeviceColorFrameAvailable(CameraDevice cameraDevice);
  4555. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4556. public static extern Result ovrp_GetCameraDeviceColorFrameSize(CameraDevice cameraDevice, out Sizei colorFrameSize);
  4557. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4558. public static extern Result ovrp_GetCameraDeviceColorFrameBgraPixels(CameraDevice cameraDevice, out IntPtr colorFrameBgraPixels, out int colorFrameRowPitch);
  4559. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4560. public static extern Result ovrp_GetControllerState4(uint controllerMask, ref ControllerState4 controllerState);
  4561. }
  4562. private static class OVRP_1_17_0
  4563. {
  4564. public static readonly System.Version version = new System.Version(1, 17, 0);
  4565. #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
  4566. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4567. public static extern Result ovrp_GetExternalCameraPose(CameraDevice camera, out Posef cameraPose);
  4568. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4569. public static extern Result ovrp_ConvertPoseToCameraSpace(CameraDevice camera, ref Posef trackingSpacePose, out Posef cameraSpacePose);
  4570. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4571. public static extern Result ovrp_GetCameraDeviceIntrinsicsParameters(CameraDevice camera, out Bool supportIntrinsics, out CameraDeviceIntrinsicsParameters intrinsicsParameters);
  4572. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4573. public static extern Result ovrp_DoesCameraDeviceSupportDepth(CameraDevice camera, out Bool supportDepth);
  4574. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4575. public static extern Result ovrp_GetCameraDeviceDepthSensingMode(CameraDevice camera, out CameraDeviceDepthSensingMode depthSensoringMode);
  4576. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4577. public static extern Result ovrp_SetCameraDeviceDepthSensingMode(CameraDevice camera, CameraDeviceDepthSensingMode depthSensoringMode);
  4578. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4579. public static extern Result ovrp_GetCameraDevicePreferredDepthQuality(CameraDevice camera, out CameraDeviceDepthQuality depthQuality);
  4580. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4581. public static extern Result ovrp_SetCameraDevicePreferredDepthQuality(CameraDevice camera, CameraDeviceDepthQuality depthQuality);
  4582. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4583. public static extern Result ovrp_IsCameraDeviceDepthFrameAvailable(CameraDevice camera, out Bool available);
  4584. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4585. public static extern Result ovrp_GetCameraDeviceDepthFrameSize(CameraDevice camera, out Sizei depthFrameSize);
  4586. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4587. public static extern Result ovrp_GetCameraDeviceDepthFramePixels(CameraDevice cameraDevice, out IntPtr depthFramePixels, out int depthFrameRowPitch);
  4588. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4589. public static extern Result ovrp_GetCameraDeviceDepthConfidencePixels(CameraDevice cameraDevice, out IntPtr depthConfidencePixels, out int depthConfidenceRowPitch);
  4590. #endif
  4591. }
  4592. private static class OVRP_1_18_0
  4593. {
  4594. public static readonly System.Version version = new System.Version(1, 18, 0);
  4595. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4596. public static extern Result ovrp_SetHandNodePoseStateLatency(double latencyInSeconds);
  4597. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4598. public static extern Result ovrp_GetHandNodePoseStateLatency(out double latencyInSeconds);
  4599. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4600. public static extern Result ovrp_GetAppHasInputFocus(out Bool appHasInputFocus);
  4601. }
  4602. private static class OVRP_1_19_0
  4603. {
  4604. public static readonly System.Version version = new System.Version(1, 19, 0);
  4605. }
  4606. private static class OVRP_1_21_0
  4607. {
  4608. public static readonly System.Version version = new System.Version(1, 21, 0);
  4609. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4610. public static extern Result ovrp_GetTiledMultiResSupported(out Bool foveationSupported);
  4611. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4612. public static extern Result ovrp_GetTiledMultiResLevel(out FixedFoveatedRenderingLevel level);
  4613. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4614. public static extern Result ovrp_SetTiledMultiResLevel(FixedFoveatedRenderingLevel level);
  4615. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4616. public static extern Result ovrp_GetGPUUtilSupported(out Bool gpuUtilSupported);
  4617. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4618. public static extern Result ovrp_GetGPUUtilLevel(out float gpuUtil);
  4619. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4620. public static extern Result ovrp_GetSystemDisplayFrequency2(out float systemDisplayFrequency);
  4621. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4622. public static extern Result ovrp_GetSystemDisplayAvailableFrequencies(IntPtr systemDisplayAvailableFrequencies, ref int numFrequencies);
  4623. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4624. public static extern Result ovrp_SetSystemDisplayFrequency(float requestedFrequency);
  4625. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4626. public static extern Result ovrp_GetAppAsymmetricFov(out Bool useAsymmetricFov);
  4627. }
  4628. private static class OVRP_1_28_0
  4629. {
  4630. public static readonly System.Version version = new System.Version(1, 28, 0);
  4631. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4632. public static extern Result ovrp_GetDominantHand(out Handedness dominantHand);
  4633. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4634. public static extern Result ovrp_GetReorientHMDOnControllerRecenter(out Bool recenter);
  4635. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4636. public static extern Result ovrp_SetReorientHMDOnControllerRecenter(Bool recenter);
  4637. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4638. public static extern Result ovrp_SendEvent(string name, string param);
  4639. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4640. public static extern Result ovrp_EnqueueSetupLayer2(ref LayerDesc desc, int compositionDepth, IntPtr layerId);
  4641. }
  4642. private static class OVRP_1_29_0
  4643. {
  4644. public static readonly System.Version version = new System.Version(1, 29, 0);
  4645. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4646. public static extern Result ovrp_GetLayerAndroidSurfaceObject(int layerId, ref IntPtr surfaceObject);
  4647. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4648. public static extern Result ovrp_SetHeadPoseModifier(ref Quatf relativeRotation, ref Vector3f relativeTranslation);
  4649. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4650. public static extern Result ovrp_GetHeadPoseModifier(out Quatf relativeRotation, out Vector3f relativeTranslation);
  4651. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4652. public static extern Result ovrp_GetNodePoseStateRaw(Step stepId, int frameIndex, Node nodeId, out PoseStatef nodePoseState);
  4653. }
  4654. private static class OVRP_1_30_0
  4655. {
  4656. public static readonly System.Version version = new System.Version(1, 30, 0);
  4657. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4658. public static extern Result ovrp_GetCurrentTrackingTransformPose(out Posef trackingTransformPose);
  4659. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4660. public static extern Result ovrp_GetTrackingTransformRawPose(out Posef trackingTransformRawPose);
  4661. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4662. public static extern Result ovrp_SendEvent2(string name, string param, string source);
  4663. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4664. public static extern Result ovrp_IsPerfMetricsSupported(PerfMetrics perfMetrics, out Bool isSupported);
  4665. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4666. public static extern Result ovrp_GetPerfMetricsFloat(PerfMetrics perfMetrics, out float value);
  4667. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4668. public static extern Result ovrp_GetPerfMetricsInt(PerfMetrics perfMetrics, out int value);
  4669. }
  4670. private static class OVRP_1_31_0
  4671. {
  4672. public static readonly System.Version version = new System.Version(1, 31, 0);
  4673. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4674. public static extern Result ovrp_GetTimeInSeconds(out double value);
  4675. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4676. public static extern Result ovrp_SetColorScaleAndOffset(Vector4 colorScale, Vector4 colorOffset, Bool applyToAllLayers);
  4677. }
  4678. private static class OVRP_1_32_0
  4679. {
  4680. public static readonly System.Version version = new System.Version(1, 32, 0);
  4681. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4682. public static extern Result ovrp_AddCustomMetadata(string name, string param);
  4683. }
  4684. private static class OVRP_1_34_0
  4685. {
  4686. public static readonly System.Version version = new System.Version(1, 34, 0);
  4687. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4688. public static extern Result ovrp_EnqueueSubmitLayer2(uint flags, IntPtr textureLeft, IntPtr textureRight, int layerId, int frameIndex, ref Posef pose, ref Vector3f scale, int layerIndex,
  4689. Bool overrideTextureRectMatrix, ref TextureRectMatrixf textureRectMatrix, Bool overridePerLayerColorScaleAndOffset, ref Vector4 colorScale, ref Vector4 colorOffset);
  4690. }
  4691. private static class OVRP_1_35_0
  4692. {
  4693. public static readonly System.Version version = new System.Version(1, 35, 0);
  4694. }
  4695. private static class OVRP_1_36_0
  4696. {
  4697. public static readonly System.Version version = new System.Version(1, 36, 0);
  4698. }
  4699. private static class OVRP_1_37_0
  4700. {
  4701. public static readonly System.Version version = new System.Version(1, 37, 0);
  4702. }
  4703. private static class OVRP_1_38_0
  4704. {
  4705. public static readonly System.Version version = new System.Version(1, 38, 0);
  4706. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4707. public static extern Result ovrp_GetTrackingTransformRelativePose(ref Posef trackingTransformRelativePose, TrackingOrigin trackingOrigin);
  4708. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4709. public static extern Result ovrp_Media_Initialize();
  4710. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4711. public static extern Result ovrp_Media_Shutdown();
  4712. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4713. public static extern Result ovrp_Media_GetInitialized(out Bool initialized);
  4714. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4715. public static extern Result ovrp_Media_Update();
  4716. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4717. public static extern Result ovrp_Media_GetMrcActivationMode(out Media.MrcActivationMode activationMode);
  4718. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4719. public static extern Result ovrp_Media_SetMrcActivationMode(Media.MrcActivationMode activationMode);
  4720. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4721. public static extern Result ovrp_Media_IsMrcEnabled(out Bool mrcEnabled);
  4722. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4723. public static extern Result ovrp_Media_IsMrcActivated(out Bool mrcActivated);
  4724. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4725. public static extern Result ovrp_Media_UseMrcDebugCamera(out Bool useMrcDebugCamera);
  4726. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4727. public static extern Result ovrp_Media_SetMrcInputVideoBufferType(Media.InputVideoBufferType inputVideoBufferType);
  4728. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4729. public static extern Result ovrp_Media_GetMrcInputVideoBufferType(ref Media.InputVideoBufferType inputVideoBufferType);
  4730. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4731. public static extern Result ovrp_Media_SetMrcFrameSize(int frameWidth, int frameHeight);
  4732. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4733. public static extern Result ovrp_Media_GetMrcFrameSize(ref int frameWidth, ref int frameHeight);
  4734. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4735. public static extern Result ovrp_Media_SetMrcAudioSampleRate(int sampleRate);
  4736. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4737. public static extern Result ovrp_Media_GetMrcAudioSampleRate(ref int sampleRate);
  4738. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4739. public static extern Result ovrp_Media_SetMrcFrameImageFlipped(Bool flipped);
  4740. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4741. public static extern Result ovrp_Media_GetMrcFrameImageFlipped(ref Bool flipped);
  4742. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4743. public static extern Result ovrp_Media_EncodeMrcFrame(System.IntPtr rawBuffer, System.IntPtr audioDataPtr, int audioDataLen, int audioChannels, double timestamp, ref int outSyncId);
  4744. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4745. public static extern Result ovrp_Media_EncodeMrcFrameWithDualTextures(System.IntPtr backgroundTextureHandle, System.IntPtr foregroundTextureHandle, System.IntPtr audioData, int audioDataLen, int audioChannels, double timestamp, ref int outSyncId);
  4746. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4747. public static extern Result ovrp_Media_SyncMrcFrame(int syncId);
  4748. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4749. public static extern Result ovrp_GetExternalCameraCalibrationRawPose(int cameraId, out Posef rawPose);
  4750. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4751. public static extern Result ovrp_SetDeveloperMode(Bool active);
  4752. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4753. public static extern Result ovrp_GetNodeOrientationValid(Node nodeId, ref Bool nodeOrientationValid);
  4754. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4755. public static extern Result ovrp_GetNodePositionValid(Node nodeId, ref Bool nodePositionValid);
  4756. }
  4757. private static class OVRP_1_39_0
  4758. {
  4759. public static readonly System.Version version = new System.Version(1, 39, 0);
  4760. }
  4761. private static class OVRP_1_40_0
  4762. {
  4763. public static readonly System.Version version = new System.Version(1, 40, 0);
  4764. }
  4765. private static class OVRP_1_41_0
  4766. {
  4767. public static readonly System.Version version = new System.Version(1, 41, 0);
  4768. }
  4769. private static class OVRP_1_42_0
  4770. {
  4771. public static readonly System.Version version = new System.Version(1, 42, 0);
  4772. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4773. public static extern Result ovrp_GetAdaptiveGpuPerformanceScale2(ref float adaptiveGpuPerformanceScale);
  4774. }
  4775. private static class OVRP_1_43_0
  4776. {
  4777. public static readonly System.Version version = new System.Version(1, 43, 0);
  4778. }
  4779. private static class OVRP_1_44_0
  4780. {
  4781. public static readonly System.Version version = new System.Version(1, 44, 0);
  4782. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4783. public static extern Result ovrp_GetHandTrackingEnabled(ref Bool handTrackingEnabled);
  4784. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4785. public static extern Result ovrp_GetHandState(Step stepId, Hand hand, out HandStateInternal handState);
  4786. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4787. public static extern Result ovrp_GetSkeleton(SkeletonType skeletonType, out Skeleton skeleton);
  4788. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4789. public static extern Result ovrp_GetMesh(MeshType meshType, System.IntPtr meshPtr);
  4790. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4791. public static extern Result ovrp_OverrideExternalCameraFov(int cameraId, Bool useOverriddenFov, ref Fovf fov);
  4792. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4793. public static extern Result ovrp_GetUseOverriddenExternalCameraFov(int cameraId, out Bool useOverriddenFov);
  4794. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4795. public static extern Result ovrp_OverrideExternalCameraStaticPose(int cameraId, Bool useOverriddenPose, ref Posef pose);
  4796. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4797. public static extern Result ovrp_GetUseOverriddenExternalCameraStaticPose(int cameraId, out Bool useOverriddenStaticPose);
  4798. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4799. public static extern Result ovrp_ResetDefaultExternalCamera();
  4800. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4801. public static extern Result ovrp_SetDefaultExternalCamera(string cameraName, ref CameraIntrinsics cameraIntrinsics, ref CameraExtrinsics cameraExtrinsics);
  4802. }
  4803. private static class OVRP_1_45_0
  4804. {
  4805. public static readonly System.Version version = new System.Version(1, 45, 0);
  4806. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4807. public static extern Result ovrp_GetSystemHmd3DofModeEnabled(ref Bool enabled);
  4808. }
  4809. private static class OVRP_1_46_0
  4810. {
  4811. public static readonly System.Version version = new System.Version(1, 46, 0);
  4812. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4813. public static extern Result ovrp_GetTiledMultiResDynamic(out Bool isDynamic);
  4814. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  4815. public static extern Result ovrp_SetTiledMultiResDynamic(Bool isDynamic);
  4816. }
  4817. private static class OVRP_1_47_0
  4818. {
  4819. public static readonly System.Version version = new System.Version(1, 47, 0);
  4820. }
  4821. #endif // !OVRPLUGIN_UNSUPPORTED_PLATFORM
  4822. }