SceneGrid.cs 2.1 KB

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