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


C# Vertices.ToArray方法代码示例

本文整理汇总了C#中Vertices.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Vertices.ToArray方法的具体用法?C# Vertices.ToArray怎么用?C# Vertices.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vertices的用法示例。


在下文中一共展示了Vertices.ToArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildEdges

        /// <summary>
        /// Builds the edges of a rectangle from a location and width/height.
        /// Optionally, you can specify the rotation angle to the X-Axsis
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="rotation"></param>
        /// <returns></returns>
        public static Vector2[] BuildEdges(double x, double y, double width, double height, Angle? rotation = null)
        {
            var topLeft = new Vector2(x, y);
            var topRight = new Vector2(x + width, y);
            var bottomRight = new Vector2(x + width, y + height);
            var bottomLeft = new Vector2(x, y + height);

            var vertices = new Vertices(new[] { topLeft, topRight, bottomRight, bottomLeft });

            // Rotate if necessary
            if (rotation.HasValue && rotation.Value != Angle.Zero)
            {
               vertices = vertices.RotateVertices(topLeft, rotation.Value);
            }
            return vertices.ToArray();
        }
开发者ID:ElderByte-,项目名称:Archimedes.Geometry,代码行数:26,代码来源:Rectangle2.cs

示例2: Update

        public override void Update(GameSettings settings, GameTime gameTime)
        {
            base.Update(settings, gameTime);

            DebugView.DrawString(50, TextLine, "Press: left mouse button to remove at mouse position.");
            TextLine += 15;
            DebugView.DrawString(50, TextLine, "Press: (A) to decrease the removal radius, (S) to increase it.");
            TextLine += 15;
            // Fighting against float decimals
            float radiusnumber = (float)((int)(Radius * 10)) / 10;
            DebugView.DrawString(50, TextLine, "Radius: " + radiusnumber);

            Color color = new Color(0.4f, 0.7f, 0.8f);

            //Transform shape to mouseposition and then draw
            Vertices tempshape = new Vertices(_clipCircle);
            tempshape.Translate(ref _mousePos);
            DebugView.BeginCustomDraw();
            DebugView.DrawPolygon(tempshape.ToArray(), _clipCircle.Count, color);
            DebugView.EndCustomDraw();
        }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:21,代码来源:DestructibleTerrainYuPengTest.cs

示例3: DrawVertices

        private void DrawVertices(Vertices vertices)
        {
            if (vertices.Count >= 1)
            {
                DebugView.DrawPolygon(vertices.ToArray(), vertices.Count, Color.Red);

                foreach (Vector2 vector2 in vertices)
                {
                    DebugView.DrawPoint(vector2, 0.1f, Color.Yellow);
                }
            }
        }
开发者ID:RCGame,项目名称:FarseerPhysics,代码行数:12,代码来源:SimplificationTest.cs

示例4: PolygonTrigger

        public PolygonTrigger( GameWorld world, Texture2D active_texture,
            Texture2D inactive_texture, Vector2[] points, TriggerableObject triggered_object = null,
            TriggerType type = TriggerType.FLOOR, float cooldown = -1, float rotation = 0, String name = "Trigger",
            String texture_name = TNames.ground_switch_inactive )
            : base(world, active_texture, inactive_texture, Vector2.Zero, triggered_object, type, cooldown, rotation, name, texture_name)
        {
            Vector2 diff = points[0] - points[(int)Math.Ceiling( points.Length / 2f )];
            float multiplier = Math.Min( Math.Abs( diff.X ), Math.Abs( diff.Y ) );
            m_width_height = new Vector2( multiplier, multiplier ) * 2;

            Vector2 sum = Vector2.Zero;

            foreach ( Vector2 p in points ) {
                sum += p;
            }
            pos = sum / points.Length;
            m_position = pos;

            for ( int i = 0; i < points.Length; i++ ) {
                points[i] -= pos;

            }

            if ( texture_name == TNames.wall && m_is_destructible ) {

                m_texture_name_change = TNames.breakwall;
                //m_texture = GameScreen.GAME_CONTENT.Load<Texture2D>(m_texture_name);
            }
            else if ( texture_name == TNames.tile ) {
                m_texture_name_change = TNames.tile;
                //m_texture = GameScreen.GAME_CONTENT.Load<Texture2D>(m_texture_name);

            }
            m_points = points;

            Vertices verts = new Vertices( points );
            Vertices collinear_simplified = SimplifyTools.CollinearSimplify( verts );
            Vertices merge_simplified = SimplifyTools.MergeIdenticalPoints( collinear_simplified );
            //Since it is a concave polygon, we need to partition it into several smaller convex polygons
            //List<Vertices> vert_list = BayazitDecomposer.ConvexPartition(merge_simplified);

            verts = merge_simplified;
            verts.ForceCounterClockWise();
            m_points = verts.ToArray();
        }
开发者ID:mumumumu,项目名称:SpeedUp,代码行数:45,代码来源:speedup-PolygonTrigger.cs


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