CameraGizmo.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2017 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using bs;
  4. namespace bs.Editor
  5. {
  6. /** @addtogroup Gizmos
  7. * @{
  8. */
  9. /// <summary>
  10. /// Handles drawing of gizmos for the <see cref="Camera"/> component.
  11. /// </summary>
  12. internal class CameraGizmo
  13. {
  14. /// <summary>
  15. /// Draws camera shape gizmos when a camera is selected.
  16. /// </summary>
  17. /// <param name="camera">Camera to draw the gizmos for.</param>
  18. [DrawGizmo(DrawGizmoFlags.Selected)]
  19. private static void Draw(Camera camera)
  20. {
  21. SceneObject so = camera.SceneObject;
  22. Gizmos.Color = Color.Yellow;
  23. Gizmos.Transform = Matrix4.TRS(so.Position, Quaternion.LookRotation(so.Rotation.Forward, so.Rotation.Up), Vector3.One);
  24. Gizmos.DrawFrustum(Vector3.Zero, camera.AspectRatio, camera.FieldOfView, camera.NearClipPlane,
  25. camera.FarClipPlane);
  26. }
  27. /// <summary>
  28. /// Draws camera icon in scene view.
  29. /// </summary>
  30. /// <param name="camera">Camera to draw the icon for.</param>
  31. [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
  32. private static void DrawIcon(Camera camera)
  33. {
  34. Gizmos.DrawIcon(camera.SceneObject.Position, EditorBuiltin.GetSceneViewIcon(SceneViewIcon.Camera), false);
  35. }
  36. }
  37. /** @} */
  38. }