示例#1
0
        private void AddVertex(GetStripColor stripColor, GetStripWidth stripWidth, Vector2 pos, float rot, int index, float progress)
        {
            while (index + 1 >= _vertices.Length)
            {
                Array.Resize(ref _vertices, _vertices.Length * 2);
            }
            Color   color       = stripColor(progress);
            Vector2 scaleFactor = stripWidth(progress);
            Vector2 value       = MathHelper.WrapAngle(rot - (float)Math.PI / 2f).ToRotationVector2() * scaleFactor;

            _vertices[index].Position     = pos + value;
            _vertices[index + 1].Position = pos - value;
            _vertices[index].TexCoord     = new Vector2(progress, 1f);
            _vertices[index + 1].TexCoord = new Vector2(progress, 0f);
            _vertices[index].Color        = color;
            _vertices[index + 1].Color    = color;
        }
示例#2
0
        public void PrepareStrip(Vector2[] oldPos, float[] oldRot, GetStripWidth stripWidth, GetStripColor stripColor, Vector2 offset = default(Vector2), int?expectedVertexPairsAmount = null, bool includeBacksides = false)
        {
            int lenght       = oldPos.Length;
            int vertexLenght = _vertexAmountCurrentlyMaintained = lenght * 2;

            if (_vertices.Length < vertexLenght)
            {
                Array.Resize(ref _vertices, vertexLenght);
            }
            int expectedAmount = expectedVertexPairsAmount.HasValue ? expectedVertexPairsAmount.Value : lenght;

            for (int i = 0; i < lenght; i++)
            {
                if (oldPos[i] == Vector2.Zero)
                {
                    lenght = i - 1;
                    expectedVertexPairsAmount = lenght * 2;
                }
                Vector2 pos      = oldPos[i] + offset;
                float   rot      = MathHelper.WrapAngle(oldRot[i]);
                float   progress = (float)i / (float)(expectedAmount - 1);
                AddVertex(stripColor, stripWidth, pos, rot, i * 2, progress);
            }
            PrepareIndices(lenght, includeBacksides);
        }