void OnRepaint(SceneView sceneView, Event e) { if (primaryTargetBrush != null) { // Use a helper method to draw a visualisation of the clipping plane float largestExtent = GetBounds().GetLargestExtent(); float planeSize = largestExtent * 4f; // clipPlane. SabreGraphics.DrawPlane(displayPlane, planePosition, new Color(0f, 1f, 0f, .3f), new Color(1f, 0f, 0f, .3f), planeSize); // Selected brush green outline SabreGraphics.GetSelectedBrushMaterial().SetPass(0); // Draw black lines where the clip plane intersects the brushes if (!sceneView.camera.orthographic || EditorHelper.GetSceneViewCamera(sceneView) == EditorHelper.SceneViewCamera.Other) { GL.Begin(GL.LINES); GL.Color(Color.black); foreach (PrimitiveBrush brush in targetBrushes) { Polygon[] polygons = brush.GenerateTransformedPolygons(); foreach (Polygon polygon in polygons) { Vector3 position1; Vector3 position2; if (Polygon.PlanePolygonIntersection(polygon, out position1, out position2, displayPlane)) { GL.Vertex(position1); GL.Vertex(position2); } } } GL.End(); } if (displayPoint) { Camera sceneViewCamera = sceneView.camera; SabreGraphics.GetVertexMaterial().SetPass(0); GL.PushMatrix(); GL.LoadPixelMatrix(); GL.Begin(GL.QUADS); // Draw points in reverse order because we want the precedence to be Red, Green, Blue GL.Color(Color.blue); Vector3 target = sceneViewCamera.WorldToScreenPoint(points[2]); if (target.z > 0) { // Make it pixel perfect target = MathHelper.RoundVector3(target); SabreGraphics.DrawBillboardQuad(target, 8, 8); } GL.Color(Color.green); target = sceneViewCamera.WorldToScreenPoint(points[1]); if (target.z > 0) { // Make it pixel perfect target = MathHelper.RoundVector3(target); SabreGraphics.DrawBillboardQuad(target, 8, 8); } GL.Color(Color.red); target = sceneViewCamera.WorldToScreenPoint(points[0]); if (target.z > 0) { // Make it pixel perfect target = MathHelper.RoundVector3(target); SabreGraphics.DrawBillboardQuad(target, 8, 8); } GL.End(); GL.PopMatrix(); } } // Draw UI specific to this editor // GUI.backgroundColor = Color.red; Rect rectangle = new Rect(0, 50, 210, 130); GUIStyle toolbar = new GUIStyle(EditorStyles.toolbar); toolbar.normal.background = SabreGraphics.ClearTexture; toolbar.fixedHeight = rectangle.height; GUILayout.Window(140006, rectangle, OnToolbarGUI, "", toolbar); }