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);
        }
示例#2
0
        public void DrawTexturedOverlay(Camera camera, Texture2D texture, Color color, float innerFactor, float outerFactor, Vector2 offset)
        {
            Vector2 viewportSize = camera.ViewportSize;
            float   num          = viewportSize.X / viewportSize.Y;
            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);

            offset.X = MathUtils.Remainder(offset.X, 1f);
            offset.Y = MathUtils.Remainder(offset.Y, 1f);
            Vector2         vector5         = new Vector2(0f, 0f) + offset;
            Vector2         vector6         = new Vector2(num, 0f) + offset;
            Vector2         vector7         = new Vector2(num, 1f) + offset;
            Vector2         vector8         = new Vector2(0f, 1f) + offset;
            Vector2         texCoord        = new Vector2(num / 2f, 0.5f) + offset;
            Color           color2          = color * outerFactor;
            Color           color3          = color * innerFactor;
            TexturedBatch2D texturedBatch2D = m_primitivesRenderer2D.TexturedBatch(texture, useAlphaTest: false, 0, DepthStencilState.None, null, BlendState.Additive, SamplerState.PointWrap);
            int             count           = texturedBatch2D.TriangleVertices.Count;

            texturedBatch2D.QueueTriangle(vector, vector2, p, 0f, vector5, vector6, texCoord, color2, color2, color3);
            texturedBatch2D.QueueTriangle(vector2, vector3, p, 0f, vector6, vector7, texCoord, color2, color2, color3);
            texturedBatch2D.QueueTriangle(vector3, vector4, p, 0f, vector7, vector8, texCoord, color2, color2, color3);
            texturedBatch2D.QueueTriangle(vector4, vector, p, 0f, vector8, vector5, texCoord, color2, color2, color3);
            texturedBatch2D.TransformTriangles(camera.ViewportMatrix, count);
            texturedBatch2D.Flush();
        }
示例#3
0
 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);
     }
 }
示例#4
0
 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);
     }
 }
示例#5
0
 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);
     }
 }
示例#6
0
 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 void Draw(PrimitivesRenderer2D primitivesRenderer, float depth, Matrix matrix, Color color)
        {
            TexturedBatch2D texturedBatch2D = primitivesRenderer.TexturedBatch(m_texture, useAlphaTest: false, 0, DepthStencilState.None, null, null, SamplerState.PointClamp);
            int             count           = texturedBatch2D.TriangleVertices.Count;

            foreach (Particle particle in m_particles)
            {
                if (particle.Active)
                {
                    DrawParticle(texturedBatch2D, particle, depth, color);
                }
            }
            texturedBatch2D.TransformTriangles(matrix, count);
        }
        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);
        }
示例#9
0
 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 override void Draw(DrawContext dc)
 {
     if (Texture != null)
     {
         SamplerState    samplerState    = TextureLinearFilter ? SamplerState.LinearWrap : SamplerState.PointWrap;
         FlatBatch2D     flatBatch2D     = dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None);
         TexturedBatch2D texturedBatch2D = dc.PrimitivesRenderer2D.TexturedBatch(Texture, useAlphaTest: false, 0, DepthStencilState.None, null, null, samplerState);
         int             count           = flatBatch2D.TriangleVertices.Count;
         int             count2          = texturedBatch2D.TriangleVertices.Count;
         QueueBevelledRectangle(texturedBatch2D, flatBatch2D, Vector2.Zero, base.ActualSize, 0f, BevelSize, CenterColor * base.GlobalColorTransform, BevelColor * base.GlobalColorTransform, ShadowColor * base.GlobalColorTransform, AmbientLight, DirectionalLight, TextureScale);
         flatBatch2D.TransformTriangles(base.GlobalTransform, count);
         texturedBatch2D.TransformTriangles(base.GlobalTransform, count2);
     }
     else
     {
         FlatBatch2D flatBatch2D2 = dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None);
         int         count3       = flatBatch2D2.TriangleVertices.Count;
         QueueBevelledRectangle(null, flatBatch2D2, Vector2.Zero, base.ActualSize, 0f, BevelSize, CenterColor * base.GlobalColorTransform, BevelColor * base.GlobalColorTransform, ShadowColor * base.GlobalColorTransform, AmbientLight, DirectionalLight, 0f);
         flatBatch2D2.TransformTriangles(base.GlobalTransform, count3);
     }
 }
示例#11
0
        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 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);
        }
示例#14
0
        public override void Draw(DrawContext dc)
        {
            Subtexture      subtexture       = ContentManager.Get <Subtexture>("Textures/Atlas/MoveRose");
            Subtexture      subtexture2      = ContentManager.Get <Subtexture>("Textures/Atlas/MoveRose_Pressed");
            TexturedBatch2D texturedBatch2D  = dc.PrimitivesRenderer2D.TexturedBatch(subtexture.Texture);
            TexturedBatch2D texturedBatch2D2 = dc.PrimitivesRenderer2D.TexturedBatch(subtexture2.Texture);
            int             count            = texturedBatch2D.TriangleVertices.Count;
            int             count2           = texturedBatch2D2.TriangleVertices.Count;
            Vector2         p       = base.ActualSize / 2f;
            Vector2         vector  = new Vector2(0f, 0f);
            Vector2         vector2 = new Vector2(base.ActualSize.X, 0f);
            Vector2         vector3 = new Vector2(base.ActualSize.X, base.ActualSize.Y);
            Vector2         vector4 = new Vector2(0f, base.ActualSize.Y);

            if (m_direction.Z > 0f)
            {
                Vector2 subtextureCoords  = GetSubtextureCoords(subtexture2, new Vector2(0f, 0f));
                Vector2 subtextureCoords2 = GetSubtextureCoords(subtexture2, new Vector2(1f, 0f));
                Vector2 subtextureCoords3 = GetSubtextureCoords(subtexture2, new Vector2(0.5f, 0.5f));
                texturedBatch2D2.QueueTriangle(vector, vector2, p, 0f, subtextureCoords, subtextureCoords2, subtextureCoords3, base.GlobalColorTransform);
            }
            else
            {
                Vector2 subtextureCoords4 = GetSubtextureCoords(subtexture, new Vector2(0f, 0f));
                Vector2 subtextureCoords5 = GetSubtextureCoords(subtexture, new Vector2(1f, 0f));
                Vector2 subtextureCoords6 = GetSubtextureCoords(subtexture, new Vector2(0.5f, 0.5f));
                texturedBatch2D.QueueTriangle(vector, vector2, p, 0f, subtextureCoords4, subtextureCoords5, subtextureCoords6, base.GlobalColorTransform);
            }
            if (m_direction.X > 0f)
            {
                Vector2 subtextureCoords7 = GetSubtextureCoords(subtexture2, new Vector2(1f, 0f));
                Vector2 subtextureCoords8 = GetSubtextureCoords(subtexture2, new Vector2(1f, 1f));
                Vector2 subtextureCoords9 = GetSubtextureCoords(subtexture2, new Vector2(0.5f, 0.5f));
                texturedBatch2D2.QueueTriangle(vector2, vector3, p, 0f, subtextureCoords7, subtextureCoords8, subtextureCoords9, base.GlobalColorTransform);
            }
            else
            {
                Vector2 subtextureCoords10 = GetSubtextureCoords(subtexture, new Vector2(1f, 0f));
                Vector2 subtextureCoords11 = GetSubtextureCoords(subtexture, new Vector2(1f, 1f));
                Vector2 subtextureCoords12 = GetSubtextureCoords(subtexture, new Vector2(0.5f, 0.5f));
                texturedBatch2D.QueueTriangle(vector2, vector3, p, 0f, subtextureCoords10, subtextureCoords11, subtextureCoords12, base.GlobalColorTransform);
            }
            if (m_direction.Z < 0f)
            {
                Vector2 subtextureCoords13 = GetSubtextureCoords(subtexture2, new Vector2(1f, 1f));
                Vector2 subtextureCoords14 = GetSubtextureCoords(subtexture2, new Vector2(0f, 1f));
                Vector2 subtextureCoords15 = GetSubtextureCoords(subtexture2, new Vector2(0.5f, 0.5f));
                texturedBatch2D2.QueueTriangle(vector3, vector4, p, 0f, subtextureCoords13, subtextureCoords14, subtextureCoords15, base.GlobalColorTransform);
            }
            else
            {
                Vector2 subtextureCoords16 = GetSubtextureCoords(subtexture, new Vector2(1f, 1f));
                Vector2 subtextureCoords17 = GetSubtextureCoords(subtexture, new Vector2(0f, 1f));
                Vector2 subtextureCoords18 = GetSubtextureCoords(subtexture, new Vector2(0.5f, 0.5f));
                texturedBatch2D.QueueTriangle(vector3, vector4, p, 0f, subtextureCoords16, subtextureCoords17, subtextureCoords18, base.GlobalColorTransform);
            }
            if (m_direction.X < 0f)
            {
                Vector2 subtextureCoords19 = GetSubtextureCoords(subtexture2, new Vector2(0f, 1f));
                Vector2 subtextureCoords20 = GetSubtextureCoords(subtexture2, new Vector2(0f, 0f));
                Vector2 subtextureCoords21 = GetSubtextureCoords(subtexture2, new Vector2(0.5f, 0.5f));
                texturedBatch2D2.QueueTriangle(vector4, vector, p, 0f, subtextureCoords19, subtextureCoords20, subtextureCoords21, base.GlobalColorTransform);
            }
            else
            {
                Vector2 subtextureCoords22 = GetSubtextureCoords(subtexture, new Vector2(0f, 1f));
                Vector2 subtextureCoords23 = GetSubtextureCoords(subtexture, new Vector2(0f, 0f));
                Vector2 subtextureCoords24 = GetSubtextureCoords(subtexture, new Vector2(0.5f, 0.5f));
                texturedBatch2D.QueueTriangle(vector4, vector, p, 0f, subtextureCoords22, subtextureCoords23, subtextureCoords24, base.GlobalColorTransform);
            }
            if (texturedBatch2D == texturedBatch2D2)
            {
                texturedBatch2D.TransformTriangles(base.GlobalTransform, count);
                return;
            }
            texturedBatch2D.TransformTriangles(base.GlobalTransform, count);
            texturedBatch2D2.TransformTriangles(base.GlobalTransform, count2);
        }
示例#15
0
 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 AnimateMagmaBlocksTexture()
        {
            TexturedBatch2D batch = m_primitivesRenderer.TexturedBatch(m_subsystemBlocksTexture.BlocksTexture, useAlphaTest: false, 0, DepthStencilState.None, null, BlendState.AlphaBlend, SamplerState.PointClamp);
            int             num   = BlocksManager.Blocks[92].DefaultTextureSlot % 16;
            int             num2  = BlocksManager.Blocks[92].DefaultTextureSlot / 16;
            double          num3  = 0.5 * m_subsystemTime.GameTime;
            double          num4  = 0.5 * (m_subsystemTime.GameTime - (double)m_subsystemTime.GameTimeDelta);
            float           num5  = MathUtils.Min((float)MathUtils.Remainder(num3, 2.0), 1f);
            float           num6  = MathUtils.Min((float)MathUtils.Remainder(num3 + 1.0, 2.0), 1f);
            byte            b     = (byte)(255f * num5);
            byte            b2    = (byte)(255f * num6);

            if (MathUtils.Remainder(num3, 2.0) >= 1.0 && MathUtils.Remainder(num4, 2.0) < 1.0)
            {
                m_magmaOrder   = true;
                m_magmaOffset2 = new Vector2(m_random.Float(0f, 1f), m_random.Float(0f, 1f));
            }
            else if (MathUtils.Remainder(num3 + 1.0, 2.0) >= 1.0 && MathUtils.Remainder(num4 + 1.0, 2.0) < 1.0)
            {
                m_magmaOrder   = false;
                m_magmaOffset1 = new Vector2(m_random.Float(0f, 1f), m_random.Float(0f, 1f));
            }
            Vector2 tcOffset  = new Vector2(num, num2) - (m_magmaOrder ? m_magmaOffset1 : m_magmaOffset2);
            Vector2 tcOffset2 = new Vector2(num, num2) - (m_magmaOrder ? m_magmaOffset2 : m_magmaOffset1);
            Color   color     = m_magmaOrder ? new Color(b, b, b, b) : new Color(b2, b2, b2, b2);
            Color   color2    = m_magmaOrder ? new Color(b2, b2, b2, b2) : new Color(b, b, b, b);
            float   num7      = MathUtils.Floor((float)MathUtils.Remainder(0.40000000596046448 * m_subsystemTime.GameTime, 1.0) * 16f) / 16f;
            float   num8      = 0f - num7 + 1f;
            float   num9      = MathUtils.Floor((float)MathUtils.Remainder((double)(0.4f / MathUtils.Sqrt(2f)) * m_subsystemTime.GameTime, 1.0) * 16f) / 16f;
            float   num10     = 0f - num9 + 1f;
            Vector2 tc        = new Vector2(0f, 0f);
            Vector2 tc2       = new Vector2(1f, 1f);

            DrawBlocksTextureSlot(batch, num, num2, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num, num2, tc, tc2, tcOffset2, color2);
            tc  = new Vector2(num7, 0f);
            tc2 = new Vector2(num7 + 1f, 1f);
            DrawBlocksTextureSlot(batch, num - 1, num2, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num - 1, num2, tc, tc2, tcOffset2, color2);
            tc  = new Vector2(num8, 0f);
            tc2 = new Vector2(num8 + 1f, 1f);
            DrawBlocksTextureSlot(batch, num + 1, num2, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num + 1, num2, tc, tc2, tcOffset2, color2);
            tc  = new Vector2(0f, num7);
            tc2 = new Vector2(1f, num7 + 1f);
            DrawBlocksTextureSlot(batch, num, num2 - 1, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num, num2 - 1, tc, tc2, tcOffset2, color2);
            tc  = new Vector2(0f, num8);
            tc2 = new Vector2(1f, num8 + 1f);
            DrawBlocksTextureSlot(batch, num, num2 + 1, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num, num2 + 1, tc, tc2, tcOffset2, color2);
            tc  = new Vector2(num9, num10);
            tc2 = new Vector2(num9 + 1f, num10 + 1f);
            DrawBlocksTextureSlot(batch, num - 1, num2 + 1, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num - 1, num2 + 1, tc, tc2, tcOffset2, color2);
            tc  = new Vector2(num10, num10);
            tc2 = new Vector2(num10 + 1f, num10 + 1f);
            DrawBlocksTextureSlot(batch, num + 1, num2 + 1, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num + 1, num2 + 1, tc, tc2, tcOffset2, color2);
            tc  = new Vector2(num9, num9);
            tc2 = new Vector2(num9 + 1f, num9 + 1f);
            DrawBlocksTextureSlot(batch, num - 1, num2 - 1, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num - 1, num2 - 1, tc, tc2, tcOffset2, color2);
            tc  = new Vector2(num10, num9);
            tc2 = new Vector2(num10 + 1f, num9 + 1f);
            DrawBlocksTextureSlot(batch, num + 1, num2 - 1, tc, tc2, tcOffset, color);
            DrawBlocksTextureSlot(batch, num + 1, num2 - 1, tc, tc2, tcOffset2, color2);
        }
示例#17
0
        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;
                }
            }
        }