ReflectionProbeGizmo.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 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="ReflectionProbe"/> component.
  11. /// </summary>
  12. internal class ReflectionProbeGizmos
  13. {
  14. /// <summary>
  15. /// Draws the reflection probe shape.
  16. /// </summary>
  17. /// <param name="reflProbe">Reflection probe to draw gizmos for.</param>
  18. [DrawGizmo(DrawGizmoFlags.Selected)]
  19. private static void Draw(ReflectionProbe reflProbe)
  20. {
  21. Vector3 position = reflProbe.SceneObject.Position;
  22. Gizmos.Color = Color.Yellow;
  23. switch (reflProbe.Type)
  24. {
  25. case ReflectionProbeType.Box:
  26. SceneObject so = reflProbe.SceneObject;
  27. Gizmos.Transform = Matrix4.TRS(so.Position, so.Rotation, Vector3.One);
  28. Vector3 scaledExtents = reflProbe.Extents * so.Scale;
  29. Gizmos.DrawWireCube(Vector3.Zero, scaledExtents);
  30. break;
  31. case ReflectionProbeType.Sphere:
  32. Gizmos.DrawWireSphere(position, reflProbe.Radius);
  33. break;
  34. }
  35. }
  36. /// <summary>
  37. /// Draws reflection probe icon in scene view.
  38. /// </summary>
  39. /// <param name="reflProbe">Reflection probe to draw the icon for.</param>
  40. [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
  41. private static void DrawIcon(ReflectionProbe reflProbe)
  42. {
  43. Gizmos.DrawIcon(reflProbe.SceneObject.Position,
  44. EditorBuiltin.GetSceneViewIcon(SceneViewIcon.ReflectionProbe), false);
  45. }
  46. }
  47. /** @} */
  48. }