Camera.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. namespace BansheeEngine
  7. {
  8. // Don't reorder, used by native code
  9. public enum ProjectionType
  10. {
  11. Orthographic, Perspective
  12. }
  13. // Don't reorder, used by native code
  14. [Flags]
  15. public enum ClearFlags
  16. {
  17. Color = 0x01, Depth = 0x02, Stencil = 0x04
  18. }
  19. public class Camera : Component
  20. {
  21. public float aspectRatio
  22. {
  23. get { return Internal_GetAspect(mCachedPtr); }
  24. set { Internal_SetAspect(mCachedPtr, value); }
  25. }
  26. public float nearClipPlane
  27. {
  28. get { return Internal_GetNearClip(mCachedPtr); }
  29. set { Internal_SetNearClip(mCachedPtr, value); }
  30. }
  31. public float farClipPlane
  32. {
  33. get { return Internal_GetFarClip(mCachedPtr); }
  34. set { Internal_SetFarClip(mCachedPtr, value); }
  35. }
  36. public Degree fieldOfView
  37. {
  38. get { return Internal_GetFieldOfView(mCachedPtr); }
  39. set { Internal_SetFieldOfView(mCachedPtr, value); }
  40. }
  41. public Rect2 viewportRect
  42. {
  43. get { return Internal_GetViewportRect(mCachedPtr); }
  44. set { Internal_SetViewportRect(mCachedPtr, value); }
  45. }
  46. public ProjectionType projectionType
  47. {
  48. get { return Internal_GetProjectionType(mCachedPtr); }
  49. set { Internal_SetProjectionType(mCachedPtr, value); }
  50. }
  51. public float orthoHeight
  52. {
  53. get { return Internal_GetOrthographicHeight(mCachedPtr); }
  54. set { Internal_SetOrthographicHeight(mCachedPtr, value); }
  55. }
  56. public float orthoWidth
  57. {
  58. get { return Internal_GetOrthographicWidth(mCachedPtr); }
  59. }
  60. public Color clearColor
  61. {
  62. get { return Internal_GetClearColor(mCachedPtr); }
  63. set { Internal_SetClearColor(mCachedPtr, value); }
  64. }
  65. public float clearDepth
  66. {
  67. get { return Internal_GetDepthClearValue(mCachedPtr); }
  68. set { Internal_SetDepthClearValue(mCachedPtr, value); }
  69. }
  70. public UInt16 clearStencil
  71. {
  72. get { return Internal_GetStencilClearValue(mCachedPtr); }
  73. set { Internal_SetStencilClearValue(mCachedPtr, value); }
  74. }
  75. public ClearFlags clearFlags
  76. {
  77. get { return Internal_GetClearFlags(mCachedPtr); }
  78. set { Internal_SetClearFlags(mCachedPtr, value); }
  79. }
  80. public int priority
  81. {
  82. get { return Internal_GetPriority(mCachedPtr); }
  83. set { Internal_SetPriority(mCachedPtr, value); }
  84. }
  85. public UInt64 layers
  86. {
  87. get { return Internal_GetLayers(mCachedPtr); }
  88. set { Internal_SetLayers(mCachedPtr, value); }
  89. }
  90. public Matrix4 projMatrix
  91. {
  92. get { return Internal_GetProjMatrix(mCachedPtr); }
  93. }
  94. public Matrix4 projMatrixInv
  95. {
  96. get { return Internal_GetProjMatrixInv(mCachedPtr); }
  97. }
  98. public Matrix4 viewMatrix
  99. {
  100. get { return Internal_GetViewMatrix(mCachedPtr); }
  101. }
  102. public Matrix4 viewMatrixInv
  103. {
  104. get { return Internal_GetViewMatrixInv(mCachedPtr); }
  105. }
  106. public int widthPixels
  107. {
  108. get { return Internal_GetWidthPixels(mCachedPtr); }
  109. }
  110. public int heightPixels
  111. {
  112. get { return Internal_GetHeightPixels(mCachedPtr); }
  113. }
  114. public Vector2I WorldToScreen(Vector3 value) { return Internal_WorldToScreen(mCachedPtr, value); }
  115. public Vector2 WorldToClip(Vector3 value) { return Internal_WorldToClip(mCachedPtr, value); }
  116. public Vector3 WorldToView(Vector3 value) { return Internal_WorldToView(mCachedPtr, value); }
  117. public Vector3 ScreenToWorld(Vector2I value) { return Internal_ScreenToWorld(mCachedPtr, value); }
  118. public Vector3 ScreenToView(Vector2I value) { return Internal_ScreenToView(mCachedPtr, value); }
  119. public Vector2 ScreenToClip(Vector2I value) { return Internal_ScreenToClip(mCachedPtr, value); }
  120. public Vector3 ViewToWorld(Vector3 value) { return Internal_ViewToWorld(mCachedPtr, value); }
  121. public Vector2I ViewToScreen(Vector3 value) { return Internal_ViewToScreen(mCachedPtr, value); }
  122. public Vector2 ViewToClip(Vector3 value) { return Internal_ViewToClip(mCachedPtr, value); }
  123. public Vector3 ClipToWorld(Vector2 value) { return Internal_ClipToWorld(mCachedPtr, value); }
  124. public Vector3 ClipToView(Vector2 value) { return Internal_ClipToView(mCachedPtr, value); }
  125. public Vector2I ClipToScreen(Vector2 value) { return Internal_ClipToScreen(mCachedPtr, value); }
  126. public Ray ScreenToWorldRay(Vector2I value) { return Internal_ScreenToWorldRay(mCachedPtr, value); }
  127. public Vector3 ProjectPoint(Vector3 value) { return Internal_ProjectPoint(mCachedPtr, value); }
  128. public Vector3 UnprojectPoint(Vector3 value) { return Internal_UnprojectPoint(mCachedPtr, value); }
  129. // TODO - Add RenderTexture
  130. [MethodImpl(MethodImplOptions.InternalCall)]
  131. private static extern float Internal_GetAspect(IntPtr instance);
  132. [MethodImpl(MethodImplOptions.InternalCall)]
  133. private static extern void Internal_SetAspect(IntPtr instance, float value);
  134. [MethodImpl(MethodImplOptions.InternalCall)]
  135. private static extern float Internal_GetNearClip(IntPtr instance);
  136. [MethodImpl(MethodImplOptions.InternalCall)]
  137. private static extern void Internal_SetNearClip(IntPtr instance, float value);
  138. [MethodImpl(MethodImplOptions.InternalCall)]
  139. private static extern float Internal_GetFarClip(IntPtr instance);
  140. [MethodImpl(MethodImplOptions.InternalCall)]
  141. private static extern void Internal_SetFarClip(IntPtr instance, float value);
  142. [MethodImpl(MethodImplOptions.InternalCall)]
  143. private static extern Degree Internal_GetFieldOfView(IntPtr instance);
  144. [MethodImpl(MethodImplOptions.InternalCall)]
  145. private static extern void Internal_SetFieldOfView(IntPtr instance, Degree value);
  146. [MethodImpl(MethodImplOptions.InternalCall)]
  147. private static extern Rect2 Internal_GetViewportRect(IntPtr instance);
  148. [MethodImpl(MethodImplOptions.InternalCall)]
  149. private static extern void Internal_SetViewportRect(IntPtr instance, Rect2 value);
  150. [MethodImpl(MethodImplOptions.InternalCall)]
  151. private static extern ProjectionType Internal_GetProjectionType(IntPtr instance);
  152. [MethodImpl(MethodImplOptions.InternalCall)]
  153. private static extern void Internal_SetProjectionType(IntPtr instance, ProjectionType value);
  154. [MethodImpl(MethodImplOptions.InternalCall)]
  155. private static extern float Internal_GetOrthographicHeight(IntPtr instance);
  156. [MethodImpl(MethodImplOptions.InternalCall)]
  157. private static extern void Internal_SetOrthographicHeight(IntPtr instance, float value);
  158. [MethodImpl(MethodImplOptions.InternalCall)]
  159. private static extern float Internal_GetOrthographicWidth(IntPtr instance);
  160. [MethodImpl(MethodImplOptions.InternalCall)]
  161. private static extern Color Internal_GetClearColor(IntPtr instance);
  162. [MethodImpl(MethodImplOptions.InternalCall)]
  163. private static extern void Internal_SetClearColor(IntPtr instance, Color value);
  164. [MethodImpl(MethodImplOptions.InternalCall)]
  165. private static extern float Internal_GetDepthClearValue(IntPtr instance);
  166. [MethodImpl(MethodImplOptions.InternalCall)]
  167. private static extern void Internal_SetDepthClearValue(IntPtr instance, float value);
  168. [MethodImpl(MethodImplOptions.InternalCall)]
  169. private static extern UInt16 Internal_GetStencilClearValue(IntPtr instance);
  170. [MethodImpl(MethodImplOptions.InternalCall)]
  171. private static extern void Internal_SetStencilClearValue(IntPtr instance, UInt16 value);
  172. [MethodImpl(MethodImplOptions.InternalCall)]
  173. private static extern ClearFlags Internal_GetClearFlags(IntPtr instance);
  174. [MethodImpl(MethodImplOptions.InternalCall)]
  175. private static extern void Internal_SetClearFlags(IntPtr instance, ClearFlags value);
  176. [MethodImpl(MethodImplOptions.InternalCall)]
  177. private static extern int Internal_GetPriority(IntPtr instance);
  178. [MethodImpl(MethodImplOptions.InternalCall)]
  179. private static extern void Internal_SetPriority(IntPtr instance, int value);
  180. [MethodImpl(MethodImplOptions.InternalCall)]
  181. private static extern UInt64 Internal_GetLayers(IntPtr instance);
  182. [MethodImpl(MethodImplOptions.InternalCall)]
  183. private static extern void Internal_SetLayers(IntPtr instance, UInt64 value);
  184. [MethodImpl(MethodImplOptions.InternalCall)]
  185. private static extern Matrix4 Internal_GetProjMatrix(IntPtr instance);
  186. [MethodImpl(MethodImplOptions.InternalCall)]
  187. private static extern Matrix4 Internal_GetProjMatrixInv(IntPtr instance);
  188. [MethodImpl(MethodImplOptions.InternalCall)]
  189. private static extern Matrix4 Internal_GetViewMatrix(IntPtr instance);
  190. [MethodImpl(MethodImplOptions.InternalCall)]
  191. private static extern Matrix4 Internal_GetViewMatrixInv(IntPtr instance);
  192. [MethodImpl(MethodImplOptions.InternalCall)]
  193. private static extern int Internal_GetWidthPixels(IntPtr instance);
  194. [MethodImpl(MethodImplOptions.InternalCall)]
  195. private static extern int Internal_GetHeightPixels(IntPtr instance);
  196. [MethodImpl(MethodImplOptions.InternalCall)]
  197. private static extern Vector2I Internal_WorldToScreen(IntPtr instance, Vector3 value);
  198. [MethodImpl(MethodImplOptions.InternalCall)]
  199. private static extern Vector2 Internal_WorldToClip(IntPtr instance, Vector3 value);
  200. [MethodImpl(MethodImplOptions.InternalCall)]
  201. private static extern Vector3 Internal_WorldToView(IntPtr instance, Vector3 value);
  202. [MethodImpl(MethodImplOptions.InternalCall)]
  203. private static extern Vector3 Internal_ScreenToWorld(IntPtr instance, Vector2I value);
  204. [MethodImpl(MethodImplOptions.InternalCall)]
  205. private static extern Vector3 Internal_ScreenToView(IntPtr instance, Vector2I value);
  206. [MethodImpl(MethodImplOptions.InternalCall)]
  207. private static extern Vector2 Internal_ScreenToClip(IntPtr instance, Vector2I value);
  208. [MethodImpl(MethodImplOptions.InternalCall)]
  209. private static extern Vector3 Internal_ViewToWorld(IntPtr instance, Vector3 value);
  210. [MethodImpl(MethodImplOptions.InternalCall)]
  211. private static extern Vector2I Internal_ViewToScreen(IntPtr instance, Vector3 value);
  212. [MethodImpl(MethodImplOptions.InternalCall)]
  213. private static extern Vector2 Internal_ViewToClip(IntPtr instance, Vector3 value);
  214. [MethodImpl(MethodImplOptions.InternalCall)]
  215. private static extern Vector3 Internal_ClipToWorld(IntPtr instance, Vector2 value);
  216. [MethodImpl(MethodImplOptions.InternalCall)]
  217. private static extern Vector3 Internal_ClipToView(IntPtr instance, Vector2 value);
  218. [MethodImpl(MethodImplOptions.InternalCall)]
  219. private static extern Vector2I Internal_ClipToScreen(IntPtr instance, Vector2 value);
  220. [MethodImpl(MethodImplOptions.InternalCall)]
  221. private static extern Ray Internal_ScreenToWorldRay(IntPtr instance, Vector2I value);
  222. [MethodImpl(MethodImplOptions.InternalCall)]
  223. private static extern Vector3 Internal_ProjectPoint(IntPtr instance, Vector3 value);
  224. [MethodImpl(MethodImplOptions.InternalCall)]
  225. private static extern Vector3 Internal_UnprojectPoint(IntPtr instance, Vector3 value);
  226. }
  227. }