public void DrawOverlay(Camera camera, Color color, float innerFactor, float outerFactor) { Vector2 viewportSize = camera.ViewportSize; Vector2 vector = new Vector2(0f, 0f); Vector2 vector2 = new Vector2(viewportSize.X, 0f); Vector2 vector3 = new Vector2(viewportSize.X, viewportSize.Y); Vector2 vector4 = new Vector2(0f, viewportSize.Y); Vector2 p = new Vector2(viewportSize.X / 2f, viewportSize.Y / 2f); Color color2 = color * outerFactor; Color color3 = color * innerFactor; FlatBatch2D flatBatch2D = m_primitivesRenderer2D.FlatBatch(0, DepthStencilState.None, null, BlendState.AlphaBlend); int count = flatBatch2D.TriangleVertices.Count; flatBatch2D.QueueTriangle(vector, vector2, p, 0f, color2, color2, color3); flatBatch2D.QueueTriangle(vector2, vector3, p, 0f, color2, color2, color3); flatBatch2D.QueueTriangle(vector3, vector4, p, 0f, color2, color2, color3); flatBatch2D.QueueTriangle(vector4, vector, p, 0f, color2, color2, color3); flatBatch2D.TransformTriangles(camera.ViewportMatrix, count); flatBatch2D.Flush(); }
public override void Draw(DrawContext dc) { if (m_parsingPending) { ParsePoints(); } Color color = Color * base.GlobalColorTransform; FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(1, DepthStencilState.None); int count = flatBatch2D.TriangleVertices.Count; for (int i = 0; i < m_vertices.Count; i += 3) { Vector2 p = m_startOffset + m_vertices[i]; Vector2 p2 = m_startOffset + m_vertices[i + 1]; Vector2 p3 = m_startOffset + m_vertices[i + 2]; flatBatch2D.QueueTriangle(p, p2, p3, 0f, color); } flatBatch2D.TransformTriangles(base.GlobalTransform, count); }
public static void QueueBevelledRectangle(TexturedBatch2D texturedBatch, FlatBatch2D flatBatch, Vector2 c1, Vector2 c2, float depth, float bevelSize, Color color, Color bevelColor, Color shadowColor, float ambientLight, float directionalLight, float textureScale) { float num = MathUtils.Abs(bevelSize); Vector2 vector = c1; Vector2 vector2 = c1 + new Vector2(num); Vector2 vector3 = c2 - new Vector2(num); Vector2 vector4 = c2; Vector2 vector5 = c2 + new Vector2(1.5f * num); float x = vector.X; float x2 = vector2.X; float x3 = vector3.X; float x4 = vector4.X; float x5 = vector5.X; float y = vector.Y; float y2 = vector2.Y; float y3 = vector3.Y; float y4 = vector4.Y; float y5 = vector5.Y; float num2 = MathUtils.Saturate(((bevelSize > 0f) ? 1f : (-0.75f)) * directionalLight + ambientLight); float num3 = MathUtils.Saturate(((bevelSize > 0f) ? (-0.75f) : 1f) * directionalLight + ambientLight); float num4 = MathUtils.Saturate(((bevelSize > 0f) ? (-0.375f) : 0.5f) * directionalLight + ambientLight); float num5 = MathUtils.Saturate(((bevelSize > 0f) ? 0.5f : (-0.375f)) * directionalLight + ambientLight); float num6 = MathUtils.Saturate(0f * directionalLight + ambientLight); Color color2 = new Color((byte)(num4 * (float)(int)bevelColor.R), (byte)(num4 * (float)(int)bevelColor.G), (byte)(num4 * (float)(int)bevelColor.B), bevelColor.A); Color color3 = new Color((byte)(num5 * (float)(int)bevelColor.R), (byte)(num5 * (float)(int)bevelColor.G), (byte)(num5 * (float)(int)bevelColor.B), bevelColor.A); Color color4 = new Color((byte)(num2 * (float)(int)bevelColor.R), (byte)(num2 * (float)(int)bevelColor.G), (byte)(num2 * (float)(int)bevelColor.B), bevelColor.A); Color color5 = new Color((byte)(num3 * (float)(int)bevelColor.R), (byte)(num3 * (float)(int)bevelColor.G), (byte)(num3 * (float)(int)bevelColor.B), bevelColor.A); Color color6 = new Color((byte)(num6 * (float)(int)color.R), (byte)(num6 * (float)(int)color.G), (byte)(num6 * (float)(int)color.B), color.A); if (texturedBatch != null) { float num7 = textureScale / (float)texturedBatch.Texture.Width; float num8 = textureScale / (float)texturedBatch.Texture.Height; float num9 = x * num7; float num10 = y * num8; float x6 = num9; float x7 = (x2 - x) * num7 + num9; float x8 = (x3 - x) * num7 + num9; float x9 = (x4 - x) * num7 + num9; float y6 = num10; float y7 = (y2 - y) * num8 + num10; float y8 = (y3 - y) * num8 + num10; float y9 = (y4 - y) * num8 + num10; if (bevelColor.A > 0) { texturedBatch.QueueQuad(new Vector2(x, y), new Vector2(x2, y2), new Vector2(x3, y2), new Vector2(x4, y), depth, new Vector2(x6, y6), new Vector2(x7, y7), new Vector2(x8, y7), new Vector2(x9, y6), color4); texturedBatch.QueueQuad(new Vector2(x3, y2), new Vector2(x3, y3), new Vector2(x4, y4), new Vector2(x4, y), depth, new Vector2(x8, y7), new Vector2(x8, y8), new Vector2(x9, y9), new Vector2(x9, y6), color3); texturedBatch.QueueQuad(new Vector2(x, y4), new Vector2(x4, y4), new Vector2(x3, y3), new Vector2(x2, y3), depth, new Vector2(x6, y9), new Vector2(x9, y9), new Vector2(x8, y8), new Vector2(x7, y8), color5); texturedBatch.QueueQuad(new Vector2(x, y), new Vector2(x, y4), new Vector2(x2, y3), new Vector2(x2, y2), depth, new Vector2(x6, y6), new Vector2(x6, y9), new Vector2(x7, y8), new Vector2(x7, y7), color2); } if (color6.A > 0) { texturedBatch.QueueQuad(new Vector2(x2, y2), new Vector2(x3, y3), depth, new Vector2(x7, y7), new Vector2(x8, y8), color6); } } else if (flatBatch != null) { if (bevelColor.A > 0) { flatBatch.QueueQuad(new Vector2(x, y), new Vector2(x2, y2), new Vector2(x3, y2), new Vector2(x4, y), depth, color4); flatBatch.QueueQuad(new Vector2(x3, y2), new Vector2(x3, y3), new Vector2(x4, y4), new Vector2(x4, y), depth, color3); flatBatch.QueueQuad(new Vector2(x, y4), new Vector2(x4, y4), new Vector2(x3, y3), new Vector2(x2, y3), depth, color5); flatBatch.QueueQuad(new Vector2(x, y), new Vector2(x, y4), new Vector2(x2, y3), new Vector2(x2, y2), depth, color2); } if (color6.A > 0) { flatBatch.QueueQuad(new Vector2(x2, y2), new Vector2(x3, y3), depth, color6); } } if (bevelSize > 0f && flatBatch != null && shadowColor.A > 0) { Color color7 = shadowColor; Color color8 = new Color(0, 0, 0, 0); flatBatch.QueueTriangle(new Vector2(x, y4), new Vector2(x2, y5), new Vector2(x2, y4), depth, color8, color8, color7); flatBatch.QueueTriangle(new Vector2(x4, y), new Vector2(x4, y2), new Vector2(x5, y2), depth, color8, color7, color8); flatBatch.QueueTriangle(new Vector2(x4, y4), new Vector2(x4, y5), new Vector2(x5, y4), depth, color7, color8, color8); flatBatch.QueueQuad(new Vector2(x2, y4), new Vector2(x2, y5), new Vector2(x4, y5), new Vector2(x4, y4), depth, color7, color8, color8, color7); flatBatch.QueueQuad(new Vector2(x4, y2), new Vector2(x4, y4), new Vector2(x5, y4), new Vector2(x5, y2), depth, color7, color7, color8, color8); } }