SceneGrid.cs 2.1 KB

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