public override void Draw(DrawContext dc) { TexturedBatch2D texturedBatch2D = dc.PrimitivesRenderer2D.TexturedBatch(m_texture, useAlphaTest: false, 0, DepthStencilState.None, null, null, SamplerState.LinearWrap); float x = 0f; float x2 = base.ActualSize.X * Rating / 5f; float x3 = base.ActualSize.X; float y = 0f; float y2 = base.ActualSize.Y; int count = texturedBatch2D.TriangleVertices.Count; texturedBatch2D.QueueQuad(new Vector2(x, y), new Vector2(x2, y2), 0f, new Vector2(0f, 0f), new Vector2(Rating, 1f), ForeColor * base.GlobalColorTransform); texturedBatch2D.QueueQuad(new Vector2(x2, y), new Vector2(x3, y2), 0f, new Vector2(Rating, 0f), new Vector2(5f, 1f), BackColor * base.GlobalColorTransform); texturedBatch2D.TransformTriangles(base.GlobalTransform, count); }
public void Draw(Widget.DrawContext dc) { if (IsMouseCursorVisible && UseSoftMouseCursor && MousePosition.HasValue) { Texture2D texture2D = m_mouseDragInProgress ? ContentManager.Get <Texture2D>("Textures/Gui/PadCursorDrag") : ((!m_mouseDownPoint.HasValue) ? ContentManager.Get <Texture2D>("Textures/Gui/PadCursor") : ContentManager.Get <Texture2D>("Textures/Gui/PadCursorDown")); TexturedBatch2D texturedBatch2D = dc.CursorPrimitivesRenderer2D.TexturedBatch(texture2D); Vector2 corner; Vector2 corner2 = (corner = Vector2.Transform(MousePosition.Value, Widget.InvertedGlobalTransform)) + new Vector2(texture2D.Width, texture2D.Height) * 0.8f; int count = texturedBatch2D.TriangleVertices.Count; texturedBatch2D.QueueQuad(corner, corner2, 0f, Vector2.Zero, Vector2.One, Color.White); texturedBatch2D.TransformTriangles(Widget.GlobalTransform, count); } if (IsPadCursorVisible) { Texture2D texture2D2 = m_padDragInProgress ? ContentManager.Get <Texture2D>("Textures/Gui/PadCursorDrag") : ((!m_padDownPoint.HasValue) ? ContentManager.Get <Texture2D>("Textures/Gui/PadCursor") : ContentManager.Get <Texture2D>("Textures/Gui/PadCursorDown")); TexturedBatch2D texturedBatch2D2 = dc.CursorPrimitivesRenderer2D.TexturedBatch(texture2D2); Vector2 corner3; Vector2 corner4 = (corner3 = Vector2.Transform(PadCursorPosition, Widget.InvertedGlobalTransform)) + new Vector2(texture2D2.Width, texture2D2.Height) * 0.8f; int count2 = texturedBatch2D2.TriangleVertices.Count; texturedBatch2D2.QueueQuad(corner3, corner4, 0f, Vector2.Zero, Vector2.One, Color.White); texturedBatch2D2.TransformTriangles(Widget.GlobalTransform, count2); } if (VrCursorPosition.HasValue) { dc.CursorPrimitivesRenderer2D.FlatBatch().QueueDisc(VrCursorPosition.Value, new Vector2(10f, 10f), 0f, Color.White); } }
public void DrawParticle(TexturedBatch2D batch, Particle particle, float depth, Color color) { Vector2 corner = particle.Position - particle.Size / 2f; Vector2 corner2 = particle.Position + particle.Size / 2f; int textureSlot = particle.TextureSlot; Vector2 v = new Vector2(textureSlot % 3, textureSlot / 3); float num = 0f; float num2 = 1f; float num3 = 0f; float num4 = 1f; if (particle.FlipX) { num = 1f - num; num2 = 1f - num2; } if (particle.FlipY) { num3 = 1f - num3; num4 = 1f - num4; } Vector2 texCoord = (v + new Vector2(num, num3)) * 0.333333343f; Vector2 texCoord2 = (v + new Vector2(num2, num4)) * 0.333333343f; batch.QueueQuad(corner, corner2, depth, texCoord, texCoord2, color); }
public override void Draw() { if (Texture == null) { return; } Matrix m = GlobalTransform; Vector2 v1, v3, v33; v1 = Vector2.Zero; v3 = new Vector2(Texture.Width * Scale, Texture.Height * Scale); //底层100%宽 v33 = new Vector2(Texture.Width * Progess * Scale, Texture.Height * Scale); Vector2.Transform(ref v1, ref m, out Vector2 result); Vector2.Transform(ref v3, ref m, out Vector2 result3); Vector2.Transform(ref v33, ref m, out Vector2 result33); texturedBatch2D.QueueQuad(result, result3, 0f, Vector2.Zero, Vector2.One, _base); //底层图 texturedBatch2D.QueueQuad(result, result33, 0f, Vector2.Zero, new Vector2(Progess, 1f), _nbase); }
public override void Draw() { if (Texture != null) { TexturedBatch2D texturedBatch2D = WidgetsManager.PrimitivesRenderer2D.TexturedBatch(Texture, useAlphaTest: false, 0, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointWrap); int count = texturedBatch2D.TriangleVertices.Count; texturedBatch2D.QueueQuad(Vector2.Zero, base.DesiredSize, 0f, startPoint, endPoint, base.GlobalColorTransform); texturedBatch2D.TransformTriangles(base.GlobalTransform, count); } }
public override void Draw(DrawContext drawContext) { if (Texture != null) { TexturedBatch2D texturedBatch2D = drawContext.PrimitivesRenderer2D.TexturedBatch(Texture, useAlphaTest: false, 0, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointWrap); int count = texturedBatch2D.TriangleVertices.Count; texturedBatch2D.QueueQuad(Vector2.Zero, base.ActualSize, 1f, Vector2.Zero, textcora, base.GlobalColorTransform); texturedBatch2D.TransformTriangles(base.GlobalTransform, count); } }
public void ApplyScalingRenderTarget(DrawContext dc) { if (m_scalingRenderTarget != null) { BlendState blendState = (base.GlobalColorTransform.A < byte.MaxValue) ? BlendState.AlphaBlend : BlendState.Opaque; TexturedBatch2D texturedBatch2D = dc.PrimitivesRenderer2D.TexturedBatch(m_scalingRenderTarget, useAlphaTest: false, 0, DepthStencilState.None, RasterizerState.CullNoneScissor, blendState, SamplerState.PointClamp); int count = texturedBatch2D.TriangleVertices.Count; texturedBatch2D.QueueQuad(Vector2.Zero, base.ActualSize, 0f, Vector2.Zero, Vector2.One, base.GlobalColorTransform); texturedBatch2D.TransformTriangles(base.GlobalTransform, count); dc.PrimitivesRenderer2D.Flush(); } }
public override void Draw() { if (Texture != null) { if (Engine.Time.RealTime - lastupdate > framedur) { ++drawpos; if (drawpos >= drawPoint_end.Count) { drawpos = 0; } lastupdate = Engine.Time.RealTime; } TexturedBatch2D texturedBatch2D = WidgetsManager.PrimitivesRenderer2D.TexturedBatch(Texture, useAlphaTest: false, 0, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointWrap); int count = texturedBatch2D.TriangleVertices.Count; texturedBatch2D.QueueQuad(Vector2.Zero, base.ActualSize, 0f, drawPoint_start[drawpos], drawPoint_end[drawpos], base.GlobalColorTransform); texturedBatch2D.TransformTriangles(base.GlobalTransform, count); } }
public void DrawImage(DrawContext dc) { float num = (float)MathUtils.Remainder(Time.FrameStartTime + (double)m_timeOffset, 10000.0); float x = 2f * SimplexNoise.OctavedNoise(num, 0.02f, 4, 2f, 0.5f) - 1f; float y = 2f * SimplexNoise.OctavedNoise(num + 100f, 0.02f, 4, 2f, 0.5f) - 1f; m_position += 0.03f * new Vector2(x, y) * MathUtils.Min(Time.FrameDuration, 0.1f); m_position.X = MathUtils.Remainder(m_position.X, 1f); m_position.Y = MathUtils.Remainder(m_position.Y, 1f); float f = 0.5f * MathUtils.PowSign(MathUtils.Sin(0.21f * num + 2f), 2f) + 0.5f; float num2 = MathUtils.Lerp(0.13f, 0.3f, f); float num3 = num2 / (float)Texture.Height * (float)Texture.Width / base.ActualSize.X * base.ActualSize.Y; float x2 = m_position.X; float y2 = m_position.Y; Vector2 zero = Vector2.Zero; Vector2 actualSize = base.ActualSize; Vector2 texCoord = new Vector2(x2 - num2, y2 - num3); Vector2 texCoord2 = new Vector2(x2 + num2, y2 + num3); TexturedBatch2D texturedBatch2D = dc.PrimitivesRenderer2D.TexturedBatch(Texture, useAlphaTest: false, 0, DepthStencilState.DepthWrite, null, BlendState.AlphaBlend, SamplerState.LinearWrap); int count = texturedBatch2D.TriangleVertices.Count; texturedBatch2D.QueueQuad(zero, actualSize, 1f, texCoord, texCoord2, base.GlobalColorTransform); texturedBatch2D.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); } }
public override void Draw(DrawContext dc) { if (FillColor.A == 0 && (OutlineColor.A == 0 || OutlineThickness <= 0f)) { return; } DepthStencilState depthStencilState = DepthWriteEnabled ? DepthStencilState.DepthWrite : DepthStencilState.None; Matrix m = base.GlobalTransform; Vector2 v = Vector2.Zero; Vector2 v2 = new Vector2(base.ActualSize.X, 0f); Vector2 v3 = base.ActualSize; Vector2 v4 = new Vector2(0f, base.ActualSize.Y); Vector2.Transform(ref v, ref m, out Vector2 result); Vector2.Transform(ref v2, ref m, out Vector2 result2); Vector2.Transform(ref v3, ref m, out Vector2 result3); Vector2.Transform(ref v4, ref m, out Vector2 result4); Color color = FillColor * base.GlobalColorTransform; if (color.A != 0) { if (Subtexture != null) { SamplerState samplerState = (!TextureWrap) ? (TextureLinearFilter ? SamplerState.LinearClamp : SamplerState.PointClamp) : (TextureLinearFilter ? SamplerState.LinearWrap : SamplerState.PointWrap); TexturedBatch2D texturedBatch2D = dc.PrimitivesRenderer2D.TexturedBatch(Subtexture.Texture, useAlphaTest: false, 0, depthStencilState, null, null, samplerState); Vector2 zero = default(Vector2); Vector2 texCoord; Vector2 texCoord2 = default(Vector2); Vector2 texCoord3; if (TextureWrap) { zero = Vector2.Zero; texCoord = new Vector2(base.ActualSize.X / (float)Subtexture.Texture.Width, 0f); texCoord2 = new Vector2(base.ActualSize.X / (float)Subtexture.Texture.Width, base.ActualSize.Y / (float)Subtexture.Texture.Height); texCoord3 = new Vector2(0f, base.ActualSize.Y / (float)Subtexture.Texture.Height); } else { zero.X = MathUtils.Lerp(Subtexture.TopLeft.X, Subtexture.BottomRight.X, Texcoord1.X); zero.Y = MathUtils.Lerp(Subtexture.TopLeft.Y, Subtexture.BottomRight.Y, Texcoord1.Y); texCoord2.X = MathUtils.Lerp(Subtexture.TopLeft.X, Subtexture.BottomRight.X, Texcoord2.X); texCoord2.Y = MathUtils.Lerp(Subtexture.TopLeft.Y, Subtexture.BottomRight.Y, Texcoord2.Y); texCoord = new Vector2(texCoord2.X, zero.Y); texCoord3 = new Vector2(zero.X, texCoord2.Y); } if (FlipHorizontal) { Utilities.Swap(ref zero.X, ref texCoord.X); Utilities.Swap(ref texCoord2.X, ref texCoord3.X); } if (FlipVertical) { Utilities.Swap(ref zero.Y, ref texCoord2.Y); Utilities.Swap(ref texCoord.Y, ref texCoord3.Y); } texturedBatch2D.QueueQuad(result, result2, result3, result4, Depth, zero, texCoord, texCoord2, texCoord3, color); } else { dc.PrimitivesRenderer2D.FlatBatch(1, depthStencilState).QueueQuad(result, result2, result3, result4, Depth, color); } } Color color2 = OutlineColor * base.GlobalColorTransform; if (color2.A != 0 && OutlineThickness > 0f) { FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(1, depthStencilState); Vector2 vector = Vector2.Normalize(base.GlobalTransform.Right.XY); Vector2 v5 = -Vector2.Normalize(base.GlobalTransform.Up.XY); int num = (int)MathUtils.Max(MathUtils.Round(OutlineThickness * base.GlobalTransform.Right.Length()), 1f); for (int i = 0; i < num; i++) { flatBatch2D.QueueLine(result, result2, Depth, color2); flatBatch2D.QueueLine(result2, result3, Depth, color2); flatBatch2D.QueueLine(result3, result4, Depth, color2); flatBatch2D.QueueLine(result4, result, Depth, color2); result += vector - v5; result2 += -vector - v5; result3 += -vector + v5; result4 += vector + v5; } } }
public void UpdateRenderTargets() { if (m_skinTexture == null || m_componentPlayer.PlayerData.CharacterSkinName != m_skinTextureName) { m_skinTexture = CharacterSkinsManager.LoadTexture(m_componentPlayer.PlayerData.CharacterSkinName); m_skinTextureName = m_componentPlayer.PlayerData.CharacterSkinName; Utilities.Dispose(ref m_innerClothedTexture); Utilities.Dispose(ref m_outerClothedTexture); } if (m_innerClothedTexture == null || m_innerClothedTexture.Width != m_skinTexture.Width || m_innerClothedTexture.Height != m_skinTexture.Height) { m_innerClothedTexture = new RenderTarget2D(m_skinTexture.Width, m_skinTexture.Height, ColorFormat.Rgba8888, DepthFormat.None); m_componentHumanModel.TextureOverride = m_innerClothedTexture; m_clothedTexturesValid = false; } if (m_outerClothedTexture == null || m_outerClothedTexture.Width != m_skinTexture.Width || m_outerClothedTexture.Height != m_skinTexture.Height) { m_outerClothedTexture = new RenderTarget2D(m_skinTexture.Width, m_skinTexture.Height, ColorFormat.Rgba8888, DepthFormat.None); m_componentOuterClothingModel.TextureOverride = m_outerClothedTexture; m_clothedTexturesValid = false; } if (DrawClothedTexture && !m_clothedTexturesValid) { m_clothedTexturesValid = true; Rectangle scissorRectangle = Display.ScissorRectangle; RenderTarget2D renderTarget = Display.RenderTarget; try { Display.RenderTarget = m_innerClothedTexture; Display.Clear(new Vector4(Color.Transparent)); int num = 0; TexturedBatch2D texturedBatch2D = m_primitivesRenderer.TexturedBatch(m_skinTexture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp); texturedBatch2D.QueueQuad(Vector2.Zero, new Vector2(m_innerClothedTexture.Width, m_innerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, Color.White); ClothingSlot[] innerSlotsOrder = m_innerSlotsOrder; foreach (ClothingSlot slot in innerSlotsOrder) { foreach (int clothe in GetClothes(slot)) { int data = Terrain.ExtractData(clothe); MekClothData clothingData = MekClothingBlock.GetClothingData(data); Color fabricColor = SubsystemPalette.GetFabricColor(m_subsystemTerrain, ClothingBlock.GetClothingColor(data)); texturedBatch2D = m_primitivesRenderer.TexturedBatch(clothingData.Texture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp); if (!clothingData.IsOuter) { texturedBatch2D.QueueQuad(new Vector2(0f, 0f), new Vector2(m_innerClothedTexture.Width, m_innerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, fabricColor); } } } m_primitivesRenderer.Flush(); Display.RenderTarget = m_outerClothedTexture; Display.Clear(new Vector4(Color.Transparent)); num = 0; innerSlotsOrder = m_outerSlotsOrder; foreach (ClothingSlot slot2 in innerSlotsOrder) { foreach (int clothe2 in GetClothes(slot2)) { int data2 = Terrain.ExtractData(clothe2); ClothingData clothingData2 = ClothingBlock.GetClothingData(data2); Color fabricColor2 = SubsystemPalette.GetFabricColor(m_subsystemTerrain, ClothingBlock.GetClothingColor(data2)); texturedBatch2D = m_primitivesRenderer.TexturedBatch(clothingData2.Texture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp); if (clothingData2.IsOuter) { texturedBatch2D.QueueQuad(new Vector2(0f, 0f), new Vector2(m_outerClothedTexture.Width, m_outerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, fabricColor2); } } } m_primitivesRenderer.Flush(); } finally { Display.RenderTarget = renderTarget; Display.ScissorRectangle = scissorRectangle; } } }
public void DrawBlocksTextureSlot(TexturedBatch2D batch, int slotX, int slotY, Vector2 tc1, Vector2 tc2, Vector2 tcOffset, Color color) { float s = (float)m_animatedBlocksTexture.Width / 16f; batch.QueueQuad(new Vector2(slotX, slotY) * s, new Vector2(slotX + 1, slotY + 1) * s, 0f, (tc1 + tcOffset) / 16f, (tc2 + tcOffset) / 16f, color); }