ParamLoaderApi.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Runtime.InteropServices;
  5. namespace SXR
  6. {
  7. enum DeviceID
  8. {
  9. Device_Default = 0x100,
  10. Device_RhinoXPro = 0x200,
  11. Device_RhinoX2 = 0x300,
  12. Device_RhinoXH = 0x400
  13. };
  14. enum LoadFileType
  15. {
  16. LoadSvrConfig = 0,
  17. LoadAligmentCalibLeft = 1,
  18. LoadAligmentCalibRight = 2
  19. };
  20. enum ParamBase
  21. {
  22. ParamBase_Device = 0x0,
  23. ParamBase_Render = 0x10000,
  24. ParamBase_Design = 0x20000,
  25. ParamBase_Tracking = 0x30000
  26. };
  27. enum ParamDataType
  28. {
  29. ParamDataType_INT= 0x0000,
  30. ParamDataType_BOOL = 0x1000,
  31. ParamDataType_FLOAT = 0x2000,
  32. ParamDataType_FLOAT_ARRAY = 0x3000,
  33. ParamDataType_Max = 0xf000
  34. };
  35. public enum ParamType
  36. {
  37. ParamIsLoader = ParamDataType.ParamDataType_BOOL + 0,
  38. Param_DeviceID = ParamBase.ParamBase_Device + ParamDataType.ParamDataType_INT + 1,
  39. ///< render param
  40. Render_EyeBufferWidth_INT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_INT + 0,
  41. Render_EyeBufferHeight_INT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_INT + 1,
  42. Render_WarpMeshType_INT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_INT + 2,
  43. Render_WarpMeshRows_INT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_INT + 3,
  44. Render_WarpMeshCols_INT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_INT + 4,
  45. Render_EnableTimeWarp_BOOL = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_BOOL + 5,
  46. Render_DisableLensCorrection_BOOL = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_BOOL + 6,
  47. Render_TimeWarpDelayBetweenEyes_BOOL = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_BOOL + 7,
  48. Render_IPD_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 8,
  49. Render_EyePitch_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 9,
  50. Render_Frustum_Near_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 10,
  51. Render_Frustum_Far_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 11,
  52. Render_Frustum_Left_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 12,
  53. Render_Frustum_Right_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 13,
  54. Render_Frustum_Top_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 14,
  55. Render_Frustum_Bottom_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 15,
  56. Render_EyeBufferFovX_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 16,
  57. Render_EyeBufferFovY_FLOAT = ParamBase.ParamBase_Render + ParamDataType.ParamDataType_FLOAT + 17,
  58. ///< design param
  59. Design_VPU_UseFixedRotateDownward_BOOL = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_BOOL + 0, // flag to use fixed rotate downward angle for VPU
  60. Design_VPU_RotateLeft_FlOAT = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT + 1, // angle of VPU rotate left; unit: degrees
  61. Design_VPU_RotateDownward_FlOAT = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT + 2, // angle of VPU rotate downward; unit: degrees
  62. Design_Eye2IMU_TransMat_OpenGL_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 3, // 4x4 transformation matrix of IMU pose relative to eye center, both use right-handed coordinate system
  63. Design_Eye2IMU_TransMat_Unity_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 4, // 4x4 transformation matrix of IMU pose relative to eye center, both use left-handed coordinate system
  64. Design_Eye2IMU_Pos_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 5, // 3x1 position of IMU relative to eye center, both use left-handed coordinate system; unit: m
  65. Design_Eye2IMU_Euler_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 6, // 3x1 rotation angles (x/y/z) of IMU relative to eye center, both use right-handed coordinate system; unit: degrees
  66. Design_Eye2VPU_TransMat_OpenGL_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 7, // 4x4 transformation matrix of VPU pose relative to eye center, both use right-handed coordinate system
  67. Design_Eye2VPU_TransMat_Unity_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 8, // 4x4 transformation matrix of VPU pose relative to eye center, both use left-handed coordinate system
  68. Design_Eye2VPU_Pos_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 9, // 3x1 position of VPU relative to eye center, both use left-handed coordinate system; unit: m
  69. Design_Eye2VPU_Euler_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 10, // 3x1 rotation angles (x/y/z) of VPU relative to eye center, both use right-handed coordinate system; unit: degrees
  70. Design_IMU2VPU_TransMat_OpenGL_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 11, // 4x4 transformation matrix of VPU pose relative to IMU, both use right-handed coordinate system
  71. Design_IMU2VPU_TransMat_Unity_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 12, // 4x4 transformation matrix of VPU pose relative to IMU, both use left-handed coordinate system
  72. Design_IMU2VPU_Pos_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 13, // 3x1 position of VPU relative to IMU, both use left-handed coordinate system; unit: m
  73. Design_IMU2VPU_Euler_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 14, // 3x1 rotation angles (x/y/z) of VPU relative to IMU, both use right-handed coordinate system; unit: degrees
  74. Design_MarkerController2Model_TransMat_OpenGL_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 15, // 4x4 transformation matrix of model pose relative to marker controller track-pose, both use right-handed coordinate system
  75. Design_MarkerController2Model_TransMat_Unity_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 16, // 4x4 transformation matrix of model pose relative to marker controller track-pose, both use left-handed coordinate system
  76. Design_MarkerController2Model_Pos_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 17, // 3x1 position of model relative to marker controller track-pose, both use left-handed coordinate system; unit: m
  77. Design_MarkerController2Model_Euler_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 18, // 3x1 rotation angles (x/y/z) of model relative to marker controller track-pose, both use right-handed coordinate system; unit: degrees
  78. Design_RingController2Model_TransMat_OpenGL_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 19, // 4x4 transformation matrix of model pose relative to ring controller track-pose, both use right-handed coordinate system
  79. Design_RingController2Model_TransMat_Unity_ARRAY16 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 20, // 4x4 transformation matrix of model pose relative to ring controller track-pose, both use left-handed coordinate system
  80. Design_RingController2Model_Pos_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 21, // 3x1 position of model relative to ring controller track-pose, both use left-handed coordinate system; unit: m
  81. Design_RingController2Model_Euler_Unity_ARRAY3 = ParamBase.ParamBase_Design + ParamDataType.ParamDataType_FLOAT_ARRAY + 22, // 3x1 rotation angles (x/y/z) of model relative to ring controller track-pose, both use right-handed coordinate system; unit: degrees
  82. ///< tracking param
  83. Track_VIO_MaxPredictTime_FLOAT = ParamBase.ParamBase_Tracking + ParamDataType.ParamDataType_FLOAT + 1,
  84. Track_VIO_FallbackTime_FLOAT = ParamBase.ParamBase_Tracking + ParamDataType.ParamDataType_FLOAT + 2,
  85. Track_Controller_MaxPredictTime_FLOAT = ParamBase.ParamBase_Tracking + ParamDataType.ParamDataType_FLOAT + 3,
  86. Track_Controller_MinConfidence_FLOAT = ParamBase.ParamBase_Tracking + ParamDataType.ParamDataType_FLOAT + 4,
  87. Track_Beacon_MaxPredictTime_FLOAT = ParamBase.ParamBase_Tracking + ParamDataType.ParamDataType_FLOAT + 5,
  88. };
  89. public class ParamLoader
  90. {
  91. [DllImport("sxrapi")]
  92. public static extern bool ParamLoaderInit(int deviceID);
  93. [DllImport("sxrapi")]
  94. public static extern void ParamLoaderExit();
  95. [DllImport("sxrapi")]
  96. public static extern bool ParamLoaderAddFloatArray(int type, float[] value, int len);
  97. [DllImport("sxrapi")]
  98. public static extern bool ParamLoaderGetFloatArray(int type, float[] value, int len);
  99. [DllImport("sxrapi")]
  100. public static extern bool ParamLoaderSetFloatArray(int type, float[] value, int len);
  101. [DllImport("sxrapi")]
  102. public static extern void ParamLoaderPrint(int type, string tag);
  103. [DllImport("sxrapi")]
  104. public static extern bool ParamLoaderAddFloat(int type, float value);
  105. [DllImport("sxrapi")]
  106. public static extern bool ParamLoaderSetFloat(int type, float value);
  107. [DllImport("sxrapi")]
  108. public static extern float ParamLoaderGetFloat(int type);
  109. [DllImport("sxrapi")]
  110. public static extern bool ParamLoaderAddBool(int type, bool value);
  111. [DllImport("sxrapi")]
  112. public static extern bool ParamLoaderSetBool(int type, bool value);
  113. [DllImport("sxrapi")]
  114. public static extern bool ParamLoaderGetBool(int type);
  115. [DllImport("sxrapi")]
  116. public static extern bool ParamLoaderAddInt(int type, int value);
  117. [DllImport("sxrapi")]
  118. public static extern bool ParamLoaderSetInt(int type, int value);
  119. [DllImport("sxrapi")]
  120. public static extern int ParamLoaderGetInt(int type);
  121. }
  122. }