当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.Vertex类代码示例

本文整理汇总了C#中SFML.Graphics.Vertex的典型用法代码示例。如果您正苦于以下问题:C# Vertex类的具体用法?C# Vertex怎么用?C# Vertex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Vertex类属于SFML.Graphics命名空间,在下文中一共展示了Vertex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        public void Draw(RenderTexture texture)
        {
            Vertex[] lines = new Vertex[(endAngle - startAngle) * 2];
            for(int i = startAngle; i < endAngle; i+=2)
            {
               Vector2f heading = new Vector2f((float)Math.Cos(i), (float)Math.Sin(i));
               lines[i] = new Vertex(position, new Color(color.R, color.G, color.B, 255));
               lines[i+1] = new Vertex(position + (heading * radius), new Color(color.R, color.G, color.B, 0));
                
            }

            texture.Draw(lines, 0, (uint)(endAngle - startAngle) * 2, PrimitiveType.Lines, new RenderStates(BlendMode.Multiply));       

          /*  VertexArray shape = new VertexArray(PrimitiveType.Points, (uint)(endAngle - startAngle) * 2);
            shape.Append(new Vertex(position));
            for(int i = startAngle; i < endAngle; i++)
            {
                Vector2f heading = new Vector2f((float)Math.Cos(i), (float)Math.Sin(i));
                heading = Util.Vector.norm(heading);
                shape.Append(new Vertex(position + (heading * radius)));
            }
            shape.Append(new Vertex(position));

            texture.Draw(shape, new RenderStates(BlendMode.None));*/
        }
开发者ID:riordanp,项目名称:panjin,代码行数:25,代码来源:Light.cs

示例2: SetFrame

        public void SetFrame(int newFrame, bool resetTime)
        {
            if (Animation != null)
            {
                // calculate new vertex positions and texture coordinates 
                var rect = Animation.Frames[newFrame];

                var texCoordA = new Vector2f(0, 0);
                var texCoordB = new Vector2f(0, rect.Height);
                var texCoordC = new Vector2f(rect.Width, rect.Height);
                var texCoordD = new Vector2f(rect.Width, 0);

                var left = rect.Left + 0.0001f;
                var right = left + rect.Width;
                float top = rect.Top;
                var bottom = top + rect.Height;

                _vertices[0] = new Vertex(texCoordA, new Vector2f(left, top));
                _vertices[1] = new Vertex(texCoordB, new Vector2f(left, bottom));
                _vertices[2] = new Vertex(texCoordC, new Vector2f(right, bottom));
                _vertices[3] = new Vertex(texCoordD, new Vector2f(right, top));
            }

            if (resetTime)
            {
                _currentTime = Time.Zero;
            }
        }
开发者ID:Tetramputechture,项目名称:Ending_0.1b,代码行数:28,代码来源:AnimatedSprite.cs

示例3: Line

 public void Line(int x1, int y1, int x2, int y2)
 {
     Vertex[] verts = new Vertex[2];
     verts[0] = new Vertex(new Vector2f(x1, y1), Color.Red);
     verts[1] = new Vertex(new Vector2f(x2, y2), Color.Red);
     RenderTexture.Draw(verts, PrimitiveType.Lines);
 }
开发者ID:Radnen,项目名称:sphere-sfml,代码行数:7,代码来源:FastTextureAtlas.cs

示例4: drawLine

        public static void drawLine(RenderWindow w, Vector2f a, Vector2f b, Color c)
        {
            Vertex[] verts = new Vertex[8];

            verts[0] = new Vertex(new Vector2f(a.X, a.Y), c);
            verts[1] = new Vertex(new Vector2f(b.X, b.Y), c);

            w.Draw(verts, PrimitiveType.Lines);
        }
开发者ID:Raptor2277,项目名称:CubePlatformer,代码行数:9,代码来源:Draw.cs

示例5: drawTexRectangle

        public static void drawTexRectangle(RenderWindow w, List<Vector2> vertecies, Color c, Texture t)
        {
            Vertex[] verts = new Vertex[4];

            verts[0] = new Vertex(new Vector2f(vertecies[3].X, vertecies[3].Y), c, new Vector2f(0,0));
            verts[1] = new Vertex(new Vector2f(vertecies[0].X, vertecies[0].Y), c, new Vector2f(t.Size.X, 0));
            verts[2] = new Vertex(new Vector2f(vertecies[1].X, vertecies[1].Y), c, new Vector2f(t.Size.X, t.Size.Y));
            verts[3] = new Vertex(new Vector2f(vertecies[2].X, vertecies[2].Y), c, new Vector2f(0, t.Size.Y));

            w.Draw(verts, PrimitiveType.Quads, new RenderStates(t));
        }
开发者ID:Raptor2277,项目名称:CubePlatformer,代码行数:11,代码来源:Draw.cs

示例6: Draw

        public void Draw()
        {
            var p0 = new SSVector2F(_cBody.X.ToPixels(), _cBody.Y.ToPixels());
            var p1 = p0 + Utils.Math.Angles.ToVectorDegrees(Angle - Amplitude)*66;
            var p2 = p0 + Utils.Math.Angles.ToVectorDegrees(Angle + Amplitude)*66;

            var v0 = new Vertex(new Vector2f(p0.X, p0.Y)) {Color = new Color(255, 0, 0, 125)};
            var v1 = new Vertex(new Vector2f(p1.X, p1.Y)) {Color = new Color(255, 0, 0, 1)};
            var v2 = new Vertex(new Vector2f(p2.X, p2.Y)) {Color = new Color(255, 0, 0, 1)};

            _game.GameWindow.RenderWindow.Draw(new[] {v0, v1, v2}, PrimitiveType.Triangles);
        }
开发者ID:SuperV1234,项目名称:Specimen,代码行数:12,代码来源:CLineOfSight.cs

示例7: Add

        /// <summary>
        /// Add a pre-transformed texture to the batcher.
        /// </summary>
        public void Add(Texture tex, Vertex[] transform)
        {
            if (_tex != tex) Flush(tex);

            _array[_idx + 0] = transform[0];
            _array[_idx + 1] = transform[1];
            _array[_idx + 2] = transform[2];
            _array[_idx + 3] = transform[3];
            _idx += 4;

            if (_idx == _array.Length) Flush();
        }
开发者ID:Radnen,项目名称:sphere-sfml,代码行数:15,代码来源:SpriteBatch.cs

示例8: drawPolygon

        public static void drawPolygon(RenderWindow w, List<Vector2> vertecies, Color c)
        {
            Vertex[] verts = new Vertex[vertecies.Count + 1];

            int i = 0;
            foreach (Vector2 v in vertecies)
            {
                verts[i] = new Vertex(new Vector2f(v.X , v.Y ), c);
                i++;
            }
            verts[i] = new Vertex(new Vector2f(vertecies[0].X , vertecies[0].Y ), c);

            w.Draw(verts, PrimitiveType.LinesStrip);
        }
开发者ID:Raptor2277,项目名称:CubePlatformer,代码行数:14,代码来源:Draw.cs

示例9: LoadContent

        public void LoadContent()
        {
            //verts = new VertexTypeList.PositionDiffuse2DTexture1[4]
            //            {
            //                new VertexTypeList.PositionDiffuse2DTexture1(new Vector3(1, -1, 0), Color.Transparent, new Vector2(1, 1)),
            //                new VertexTypeList.PositionDiffuse2DTexture1(new Vector3(-1, -1, 0), Color.Transparent,new Vector2(0, 1)),
            //                new VertexTypeList.PositionDiffuse2DTexture1(new Vector3(-1, 1, 0), Color.Transparent, new Vector2(0, 0)),
            //                new VertexTypeList.PositionDiffuse2DTexture1(new Vector3(1, 1, 0), Color.Transparent, new Vector2(1, 0))
            //            };

            vertex = new VertexArray(PrimitiveType.Lines, 4);
            vertex[0] = new Vertex(new Vector2(1,-1), Color.Transparent.ToSFMLColor(),new Vector2(1,1));
            vertex[1] = new Vertex(new Vector2(-1, -1), Color.Transparent.ToSFMLColor(), new Vector2(0, 1));
            vertex[2] = new Vertex(new Vector2(-1, 1), Color.Transparent.ToSFMLColor(), new Vector2(0, 0));
            vertex[3] = new Vertex(new Vector2(1, 1), Color.Transparent.ToSFMLColor(), new Vector2(1, 0));
        }
开发者ID:Tri125,项目名称:space-station-14,代码行数:16,代码来源:QuadRenderer.cs

示例10: Crosshair

 public Crosshair()
 {
     const float halfWidth = 5f;
     Vertex v = new Vertex(new Vector2f(halfWidth, 0f), SFML.Graphics.Color.White);
     m_vertexArray.Append(v);
     v.Position = new Vector2f(-halfWidth, 0f);
     m_vertexArray.Append(v);
     v.Color = SFML.Graphics.Color.Transparent;
     m_vertexArray.Append(v);
     v.Position = new Vector2f(0f, -halfWidth);
     m_vertexArray.Append(v);
     v.Color = SFML.Graphics.Color.White;
     m_vertexArray.Append(v);
     v.Position = new Vector2f(0f, halfWidth);
     m_vertexArray.Append(v);
 }
开发者ID:fallahn,项目名称:xygine,代码行数:16,代码来源:ParticleSystem.cs

示例11: Rebuild

        private void Rebuild()
        {
            var edgeWidth = (_radius * 2) / 3;

            _vertices[00] = new Vertex(new Vector2f(0, 0), _color);
            _vertices[01] = new Vertex(new Vector2f(edgeWidth, 0), _color);
            _vertices[02] = new Vertex(new Vector2f(edgeWidth, _thickness), _color);
            _vertices[03] = new Vertex(new Vector2f(0, _thickness), _color);

            _vertices[04] = new Vertex(new Vector2f(0, 0), _color);
            _vertices[05] = new Vertex(new Vector2f(_thickness, 0), _color);
            _vertices[06] = new Vertex(new Vector2f(_thickness, edgeWidth), _color);
            _vertices[07] = new Vertex(new Vector2f(0, edgeWidth), _color);

            _vertices[08] = new Vertex(new Vector2f(edgeWidth * 2, 0), _color);
            _vertices[09] = new Vertex(new Vector2f(edgeWidth * 3, 0), _color);
            _vertices[10] = new Vertex(new Vector2f(edgeWidth * 3, _thickness), _color);
            _vertices[11] = new Vertex(new Vector2f(edgeWidth * 2, _thickness), _color);

            _vertices[12] = new Vertex(new Vector2f(edgeWidth * 3 - _thickness, 0), _color);
            _vertices[13] = new Vertex(new Vector2f(edgeWidth * 3, 0), _color);
            _vertices[14] = new Vertex(new Vector2f(edgeWidth * 3, edgeWidth), _color);
            _vertices[15] = new Vertex(new Vector2f(edgeWidth * 3 - _thickness, edgeWidth), _color);

            _vertices[16] = new Vertex(new Vector2f(edgeWidth * 3 - _thickness, edgeWidth * 2), _color);
            _vertices[17] = new Vertex(new Vector2f(edgeWidth * 3, edgeWidth * 2), _color);
            _vertices[18] = new Vertex(new Vector2f(edgeWidth * 3, edgeWidth * 3), _color);
            _vertices[19] = new Vertex(new Vector2f(edgeWidth * 3 - _thickness, edgeWidth * 3), _color);

            _vertices[20] = new Vertex(new Vector2f(edgeWidth * 2, edgeWidth * 3 - _thickness), _color);
            _vertices[21] = new Vertex(new Vector2f(edgeWidth * 3, edgeWidth * 3 - _thickness), _color);
            _vertices[22] = new Vertex(new Vector2f(edgeWidth * 3, edgeWidth * 3), _color);
            _vertices[23] = new Vertex(new Vector2f(edgeWidth * 2, edgeWidth * 3), _color);

            _vertices[24] = new Vertex(new Vector2f(0, edgeWidth * 2), _color);
            _vertices[25] = new Vertex(new Vector2f(_thickness, edgeWidth * 2), _color);
            _vertices[26] = new Vertex(new Vector2f(_thickness, edgeWidth * 3), _color);
            _vertices[27] = new Vertex(new Vector2f(0, edgeWidth * 3), _color);

            _vertices[28] = new Vertex(new Vector2f(0, edgeWidth * 3 - _thickness), _color);
            _vertices[29] = new Vertex(new Vector2f(edgeWidth, edgeWidth * 3 - _thickness), _color);
            _vertices[30] = new Vertex(new Vector2f(edgeWidth, edgeWidth * 3), _color);
            _vertices[31] = new Vertex(new Vector2f(0, edgeWidth * 3), _color);

            _dirty = false;
        }
开发者ID:Rohansi,项目名称:FPCompo11,代码行数:46,代码来源:TargetMarker.cs

示例12: Draw

        public void Draw(Vector2f position, IntRect rec, Color color, Vector2f scale, Vector2f origin, float rotation = 0)
        {
            if (_count >= (_vertices.Length / 4))
                Array.Resize(ref _vertices, _vertices.Length * 2);

            rotation = rotation * (float)Math.PI / 180;
            var sin = (float)Math.Sin(rotation);
            var cos = (float)Math.Cos(rotation);

            origin.X *= scale.X;
            origin.Y *= scale.Y;
            scale.X *= rec.Width;
            scale.Y *= rec.Height;

            Vertex v = new Vertex {Color = color};

            float pX = -origin.X;
            float pY = -origin.Y;

            v.Position.X = pX * cos - pY * sin + position.X;
            v.Position.Y = pX * sin + pY * cos + position.Y;
            v.TexCoords.X = rec.Left;
            v.TexCoords.Y = rec.Top;
            _vertices[_count * 4 + 0] = v;

            pX += scale.X;
            v.Position.X = pX * cos - pY * sin + position.X;
            v.Position.Y = pX * sin + pY * cos + position.Y;
            v.TexCoords.X += rec.Width;
            _vertices[_count * 4 + 1] = v;

            pY += scale.Y;
            v.Position.X = pX * cos - pY * sin + position.X;
            v.Position.Y = pX * sin + pY * cos + position.Y;
            v.TexCoords.Y += rec.Height;
            _vertices[_count * 4 + 2] = v;

            pX -= scale.X;
            v.Position.X = pX * cos - pY * sin + position.X;
            v.Position.Y = pX * sin + pY * cos + position.Y;
            v.TexCoords.X -= rec.Width;
            _vertices[_count * 4 + 3] = v;

            _count++;
        }
开发者ID:krixalis,项目名称:Subject2Change,代码行数:45,代码来源:SpriteBatch.cs

示例13: drawRectangle

        public static void drawRectangle(RenderWindow w, Rectangle rect, Color c)
        {
            Vertex[] verts = new Vertex[8];

            verts[0] = new Vertex(new Vector2f(rect.x, rect.y), c);
            verts[1] = new Vertex(new Vector2f(rect.x + rect.width, rect.y), c);

            verts[2] = new Vertex(new Vector2f(rect.x + rect.width, rect.y), c);
            verts[3] = new Vertex(new Vector2f(rect.x + rect.width, rect.y + rect.height), c);

            verts[4] = new Vertex(new Vector2f(rect.x + rect.width, rect.y + rect.height), c);
            verts[5] = new Vertex(new Vector2f(rect.x, rect.y + rect.height), c);

            verts[6] = new Vertex(new Vector2f(rect.x, rect.y + rect.height), c);
            verts[7] = new Vertex(new Vector2f(rect.x, rect.y), c);

            w.Draw(verts, PrimitiveType.Lines);
        }
开发者ID:Raptor2277,项目名称:CubePlatformer,代码行数:18,代码来源:Draw.cs

示例14: load

        public bool load(string tileset, SFML.Window.Vector2u tileSize, int[] tiles, uint width, uint height)
        {
            m_vertices.PrimitiveType = SFML.Graphics.PrimitiveType.Quads;
            m_vertices.Resize(width * height * 4);
            for (uint i = 0; i < width; ++i) {
                for (uint j = 0; j < height; ++j) {
                    int tileNumber = tiles[i + j * width];

                    long tu = tileNumber % (m_tileset.Size.X / tileSize.X);
                    long tv = tileNumber / (m_tileset.Size.X / tileSize.X);

                    uint index = (i + j * width) * 4;

                    m_vertices[index + 0] = new Vertex(new Vector2f(i * tileSize.X, j * tileSize.Y), new Vector2f(tu * tileSize.X, tv * tileSize.Y));
                    m_vertices[index + 1] = new Vertex(new Vector2f((i + 1) * tileSize.X, j * tileSize.Y), new Vector2f((tu + 1) * tileSize.X, tv * tileSize.Y));
                    m_vertices[index + 2] = new Vertex(new Vector2f((i + 1) * tileSize.X, (j + 1) * tileSize.Y), new Vector2f((tu + 1) * tileSize.X, (tv + 1) * tileSize.Y));
                    m_vertices[index + 3] = new Vertex(new Vector2f(i * tileSize.X, (j + 1) * tileSize.Y), new Vector2f(tu * tileSize.X, (tv + 1) * tileSize.Y));
                }
            }

            return true;
        }
开发者ID:gamodo,项目名称:ProjectSheep,代码行数:22,代码来源:TileMap.cs

示例15: Draw

        public override void Draw(RenderTarget target, RenderStates states)
        {
            var corners = game.WindowBounds.Corners().Concat(game.World.Objects.SelectMany(o => o.Bounds.Corners()));
            var edges = game.WindowBounds.Edges().Concat(game.World.Objects.SelectMany(o => o.Bounds.Edges()));

            //foreach (var edge in edges)
            //    Debug.DrawLine(edge.start, edge.end);

            var hits =
                from c in corners
                let angle = Radians(c.Angle(Position))
                let hit = Raycast(Position, c, edges)
                let left = Raycast(Position, angle - 0.0001f, 10000f, edges)
                let right = Raycast(Position, angle + 0.0001f, 10000f, edges)
                where hit.HasValue && left.HasValue && right.HasValue
                from h in new[] {
                    new { Hit = hit, Angle = angle },
                    new { Hit = left, Angle = angle - 0.0001f },
                    new { Hit = right, Angle = angle + 0.0001f } }
                let a = NormalizeAngle(Position.Angle(h.Hit.Value.ClosestHit))
                orderby h.Angle
                select h.Hit.Value.ClosestHit;

            //foreach (var hit in hits)
            //{
            //    Debug.DrawLine(Position, hit, Color.Red);
            //    Debug.DrawCircle(hit, 5f, 8, Color.Red);
            //}

            var vertices = new VertexArray(PrimitiveType.Triangles);
            var center = new Vertex(Position, Color);

            foreach (var hit in hits.Pairs(Position))
                vertices.Append(new Vertex(hit, Color));

            target.Draw(vertices);
        }
开发者ID:snowfox0x,项目名称:2D-Lighting-Sample,代码行数:37,代码来源:PointLight.cs


注:本文中的SFML.Graphics.Vertex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。