SceneGrid.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /// <summary>
  7. /// Determines how is grid drawn.
  8. /// </summary>
  9. internal enum GridMode // Note: Must match C++ enum GridMode
  10. {
  11. Perspective,
  12. OrthoX,
  13. OrthoY,
  14. OrthoZ,
  15. OrthoNegX,
  16. OrthoNegY,
  17. OrthoNegZ
  18. }
  19. /// <summary>
  20. /// Handles rendering of the scene grid for the specified camera. Grid properties are controlled through
  21. /// <see cref="EditorSettings"/>.
  22. /// </summary>
  23. internal sealed class SceneGrid : ScriptObject
  24. {
  25. /// <summary>
  26. /// Creates a new scene grid renderer.
  27. /// </summary>
  28. /// <param name="sceneCamera">Camera into which the grid will be rendered.</param>
  29. internal SceneGrid(Camera sceneCamera)
  30. {
  31. Internal_Create(this, sceneCamera.Native.GetCachedPtr());
  32. }
  33. /// <summary>
  34. /// Queues grid drawing for this frame.
  35. /// </summary>
  36. internal void Draw()
  37. {
  38. Internal_Draw(mCachedPtr);
  39. }
  40. /// <summary>
  41. /// Changes how is the grid drawn.
  42. /// </summary>
  43. /// <param name="mode">Determines orientation and position of the grid so it suits the camera in the provided mode.
  44. /// </param>
  45. internal void SetMode(GridMode mode)
  46. {
  47. Internal_SetMode(mCachedPtr, mode);
  48. }
  49. [MethodImpl(MethodImplOptions.InternalCall)]
  50. private static extern void Internal_Create(SceneGrid managedInstance, IntPtr camera);
  51. [MethodImpl(MethodImplOptions.InternalCall)]
  52. private static extern void Internal_Draw(IntPtr thisPtr);
  53. [MethodImpl(MethodImplOptions.InternalCall)]
  54. private static extern void Internal_SetMode(IntPtr thisPtr, GridMode mode);
  55. }
  56. }