CCamera.generated.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Runtime.InteropServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Rendering
  7. * @{
  8. */
  9. /// <summary>
  10. /// Camera determines how is world geometry projected onto a 2D surface. You may position and orient it in space, set
  11. /// options like aspect ratio and field or view and it outputs view and projection matrices required for rendering.
  12. /// </summary>
  13. [ShowInInspector]
  14. public partial class Camera : Component
  15. {
  16. private Camera(bool __dummy0) { }
  17. protected Camera() { }
  18. /// <summary>Returns the viewport used by the camera.</summary>
  19. [ShowInInspector]
  20. public Viewport Viewport
  21. {
  22. get { return Internal_getViewport(mCachedPtr); }
  23. }
  24. /// <summary>
  25. /// Determines the camera horizontal field of view. This determines how wide the camera viewing angle is along the
  26. /// horizontal axis. Vertical FOV is calculated from the horizontal FOV and the aspect ratio.
  27. /// </summary>
  28. [ShowInInspector]
  29. public Radian FieldOfView
  30. {
  31. get
  32. {
  33. Radian temp;
  34. Internal_getHorzFOV(mCachedPtr, out temp);
  35. return temp;
  36. }
  37. set { Internal_setHorzFOV(mCachedPtr, ref value); }
  38. }
  39. /// <summary>
  40. /// Determines the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane
  41. /// will not be rendered. Decreasing this value decreases depth buffer precision.
  42. /// </summary>
  43. [ShowInInspector]
  44. public float NearClipPlane
  45. {
  46. get { return Internal_getNearClipDistance(mCachedPtr); }
  47. set { Internal_setNearClipDistance(mCachedPtr, value); }
  48. }
  49. /// <summary>
  50. /// Determines the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane will
  51. /// not be rendered. Increasing this value decreases depth buffer precision.
  52. /// </summary>
  53. [ShowInInspector]
  54. public float FarClipPlane
  55. {
  56. get { return Internal_getFarClipDistance(mCachedPtr); }
  57. set { Internal_setFarClipDistance(mCachedPtr, value); }
  58. }
  59. /// <summary>Determines the current viewport aspect ratio (width / height).</summary>
  60. [ShowInInspector]
  61. public float AspectRatio
  62. {
  63. get { return Internal_getAspectRatio(mCachedPtr); }
  64. set { Internal_setAspectRatio(mCachedPtr, value); }
  65. }
  66. /// <summary>
  67. /// Returns the standard projection matrix that determines how are 3D points projected to two dimensions. The layout of
  68. /// this matrix depends on currently used render system.
  69. /// </summary>
  70. [ShowInInspector]
  71. public Matrix4 ProjMatrix
  72. {
  73. get
  74. {
  75. Matrix4 temp;
  76. Internal_getProjectionMatrixRS(mCachedPtr, out temp);
  77. return temp;
  78. }
  79. }
  80. /// <summary>Gets the camera view matrix. Used for positioning/orienting the camera.</summary>
  81. [ShowInInspector]
  82. public Matrix4 ViewMatrix
  83. {
  84. get
  85. {
  86. Matrix4 temp;
  87. Internal_getViewMatrix(mCachedPtr, out temp);
  88. return temp;
  89. }
  90. }
  91. /// <summary>
  92. /// Determines the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a
  93. /// 2D plane.
  94. /// </summary>
  95. [ShowInInspector]
  96. public ProjectionType ProjectionType
  97. {
  98. get { return Internal_getProjectionType(mCachedPtr); }
  99. set { Internal_setProjectionType(mCachedPtr, value); }
  100. }
  101. /// <summary>
  102. /// Determines the orthographic window height, for use with orthographic rendering only. The width of the window will be
  103. /// calculated from the aspect ratio. Value is specified in world units.
  104. /// </summary>
  105. [ShowInInspector]
  106. public float OrthoHeight
  107. {
  108. get { return Internal_getOrthoWindowHeight(mCachedPtr); }
  109. set { Internal_setOrthoWindowHeight(mCachedPtr, value); }
  110. }
  111. /// <summary>
  112. /// Determines the orthographic window width, for use with orthographic rendering only. The height of the window will be
  113. /// calculated from the aspect ratio. Value is specified in world units.
  114. /// </summary>
  115. [ShowInInspector]
  116. public float OrthoWidth
  117. {
  118. get { return Internal_getOrthoWindowWidth(mCachedPtr); }
  119. set { Internal_setOrthoWindowWidth(mCachedPtr, value); }
  120. }
  121. /// <summary>
  122. /// Determines a priority that determines in which orders the cameras are rendered. This only applies to cameras
  123. /// rendering to the same render target. Higher value means the camera will be rendered sooner.
  124. /// </summary>
  125. [ShowInInspector]
  126. public int Priority
  127. {
  128. get { return Internal_getPriority(mCachedPtr); }
  129. set { Internal_setPriority(mCachedPtr, value); }
  130. }
  131. /// <summary>Determines layer bitfield that is used when determining which object should the camera render.</summary>
  132. [ShowInInspector]
  133. public ulong Layers
  134. {
  135. get { return Internal_getLayers(mCachedPtr); }
  136. set { Internal_setLayers(mCachedPtr, value); }
  137. }
  138. /// <summary>
  139. /// Determines number of samples to use when rendering to this camera. Values larger than 1 will enable MSAA rendering.
  140. /// </summary>
  141. [ShowInInspector]
  142. public uint SampleCount
  143. {
  144. get { return Internal_getMSAACount(mCachedPtr); }
  145. set { Internal_setMSAACount(mCachedPtr, value); }
  146. }
  147. /// <summary>
  148. /// Settings that control rendering for this view. They determine how will the renderer process this view, which effects
  149. /// will be enabled, and what properties will those effects use.
  150. /// </summary>
  151. [ShowInInspector]
  152. public RenderSettings RenderSettings
  153. {
  154. get { return Internal_getRenderSettings(mCachedPtr); }
  155. set { Internal_setRenderSettings(mCachedPtr, value); }
  156. }
  157. /// <summary>
  158. /// Determines whether this is the main application camera. Main camera controls the final render surface that is
  159. /// displayed to the user.
  160. /// </summary>
  161. [ShowInInspector]
  162. public bool Main
  163. {
  164. get { return Internal_isMain(mCachedPtr); }
  165. set { Internal_setMain(mCachedPtr, value); }
  166. }
  167. /// <summary>Converts a point in world space to screen coordinates.</summary>
  168. /// <param name="worldPoint">3D point in world space.</param>
  169. /// <returns>2D point on the render target attached to the camera's viewport, in pixels.</returns>
  170. public Vector2I WorldToScreenPoint(Vector3 worldPoint)
  171. {
  172. Vector2I temp;
  173. Internal_worldToScreenPoint(mCachedPtr, ref worldPoint, out temp);
  174. return temp;
  175. }
  176. /// <summary>Converts a point in world space to normalized device coordinates.</summary>
  177. /// <param name="worldPoint">3D point in world space.</param>
  178. /// <returns>2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.</returns>
  179. public Vector2 WorldToNdcPoint(Vector3 worldPoint)
  180. {
  181. Vector2 temp;
  182. Internal_worldToNdcPoint(mCachedPtr, ref worldPoint, out temp);
  183. return temp;
  184. }
  185. /// <summary>Converts a point in world space to view space coordinates.</summary>
  186. /// <param name="worldPoint">3D point in world space.</param>
  187. /// <returns>3D point relative to the camera's coordinate system.</returns>
  188. public Vector3 WorldToViewPoint(Vector3 worldPoint)
  189. {
  190. Vector3 temp;
  191. Internal_worldToViewPoint(mCachedPtr, ref worldPoint, out temp);
  192. return temp;
  193. }
  194. /// <summary>Converts a point in screen space to a point in world space.</summary>
  195. /// <param name="screenPoint">2D point on the render target attached to the camera's viewport, in pixels.</param>
  196. /// <param name="depth">
  197. /// Depth to place the world point at, in world coordinates. The depth is applied to the vector going from camera origin
  198. /// to the point on the near plane.
  199. /// </param>
  200. /// <returns>3D point in world space.</returns>
  201. public Vector3 ScreenToWorldPoint(Vector2I screenPoint, float depth = 0.5f)
  202. {
  203. Vector3 temp;
  204. Internal_screenToWorldPoint(mCachedPtr, ref screenPoint, depth, out temp);
  205. return temp;
  206. }
  207. /// <summary>Converts a point in screen space to a point in view space.</summary>
  208. /// <param name="screenPoint">2D point on the render target attached to the camera's viewport, in pixels.</param>
  209. /// <param name="depth">
  210. /// Depth to place the world point at, in device depth. The depth is applied to the vector going from camera origin to
  211. /// the point on the near plane.
  212. /// </param>
  213. /// <returns>3D point relative to the camera's coordinate system.</returns>
  214. public Vector3 ScreenToViewPoint(Vector2I screenPoint, float depth = 0.5f)
  215. {
  216. Vector3 temp;
  217. Internal_screenToViewPoint(mCachedPtr, ref screenPoint, depth, out temp);
  218. return temp;
  219. }
  220. /// <summary>Converts a point in screen space to normalized device coordinates.</summary>
  221. /// <param name="screenPoint">2D point on the render target attached to the camera's viewport, in pixels.</param>
  222. /// <returns>2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.</returns>
  223. public Vector2 ScreenToNdcPoint(Vector2I screenPoint)
  224. {
  225. Vector2 temp;
  226. Internal_screenToNdcPoint(mCachedPtr, ref screenPoint, out temp);
  227. return temp;
  228. }
  229. /// <summary>Converts a point in view space to world space.</summary>
  230. /// <param name="viewPoint">3D point relative to the camera's coordinate system.</param>
  231. /// <returns>3D point in world space.</returns>
  232. public Vector3 ViewToWorldPoint(Vector3 viewPoint)
  233. {
  234. Vector3 temp;
  235. Internal_viewToWorldPoint(mCachedPtr, ref viewPoint, out temp);
  236. return temp;
  237. }
  238. /// <summary>Converts a point in view space to screen space.</summary>
  239. /// <param name="viewPoint">3D point relative to the camera's coordinate system.</param>
  240. /// <returns>2D point on the render target attached to the camera's viewport, in pixels.</returns>
  241. public Vector2I ViewToScreenPoint(Vector3 viewPoint)
  242. {
  243. Vector2I temp;
  244. Internal_viewToScreenPoint(mCachedPtr, ref viewPoint, out temp);
  245. return temp;
  246. }
  247. /// <summary>Converts a point in view space to normalized device coordinates.</summary>
  248. /// <param name="viewPoint">3D point relative to the camera's coordinate system.</param>
  249. /// <returns>2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.</returns>
  250. public Vector2 ViewToNdcPoint(Vector3 viewPoint)
  251. {
  252. Vector2 temp;
  253. Internal_viewToNdcPoint(mCachedPtr, ref viewPoint, out temp);
  254. return temp;
  255. }
  256. /// <summary>Converts a point in normalized device coordinates to world space.</summary>
  257. /// <param name="ndcPoint">
  258. /// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
  259. /// </param>
  260. /// <param name="depth">
  261. /// Depth to place the world point at. The depth is applied to the vector going from camera origin to the point on the
  262. /// near plane.
  263. /// </param>
  264. /// <returns>3D point in world space.</returns>
  265. public Vector3 NdcToWorldPoint(Vector2 ndcPoint, float depth = 0.5f)
  266. {
  267. Vector3 temp;
  268. Internal_ndcToWorldPoint(mCachedPtr, ref ndcPoint, depth, out temp);
  269. return temp;
  270. }
  271. /// <summary>Converts a point in normalized device coordinates to view space.</summary>
  272. /// <param name="ndcPoint">
  273. /// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
  274. /// </param>
  275. /// <param name="depth">
  276. /// Depth to place the world point at. The depth is applied to the vector going from camera origin to the point on the
  277. /// near plane.
  278. /// </param>
  279. /// <returns>3D point relative to the camera's coordinate system.</returns>
  280. public Vector3 NdcToViewPoint(Vector2 ndcPoint, float depth = 0.5f)
  281. {
  282. Vector3 temp;
  283. Internal_ndcToViewPoint(mCachedPtr, ref ndcPoint, depth, out temp);
  284. return temp;
  285. }
  286. /// <summary>Converts a point in normalized device coordinates to screen space.</summary>
  287. /// <param name="ndcPoint">
  288. /// 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
  289. /// </param>
  290. /// <returns>2D point on the render target attached to the camera's viewport, in pixels.</returns>
  291. public Vector2I NdcToScreenPoint(Vector2 ndcPoint)
  292. {
  293. Vector2I temp;
  294. Internal_ndcToScreenPoint(mCachedPtr, ref ndcPoint, out temp);
  295. return temp;
  296. }
  297. /// <summary>Converts a point in screen space to a ray in world space.</summary>
  298. /// <param name="screenPoint">2D point on the render target attached to the camera's viewport, in pixels.</param>
  299. /// <returns>Ray in world space, originating at the selected point on the camera near plane.</returns>
  300. public Ray ScreenPointToRay(Vector2I screenPoint)
  301. {
  302. Ray temp;
  303. Internal_screenPointToRay(mCachedPtr, ref screenPoint, out temp);
  304. return temp;
  305. }
  306. /// <summary>
  307. /// Projects a point in view space to normalized device coordinates. Similar to viewToNdcPoint() but preserves the depth
  308. /// component.
  309. /// </summary>
  310. /// <param name="point">3D point relative to the camera's coordinate system.</param>
  311. /// <returns>
  312. /// 3D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport. Z value range depends
  313. /// on active render API.
  314. /// </returns>
  315. public Vector3 ProjectPoint(Vector3 point)
  316. {
  317. Vector3 temp;
  318. Internal_projectPoint(mCachedPtr, ref point, out temp);
  319. return temp;
  320. }
  321. /// <summary>Un-projects a point in normalized device space to view space.</summary>
  322. /// <param name="point">
  323. /// 3D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport. Z value range depends
  324. /// on active render API.
  325. /// </param>
  326. /// <returns>3D point relative to the camera's coordinate system.</returns>
  327. public Vector3 UnprojectPoint(Vector3 point)
  328. {
  329. Vector3 temp;
  330. Internal_unprojectPoint(mCachedPtr, ref point, out temp);
  331. return temp;
  332. }
  333. [MethodImpl(MethodImplOptions.InternalCall)]
  334. private static extern Viewport Internal_getViewport(IntPtr thisPtr);
  335. [MethodImpl(MethodImplOptions.InternalCall)]
  336. private static extern void Internal_setHorzFOV(IntPtr thisPtr, ref Radian fovy);
  337. [MethodImpl(MethodImplOptions.InternalCall)]
  338. private static extern void Internal_getHorzFOV(IntPtr thisPtr, out Radian __output);
  339. [MethodImpl(MethodImplOptions.InternalCall)]
  340. private static extern void Internal_setNearClipDistance(IntPtr thisPtr, float nearDist);
  341. [MethodImpl(MethodImplOptions.InternalCall)]
  342. private static extern float Internal_getNearClipDistance(IntPtr thisPtr);
  343. [MethodImpl(MethodImplOptions.InternalCall)]
  344. private static extern void Internal_setFarClipDistance(IntPtr thisPtr, float farDist);
  345. [MethodImpl(MethodImplOptions.InternalCall)]
  346. private static extern float Internal_getFarClipDistance(IntPtr thisPtr);
  347. [MethodImpl(MethodImplOptions.InternalCall)]
  348. private static extern void Internal_setAspectRatio(IntPtr thisPtr, float ratio);
  349. [MethodImpl(MethodImplOptions.InternalCall)]
  350. private static extern float Internal_getAspectRatio(IntPtr thisPtr);
  351. [MethodImpl(MethodImplOptions.InternalCall)]
  352. private static extern void Internal_getProjectionMatrixRS(IntPtr thisPtr, out Matrix4 __output);
  353. [MethodImpl(MethodImplOptions.InternalCall)]
  354. private static extern void Internal_getViewMatrix(IntPtr thisPtr, out Matrix4 __output);
  355. [MethodImpl(MethodImplOptions.InternalCall)]
  356. private static extern void Internal_setProjectionType(IntPtr thisPtr, ProjectionType pt);
  357. [MethodImpl(MethodImplOptions.InternalCall)]
  358. private static extern ProjectionType Internal_getProjectionType(IntPtr thisPtr);
  359. [MethodImpl(MethodImplOptions.InternalCall)]
  360. private static extern void Internal_setOrthoWindowHeight(IntPtr thisPtr, float h);
  361. [MethodImpl(MethodImplOptions.InternalCall)]
  362. private static extern float Internal_getOrthoWindowHeight(IntPtr thisPtr);
  363. [MethodImpl(MethodImplOptions.InternalCall)]
  364. private static extern void Internal_setOrthoWindowWidth(IntPtr thisPtr, float w);
  365. [MethodImpl(MethodImplOptions.InternalCall)]
  366. private static extern float Internal_getOrthoWindowWidth(IntPtr thisPtr);
  367. [MethodImpl(MethodImplOptions.InternalCall)]
  368. private static extern void Internal_setPriority(IntPtr thisPtr, int priority);
  369. [MethodImpl(MethodImplOptions.InternalCall)]
  370. private static extern int Internal_getPriority(IntPtr thisPtr);
  371. [MethodImpl(MethodImplOptions.InternalCall)]
  372. private static extern void Internal_setLayers(IntPtr thisPtr, ulong layers);
  373. [MethodImpl(MethodImplOptions.InternalCall)]
  374. private static extern ulong Internal_getLayers(IntPtr thisPtr);
  375. [MethodImpl(MethodImplOptions.InternalCall)]
  376. private static extern void Internal_setMSAACount(IntPtr thisPtr, uint count);
  377. [MethodImpl(MethodImplOptions.InternalCall)]
  378. private static extern uint Internal_getMSAACount(IntPtr thisPtr);
  379. [MethodImpl(MethodImplOptions.InternalCall)]
  380. private static extern void Internal_setRenderSettings(IntPtr thisPtr, RenderSettings settings);
  381. [MethodImpl(MethodImplOptions.InternalCall)]
  382. private static extern RenderSettings Internal_getRenderSettings(IntPtr thisPtr);
  383. [MethodImpl(MethodImplOptions.InternalCall)]
  384. private static extern void Internal_worldToScreenPoint(IntPtr thisPtr, ref Vector3 worldPoint, out Vector2I __output);
  385. [MethodImpl(MethodImplOptions.InternalCall)]
  386. private static extern void Internal_worldToNdcPoint(IntPtr thisPtr, ref Vector3 worldPoint, out Vector2 __output);
  387. [MethodImpl(MethodImplOptions.InternalCall)]
  388. private static extern void Internal_worldToViewPoint(IntPtr thisPtr, ref Vector3 worldPoint, out Vector3 __output);
  389. [MethodImpl(MethodImplOptions.InternalCall)]
  390. private static extern void Internal_screenToWorldPoint(IntPtr thisPtr, ref Vector2I screenPoint, float depth, out Vector3 __output);
  391. [MethodImpl(MethodImplOptions.InternalCall)]
  392. private static extern void Internal_screenToViewPoint(IntPtr thisPtr, ref Vector2I screenPoint, float depth, out Vector3 __output);
  393. [MethodImpl(MethodImplOptions.InternalCall)]
  394. private static extern void Internal_screenToNdcPoint(IntPtr thisPtr, ref Vector2I screenPoint, out Vector2 __output);
  395. [MethodImpl(MethodImplOptions.InternalCall)]
  396. private static extern void Internal_viewToWorldPoint(IntPtr thisPtr, ref Vector3 viewPoint, out Vector3 __output);
  397. [MethodImpl(MethodImplOptions.InternalCall)]
  398. private static extern void Internal_viewToScreenPoint(IntPtr thisPtr, ref Vector3 viewPoint, out Vector2I __output);
  399. [MethodImpl(MethodImplOptions.InternalCall)]
  400. private static extern void Internal_viewToNdcPoint(IntPtr thisPtr, ref Vector3 viewPoint, out Vector2 __output);
  401. [MethodImpl(MethodImplOptions.InternalCall)]
  402. private static extern void Internal_ndcToWorldPoint(IntPtr thisPtr, ref Vector2 ndcPoint, float depth, out Vector3 __output);
  403. [MethodImpl(MethodImplOptions.InternalCall)]
  404. private static extern void Internal_ndcToViewPoint(IntPtr thisPtr, ref Vector2 ndcPoint, float depth, out Vector3 __output);
  405. [MethodImpl(MethodImplOptions.InternalCall)]
  406. private static extern void Internal_ndcToScreenPoint(IntPtr thisPtr, ref Vector2 ndcPoint, out Vector2I __output);
  407. [MethodImpl(MethodImplOptions.InternalCall)]
  408. private static extern void Internal_screenPointToRay(IntPtr thisPtr, ref Vector2I screenPoint, out Ray __output);
  409. [MethodImpl(MethodImplOptions.InternalCall)]
  410. private static extern void Internal_projectPoint(IntPtr thisPtr, ref Vector3 point, out Vector3 __output);
  411. [MethodImpl(MethodImplOptions.InternalCall)]
  412. private static extern void Internal_unprojectPoint(IntPtr thisPtr, ref Vector3 point, out Vector3 __output);
  413. [MethodImpl(MethodImplOptions.InternalCall)]
  414. private static extern void Internal_setMain(IntPtr thisPtr, bool main);
  415. [MethodImpl(MethodImplOptions.InternalCall)]
  416. private static extern bool Internal_isMain(IntPtr thisPtr);
  417. }
  418. /** @} */
  419. }