Beispiel #1
0
        public void FillTriangleFan(Vector2 center, IList <Vector2> ps, Color color)
        {
            var di = DrawInfo.ForFill(BasicEffect, _blankTexture);

            CheckFlush(di);

            if (ps.Count < 3)
            {
                throw new Exception("Triangle fan needs at least 3 points.");
            }

            var centerIndex = AddVertex(center, color);
            var v0          = AddVertex(ps[0], color);
            var v1          = AddVertex(ps[0], color);

            for (var i = 1; i < ps.Count; i++)
            {
                var v2 = AddVertex(ps[i], color);
                AddIndex(v1);
                AddIndex(v2);
                AddIndex(centerIndex);
                v1 = v2;
            }
            AddIndex(v1);
            AddIndex(v0);
            AddIndex(centerIndex);
        }
Beispiel #2
0
        public void FillTriangleStrip(IEnumerable <VertexPos2Texture> ps, Texture2D texture = null, Color?c = null)
        {
            var color = c ?? Color.White;
            var tex   = texture ?? _blankTexture;
            var di    = DrawInfo.ForFill(BasicEffect, tex, PrimitiveType.TriangleStrip);

            CheckFlush(di);

            var en = ps.GetEnumerator();

            if (!en.MoveNext())
            {
                throw new Exception("Need at least 3 vertices for a triangle strip.");
            }

            AddIndex(AddVertex(en.Current.Pos, color, en.Current.Uv));
            if (!en.MoveNext())
            {
                throw new Exception("Need at least 3 vertices for a triangle strip.");
            }
            AddIndex(AddVertex(en.Current.Pos, color, en.Current.Uv));

            while (en.MoveNext())
            {
                AddIndex(AddVertex(en.Current.Pos, color, en.Current.Uv));
            }

            en.Dispose();
        }
Beispiel #3
0
        public void FillRect(RectangleF rect, Sprite sprite)
        {
            var di = DrawInfo.ForFill(BasicEffect, sprite.Texture);

            CheckFlush(di);

            var v1 = AddVertex(new Vector2(rect.Left, rect.Top), sprite.UV1);
            var v2 = AddVertex(new Vector2(rect.Right, rect.Top), sprite.UV2);
            var v3 = AddVertex(new Vector2(rect.Right, rect.Bottom), sprite.UV3);
            var v4 = AddVertex(new Vector2(rect.Left, rect.Bottom), sprite.UV4);

            AddIndex(v1);
            AddIndex(v2);
            AddIndex(v4);
            AddIndex(v4);
            AddIndex(v2);
            AddIndex(v3);
        }
Beispiel #4
0
        public void FillRoundedRect(RectangleF rect, Texture2D tex)
        {
            var di = DrawInfo.ForFill(BasicEffect, tex);

            CheckFlush(di);

            var v1 = AddVertex(new Vector2(rect.Left, rect.Top), Vector2.Zero);
            var v2 = AddVertex(new Vector2(rect.Right, rect.Top), Vector2.UnitX);
            var v3 = AddVertex(new Vector2(rect.Right, rect.Bottom), Vector2.One);
            var v4 = AddVertex(new Vector2(rect.Left, rect.Bottom), Vector2.UnitY);

            AddIndex(v1);
            AddIndex(v2);
            AddIndex(v4);
            AddIndex(v4);
            AddIndex(v2);
            AddIndex(v3);
        }
Beispiel #5
0
        public void FillRect(RectangleF rect, Color c1, Color c2, Color c3, Color c4)
        {
            var di = DrawInfo.ForFill(BasicEffect, _blankTexture);

            CheckFlush(di);

            var v1 = AddVertex(new Vector2(rect.Left, rect.Top), c1);
            var v2 = AddVertex(new Vector2(rect.Right, rect.Top), c2);
            var v3 = AddVertex(new Vector2(rect.Right, rect.Bottom), c3);
            var v4 = AddVertex(new Vector2(rect.Left, rect.Bottom), c4);

            AddIndex(v1);
            AddIndex(v2);
            AddIndex(v4);
            AddIndex(v4);
            AddIndex(v2);
            AddIndex(v3);
        }