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