internal ViewportOverlay(IViewport viewport) { _viewport = viewport; _width = -1; _height = -1; _buffer = Engine.Engine.Interface.CreateBuffer(); _buffer.Update(new [] { new VertexStandard { Position = new Vector3(0, 0, 0), Texture = new Vector2(0, 0) }, new VertexStandard { Position = new Vector3(0, 1, 0), Texture = new Vector2(0, 1) }, new VertexStandard { Position = new Vector3(1, 1, 0), Texture = new Vector2(1, 1) }, new VertexStandard { Position = new Vector3(1, 0, 0), Texture = new Vector2(1, 0) }, }, new uint[] { 0, 2, 1, 0, 3, 2 }); }
private void Update() { if (!(_viewport.Camera is OrthographicCamera oc)) { return; } if (_grid == null) { return; } var newBounds = GetValidatedBounds(oc, 50); var min = oc.Expand(new Vector3(newBounds.Left, newBounds.Top, 0)); var max = oc.Expand(new Vector3(newBounds.Right, newBounds.Bottom, 0)); var normal = Vector3.One - oc.Expand(new Vector3(1, 1, 0)); var points = new List <VertexStandard>(); var indices = new List <uint>(); uint idx = 0; foreach (var line in _grid.GetLines(normal, oc.Zoom, min, max).OrderBy(x => (int)x.Type)) { var c = GetColorForGridLineType(line.Type); var col = new Vector4(c.R, c.G, c.B, c.A) / 255f; points.Add(new VertexStandard { Position = line.Line.Start, Normal = normal, Colour = col, Texture = Vector2.Zero, Tint = Vector4.One }); points.Add(new VertexStandard { Position = line.Line.End, Normal = normal, Colour = col, Texture = Vector2.Zero, Tint = Vector4.One }); indices.Add(idx++); indices.Add(idx++); } _buffer.Update(points, indices); _indexCount = idx; _validated = true; _currentType = oc.ViewType; _currentZoom = oc.Zoom; _currentBounds = newBounds; }