SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

289 lines
13 KiB

4 years ago
  1. using System;
  2. namespace UnityEngine.XR.ARSubsystems
  3. {
  4. /// <summary>
  5. /// Encapsulates the parameters for creating a new <see cref="XRCameraSubsystemDescriptor"/>.
  6. /// </summary>
  7. public struct XRCameraSubsystemCinfo : IEquatable<XRCameraSubsystemCinfo>
  8. {
  9. /// <summary>
  10. /// Specifies an identifier for the provider implementation of the subsystem.
  11. /// </summary>
  12. /// <value>
  13. /// The identifier for the provider implementation of the subsystem.
  14. /// </value>
  15. public string id { get; set; }
  16. /// <summary>
  17. /// Specifies the provider implementation type to use for instantiation.
  18. /// </summary>
  19. /// <value>
  20. /// The provider implementation type to use for instantiation.
  21. /// </value>
  22. public Type implementationType { get; set; }
  23. /// <summary>
  24. /// Specifies if current subsystem is allowed to provide average brightness.
  25. /// </summary>
  26. /// <value>
  27. /// <c>true</c> if current subsystem is allowed to provide average brightness. Otherwise, <c>false</c>.
  28. /// </value>
  29. public bool supportsAverageBrightness { get; set; }
  30. /// <summary>
  31. /// Specifies if current subsystem is allowed to provide average camera temperature.
  32. /// </summary>
  33. /// <value>
  34. /// <c>true</c> if current subsystem is allowed to provide average camera temperature. Otherwise, <c>false</c>.
  35. /// </value>
  36. public bool supportsAverageColorTemperature { get; set; }
  37. /// <summary>
  38. /// True if color correction is supported.
  39. /// </summary>
  40. public bool supportsColorCorrection { get; set; }
  41. /// <summary>
  42. /// Specifies if current subsystem is allowed to provide display matrix.
  43. /// </summary>
  44. /// <value>
  45. /// <c>true</c> if current subsystem is allowed to provide display matrix. Otherwise, <c>false</c>.
  46. /// </value>
  47. public bool supportsDisplayMatrix { get; set; }
  48. /// <summary>
  49. /// Specifies if current subsystem is allowed to provide projection matrix.
  50. /// </summary>
  51. /// <value>
  52. /// <c>true</c> if current subsystem is allowed to provide projection matrix. Otherwise, <c>false</c>.
  53. /// </value>
  54. public bool supportsProjectionMatrix { get; set; }
  55. /// <summary>
  56. /// Specifies if current subsystem is allowed to provide timestamp.
  57. /// </summary>
  58. /// <value>
  59. /// <c>true</c> if current subsystem is allowed to provide timestamp. Otherwise, <c>false</c>.
  60. /// </value>
  61. public bool supportsTimestamp { get; set; }
  62. /// <summary>
  63. /// Specifies if the current subsystem supports camera configurations.
  64. /// </summary>
  65. /// <value>
  66. /// <c>true</c> if the current subsystem supports camera configurations. Otherwise, <c>false</c>.
  67. /// </value>
  68. public bool supportsCameraConfigurations { get; set; }
  69. /// <summary>
  70. /// Specifies if the current subsystem is allowed to provide camera images.
  71. /// </summary>
  72. /// <value>
  73. /// <c>true</c> if the current subsystem is allowed to provide camera images. Otherwise, <c>false</c>.
  74. /// </value>
  75. public bool supportsCameraImage { get; set; }
  76. /// <summary>
  77. /// Specifies if current subsystem is allowed to provide average intensity in lumens.
  78. /// </summary>
  79. /// <value>
  80. /// <c>true</c> if current subsystem is allowed to provide average intensity in lumens. Otherwise, <c>false</c>.
  81. /// </value>
  82. public bool supportsAverageIntensityInLumens { get; set; }
  83. /// <summary>
  84. /// Specifies whether the subsystem supports setting the camera's focus mode.
  85. /// </summary>
  86. public bool supportsFocusModes { get; set; }
  87. public bool Equals(XRCameraSubsystemCinfo other)
  88. {
  89. return
  90. (id == other.id)
  91. && (implementationType == other.implementationType)
  92. && supportsAverageBrightness.Equals(other.supportsAverageBrightness)
  93. && supportsAverageColorTemperature.Equals(other.supportsAverageColorTemperature)
  94. && supportsDisplayMatrix.Equals(other.supportsDisplayMatrix)
  95. && supportsProjectionMatrix.Equals(other.supportsProjectionMatrix)
  96. && supportsTimestamp.Equals(other.supportsTimestamp)
  97. && supportsCameraConfigurations.Equals(other.supportsCameraConfigurations)
  98. && supportsCameraImage.Equals(other.supportsCameraImage)
  99. && supportsAverageIntensityInLumens.Equals(other.supportsAverageIntensityInLumens)
  100. && supportsFocusModes.Equals(other.supportsFocusModes);
  101. }
  102. public override bool Equals(System.Object obj)
  103. {
  104. return ((obj is XRCameraSubsystemCinfo) && Equals((XRCameraSubsystemCinfo)obj));
  105. }
  106. public static bool operator ==(XRCameraSubsystemCinfo lhs, XRCameraSubsystemCinfo rhs)
  107. {
  108. return lhs.Equals(rhs);
  109. }
  110. public static bool operator !=(XRCameraSubsystemCinfo lhs, XRCameraSubsystemCinfo rhs)
  111. {
  112. return !lhs.Equals(rhs);
  113. }
  114. public override int GetHashCode()
  115. {
  116. int hashCode = 486187739;
  117. unchecked
  118. {
  119. hashCode = (hashCode * 486187739) + (ReferenceEquals(id, null) ? 0 : id.GetHashCode());
  120. hashCode = (hashCode * 486187739) + (ReferenceEquals(implementationType, null) ? 0 : implementationType.GetHashCode());
  121. hashCode = (hashCode * 486187739) + supportsAverageBrightness.GetHashCode();
  122. hashCode = (hashCode * 486187739) + supportsAverageColorTemperature.GetHashCode();
  123. hashCode = (hashCode * 486187739) + supportsDisplayMatrix.GetHashCode();
  124. hashCode = (hashCode * 486187739) + supportsProjectionMatrix.GetHashCode();
  125. hashCode = (hashCode * 486187739) + supportsTimestamp.GetHashCode();
  126. hashCode = (hashCode * 486187739) + supportsCameraConfigurations.GetHashCode();
  127. hashCode = (hashCode * 486187739) + supportsCameraImage.GetHashCode();
  128. hashCode = (hashCode * 486187739) + supportsAverageIntensityInLumens.GetHashCode();
  129. hashCode = (hashCode * 486187739) + supportsFocusModes.GetHashCode();
  130. }
  131. return hashCode;
  132. }
  133. }
  134. /// <summary>
  135. /// Specifies a functionality description that may be registered for each implementation that provides the
  136. /// <see cref="XRCameraSubsystem"/> interface.
  137. /// </summary>
  138. public sealed class XRCameraSubsystemDescriptor : SubsystemDescriptor<XRCameraSubsystem>
  139. {
  140. /// <summary>
  141. /// Constructs a <c>XRCameraSubsystemDescriptor</c> based on the given parameters.
  142. /// </summary>
  143. /// <param name="cameraSubsystemParams">The parameters required to initialize the descriptor.</param>
  144. XRCameraSubsystemDescriptor(XRCameraSubsystemCinfo cameraSubsystemParams)
  145. {
  146. id = cameraSubsystemParams.id;
  147. subsystemImplementationType = cameraSubsystemParams.implementationType;
  148. supportsAverageBrightness = cameraSubsystemParams.supportsAverageBrightness;
  149. supportsAverageColorTemperature = cameraSubsystemParams.supportsAverageColorTemperature;
  150. supportsDisplayMatrix = cameraSubsystemParams.supportsDisplayMatrix;
  151. supportsProjectionMatrix = cameraSubsystemParams.supportsProjectionMatrix;
  152. supportsTimestamp = cameraSubsystemParams.supportsTimestamp;
  153. supportsCameraConfigurations = cameraSubsystemParams.supportsCameraConfigurations;
  154. supportsCameraImage = cameraSubsystemParams.supportsCameraImage;
  155. supportsAverageIntensityInLumens = cameraSubsystemParams.supportsAverageIntensityInLumens;
  156. supportsFocusModes = cameraSubsystemParams.supportsFocusModes;
  157. }
  158. /// <summary>
  159. /// Specifies if current subsystem is allowed to provide average brightness.
  160. /// </summary>
  161. /// <value>
  162. /// <c>true</c> if current subsystem is allowed to provide average brightness. Otherwise, <c>false</c>.
  163. /// </value>
  164. public bool supportsAverageBrightness { get; private set; }
  165. /// <summary>
  166. /// Specifies if current subsystem is allowed to provide average camera temperature.
  167. /// </summary>
  168. /// <value>
  169. /// <c>true</c> if current subsystem is allowed to provide average camera temperature. Otherwise, <c>false</c>.
  170. /// </value>
  171. public bool supportsAverageColorTemperature { get; private set; }
  172. /// <summary>
  173. /// Specifies if current subsystem is allowed to provide display matrix.
  174. /// </summary>
  175. /// <value>
  176. /// <c>true</c> if current subsystem is allowed to provide display matrix. Otherwise, <c>false</c>.
  177. /// </value>
  178. public bool supportsDisplayMatrix { get; private set; }
  179. /// <summary>
  180. /// Specifies if current subsystem is allowed to provide projection matrix.
  181. /// </summary>
  182. /// <value>
  183. /// <c>true</c> if current subsystem is allowed to provide projection matrix. Otherwise, <c>false</c>.
  184. /// </value>
  185. public bool supportsProjectionMatrix { get; private set; }
  186. /// <summary>
  187. /// Specifies if current subsystem is allowed to provide timestamp.
  188. /// </summary>
  189. /// <value>
  190. /// <c>true</c> if current subsystem is allowed to provide timestamp. Otherwise, <c>false</c>.
  191. /// </value>
  192. public bool supportsTimestamp { get; private set; }
  193. /// <summary>
  194. /// Specifies if the current subsystem supports camera configurations.
  195. /// </summary>
  196. /// <value>
  197. /// <c>true</c> if the current subsystem supports camera configurations. Otherwise, <c>false</c>.
  198. /// </value>
  199. public bool supportsCameraConfigurations { get; private set; }
  200. /// <summary>
  201. /// Specifies if the current subsystem is allowed to provide camera images.
  202. /// </summary>
  203. /// <value>
  204. /// <c>true</c> if the current subsystem is allowed to provide camera images. Otherwise, <c>false</c>.
  205. /// </value>
  206. public bool supportsCameraImage { get; private set; }
  207. /// <summary>
  208. /// Specifies if current subsystem is allowed to provide average intensity in lumens.
  209. /// </summary>
  210. /// <value>
  211. /// <c>true</c> if current subsystem is allowed to provide average intensity in lumens. Otherwise, <c>false</c>.
  212. /// </value>
  213. public bool supportsAverageIntensityInLumens { get; private set; }
  214. /// <summary>
  215. /// Specifies whether the subsystem supports setting the camera's focus mode.
  216. /// </summary>
  217. public bool supportsFocusModes { get; private set; }
  218. /// <summary>
  219. /// Creates a <c>XRCameraSubsystemDescriptor</c> based on the given parameters validating that the
  220. /// <see cref="XRCameraSubsystemCinfo.id"/> and <see cref="XRCameraSubsystemCinfo.implementationType"/>
  221. /// properties are properly specified.
  222. /// </summary>
  223. /// <param name="cameraSubsystemParams">The parameters defining how to initialize the descriptor.</param>
  224. /// <returns>
  225. /// The created <c>XRCameraSubsystemDescriptor</c>.
  226. /// </returns>
  227. /// <exception cref="System.ArgumentException">Thrown when the values specified in the
  228. /// <see cref="XRCameraSubsystemCinfo"/> parameter are invalid. Typically, this will occur
  229. /// <list type="bullet">
  230. /// <item>
  231. /// <description>if <see cref="XRCameraSubsystemCinfo.id"/> is <c>null</c> or empty</description>
  232. /// </item>
  233. /// <item>
  234. /// <description>if <see cref="XRCameraSubsystemCinfo.implementationType"/> is <c>null</c></description>
  235. /// </item>
  236. /// <item>
  237. /// <description>if <see cref="XRCameraSubsystemCinfo.implementationType"/> does not derive from the
  238. /// <see cref="XRCameraSubsystem"/> class
  239. /// </description>
  240. /// </item>
  241. /// </list>
  242. /// </exception>
  243. internal static XRCameraSubsystemDescriptor Create(XRCameraSubsystemCinfo cameraSubsystemParams)
  244. {
  245. if (String.IsNullOrEmpty(cameraSubsystemParams.id))
  246. {
  247. throw new ArgumentException("Cannot create camera subsystem descriptor because id is invalid",
  248. "cameraSubsystemParams");
  249. }
  250. if ((cameraSubsystemParams.implementationType == null)
  251. || !cameraSubsystemParams.implementationType.IsSubclassOf(typeof(XRCameraSubsystem)))
  252. {
  253. throw new ArgumentException("Cannot create camera subsystem descriptor because implementationType is invalid",
  254. "cameraSubsystemParams");
  255. }
  256. return new XRCameraSubsystemDescriptor(cameraSubsystemParams);
  257. }
  258. }
  259. }