using BansheeEngine; namespace BansheeEditor { /// /// Handles drawing of gizmos for the component. /// internal class LightGizmos { /// /// Method called by the runtime when gizmos are meant to be drawn. /// /// Light to draw gizmos for. [DrawGizmo(DrawGizmoFlags.Selected)] private static void Draw(Light light) { Vector3 position = light.SceneObject.Position; Gizmos.Color = Color.Yellow; switch (light.Type) { case LightType.Directional: { Vector3 right = light.SceneObject.Rotation.Rotate(Vector3.XAxis); Vector3 up = light.SceneObject.Rotation.Rotate(Vector3.YAxis); Vector3 forward = light.SceneObject.Forward; Vector3 topLeft = position - right + up; Vector3 topRight = position + right + up; Vector3 botLeft = position - right - up; Vector3 botRight = position + right - up; Gizmos.DrawLine(topLeft, topRight); Gizmos.DrawLine(topRight, botRight); Gizmos.DrawLine(botRight, botLeft); Gizmos.DrawLine(botLeft, topLeft); Gizmos.DrawLine(topLeft, topLeft + forward*5.0f); Gizmos.DrawLine(topRight, topRight + forward*5.0f); Gizmos.DrawLine(botRight, botRight + forward*5.0f); Gizmos.DrawLine(botLeft, botLeft + forward*5.0f); } break; case LightType.Point: Gizmos.DrawWireSphere(position, light.Range); break; case LightType.Spot: { Vector3 right = light.SceneObject.Rotation.Rotate(Vector3.XAxis); Vector3 up = light.SceneObject.Rotation.Rotate(Vector3.YAxis); Vector3 forward = light.SceneObject.Forward; float discRadius = light.Range*MathEx.Tan(light.SpotAngle*0.5f); Gizmos.DrawLine(position, position + forward * light.Range + up * discRadius); Gizmos.DrawLine(position, position + forward * light.Range - up * discRadius); Gizmos.DrawLine(position, position + forward * light.Range + right * discRadius); Gizmos.DrawLine(position, position + forward * light.Range - right * discRadius); float falloffDiscRadius = light.Range * MathEx.Tan(light.SpotFalloffAngle * 0.5f); Gizmos.DrawWireDisc(position + forward * light.Range, forward, discRadius); Gizmos.DrawWireDisc(position + forward * light.Range, forward, falloffDiscRadius); } break; } } } }