Camera.cs 12 KB

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