Camera.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace AtomicEngine
  4. {
  5. public partial class Camera : Component
  6. {
  7. /// Return ray corresponding to normalized screen coordinates (0 - 1), with origin on the near clip plane.
  8. public Ray GetScreenRay(float x, float y)
  9. {
  10. csi_Atomic_Camera_GetScreenRay(nativeInstance, x, y, ref GetScreenRayReturnValue);
  11. return GetScreenRayReturnValue;
  12. }
  13. public Plane ClipPlane
  14. {
  15. get
  16. {
  17. return GetClipPlane();
  18. }
  19. set
  20. {
  21. SetClipPlane(value);
  22. }
  23. }
  24. public Plane ReflectionPlane
  25. {
  26. get
  27. {
  28. return GetReflectionPlane();
  29. }
  30. set
  31. {
  32. SetReflectionPlane(value);
  33. }
  34. }
  35. public Plane GetClipPlane()
  36. {
  37. Plane plane = new Plane();
  38. csi_Atomic_Camera_GetClipPlane(nativeInstance, ref plane);
  39. return plane;
  40. }
  41. public Plane GetReflectionPlane()
  42. {
  43. Plane plane = new Plane();
  44. csi_Atomic_Camera_GetReflectionPlane(nativeInstance, ref plane);
  45. return plane;
  46. }
  47. public void SetClipPlane(Plane plane)
  48. {
  49. csi_Atomic_Camera_SetClipPlane(nativeInstance, ref plane);
  50. }
  51. public void SetReflectionPlane(Plane plane)
  52. {
  53. csi_Atomic_Camera_SetReflectionPlane(nativeInstance, ref plane);
  54. }
  55. private Ray GetScreenRayReturnValue = new Ray();
  56. [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  57. private static extern void csi_Atomic_Camera_GetScreenRay(IntPtr self, float x, float y, ref Ray retValue);
  58. [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  59. private static extern void csi_Atomic_Camera_GetClipPlane(IntPtr self, ref Plane retValue);
  60. [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  61. private static extern void csi_Atomic_Camera_GetReflectionPlane(IntPtr self, ref Plane retValue);
  62. [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  63. private static extern void csi_Atomic_Camera_SetClipPlane(IntPtr self, ref Plane retValue);
  64. [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  65. private static extern void csi_Atomic_Camera_SetReflectionPlane(IntPtr self, ref Plane retValue);
  66. };
  67. }