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


C# Vertices类代码示例

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


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

示例1: Initialize

        public override void Initialize()
        {
            Vector2 trans = new Vector2();
            _polygons = new List<Vertices>();

            _polygons.Add(PolygonTools.CreateGear(5f, 10, 0f, 6f));
            _polygons.Add(PolygonTools.CreateGear(4f, 15, 100f, 3f));

            trans.X = 0f;
            trans.Y = 8f;
            _polygons[0].Translate(ref trans);
            _polygons[1].Translate(ref trans);

            _polygons.Add(PolygonTools.CreateGear(5f, 10, 50f, 5f));

            trans.X = 22f;
            trans.Y = 17f;
            _polygons[2].Translate(ref trans);

            AddRectangle(5, 10);
            AddCircle(5, 32);

            trans.X = -20f;
            trans.Y = 8f;
            _polygons[3].Translate(ref trans);
            trans.Y = 20f;
            _polygons[4].Translate(ref trans);

            _subject = _polygons[0];
            _clip = _polygons[1];

            base.Initialize();
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:33,代码来源:YuPengPolygonTest.cs

示例2: ConvexPartition

        /// <summary>
        /// Decompose the polygon into several smaller non-concave polygons.
        /// </summary>
        /// <param name="vertices">The polygon to decompose.</param>
        /// <param name="sheer">The sheer to use if you get bad results, try using a higher value.</param>
        /// <returns>A list of triangles</returns>
        public static List<Vertices> ConvexPartition(Vertices vertices, float sheer = 0.001f)
        {
            Debug.Assert(vertices.Count > 3);

            List<Point> compatList = new List<Point>(vertices.Count);

            foreach (Vector2 vertex in vertices)
            {
                compatList.Add(new Point(vertex.X, vertex.Y));
            }

            Triangulator t = new Triangulator(compatList, sheer);

            List<Vertices> list = new List<Vertices>();

            foreach (List<Point> triangle in t.Triangles)
            {
                Vertices outTriangles = new Vertices(triangle.Count);

                foreach (Point outTriangle in triangle)
                {
                    outTriangles.Add(new Vector2(outTriangle.X, outTriangle.Y));
                }

                list.Add(outTriangles);
            }

            return list;
        }
开发者ID:nagyist,项目名称:Farseer-Physics-Engine-For-MonoMac,代码行数:35,代码来源:SeidelDecomposer.cs

示例3: SimplifySection

        private static void SimplifySection(Vertices vertices, int i, int j)
        {
            if ((i + 1) == j)
                return;

            Vector2 A = vertices[i];
            Vector2 B = vertices[j];
            double maxDistance = -1.0;
            int maxIndex = i;
            for (int k = i + 1; k < j; k++)
            {
                double distance = DistancePointLine(vertices[k], A, B);

                if (distance > maxDistance)
                {
                    maxDistance = distance;
                    maxIndex = k;
                }
            }
            if (maxDistance <= _distanceTolerance)
                for (int k = i + 1; k < j; k++)
                    _usePt[k] = false;
            else
            {
                SimplifySection(vertices, i, maxIndex);
                SimplifySection(vertices, maxIndex, j);
            }
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:28,代码来源:SimplifyTools.cs

示例4: BuildEntity

        public Entity BuildEntity(Entity e, params object[] args)
        {
            e.Tag = "Chassis";

            #region Body
            Body Chassis = e.AddComponent<Body>(new Body(_World, e));
            {
                Vertices vertices = new Vertices(8);
                vertices.Add(new Vector2(-2.5f, 0.08f));
                vertices.Add(new Vector2(-2.375f, -0.46f));
                vertices.Add(new Vector2(-0.58f, -0.92f));
                vertices.Add(new Vector2(0.46f, -0.92f));
                vertices.Add(new Vector2(2.5f, -0.17f));
                vertices.Add(new Vector2(2.5f, 0.205f));
                vertices.Add(new Vector2(2.3f, 0.33f));
                vertices.Add(new Vector2(-2.25f, 0.35f));
                PolygonShape chassisShape = new PolygonShape(vertices, 2f);

                Chassis.BodyType = BodyType.Dynamic;
                Chassis.Position = new Vector2(0.0f, -1.0f);
                Chassis.CreateFixture(chassisShape);
            }
            #endregion

            #region Sprite
            e.AddComponent<Sprite>(new Sprite(args[0] as Texture2D, (Rectangle)args[1],
               Chassis, 1, Color.White, 0f));
            #endregion
            return e;
        }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:30,代码来源:ChassisTemplate.cs

示例5: Goalie

 public Goalie(World world, GoalieData spawn)
 {
     var body = new Body(world);
     var angle = spawn.End - spawn.Begin;
     body.Rotation = FMath.Atan2(angle.Y, angle.X);
     segment.A = spawn.Begin;
     segment.B = spawn.End;
     var normal = new Vector2(-angle.Y, angle.X);
     normal.Normalize();
     delta = normal * .5f;
     segmentOut.A = spawn.Begin + delta;
     segmentOut.B = spawn.End + delta;
     segmentIn.A = spawn.Begin - delta;
     segmentIn.B = spawn.End - delta;
     body.Position = spawn.Begin;
     var verts = new Vertices();
     verts.Add(new Vector2(left, bottom));
     verts.Add(new Vector2(right, bottom));
     verts.Add(new Vector2(right, top));
     verts.Add(new Vector2(left, top));
     var shape = new PolygonShape(verts, 1f);
     body.FixedRotation = true;
     body.BodyType = BodyType.Dynamic;
     Fixture = body.CreateFixture(shape);
 }
开发者ID:det,项目名称:Rimbalzo,代码行数:25,代码来源:Goalie.cs

示例6: ChainShape

        /// <summary>
        /// Create a new chainshape from the vertices.
        /// </summary>
        /// <param name="vertices">The vertices to use. Must contain 2 or more vertices.</param>
        /// <param name="createLoop">Set to true to create a closed loop. It connects the first vertice to the last, and automatically adjusts connectivity to create smooth collisions along the chain.</param>
        public ChainShape(Vertices vertices, bool createLoop = false)
            : base(0)
        {
            ShapeType = ShapeType.Chain;
            _radius = Settings.PolygonRadius;

            Debug.Assert(vertices != null && vertices.Count >= 3);
            Debug.Assert(vertices[0] != vertices[vertices.Count - 1]); // FPE. See http://www.box2d.org/forum/viewtopic.php?f=4&t=7973&p=35363

            for (int i = 1; i < vertices.Count; ++i)
            {
                Vector2 v1 = vertices[i - 1];
                Vector2 v2 = vertices[i];

                // If the code crashes here, it means your vertices are too close together.
                Debug.Assert(Vector2.DistanceSquared(v1, v2) > Settings.LinearSlop * Settings.LinearSlop);
            }

            Vertices = new Vertices(vertices);

            if (createLoop)
            {
                Vertices.Add(vertices[0]);
                PrevVertex = Vertices[Vertices.Count - 2]; //FPE: We use the properties instead of the private fields here.
                NextVertex = Vertices[1]; //FPE: We use the properties instead of the private fields here.
            }
        }
开发者ID:tracer0707,项目名称:OpenGLF,代码行数:32,代码来源:ChainShape.cs

示例7: PhysicsGameEntity

 /// <summary>
 /// Constructs a FPE Body from the given list of vertices and density
 /// </summary>
 /// <param name="game"></param>
 /// <param name="world"></param>
 /// <param name="vertices">The collection of vertices in display units (pixels)</param>
 /// <param name="bodyType"></param>
 /// <param name="density"></param>
 public PhysicsGameEntity(Game game, World world, Category collisionCategory, Vertices vertices, BodyType bodyType, float density)
     : this(game,world,collisionCategory)
 {
     ConstructFromVertices(world,vertices,density);
     Body.BodyType = bodyType;
     Body.CollisionCategories = collisionCategory;
 }
开发者ID:dreasgrech,项目名称:FarseerPhysicsBaseFramework,代码行数:15,代码来源:PhysicsGameEntity.cs

示例8: ConvexPartition

        /// <summary>
        /// Decompose the polygon into several smaller non-concave polygon.
        /// If the polygon is already convex, it will return the original polygon, unless it is over Settings.MaxPolygonVertices.
        /// </summary>
        public static List<Vertices> ConvexPartition(Vertices vertices)
        {
            Debug.Assert(vertices.Count > 3);
            Debug.Assert(vertices.IsCounterClockWise());

            return TriangulatePolygon(vertices);
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:11,代码来源:BayazitDecomposer.cs

示例9: CreateBody

        public override Body CreateBody(World world)
        {
            var unithull = new Vertices((Vector2[])this.ResourceDictionary.GetResource(_resource.CollisionHullKey));
            
            var scaledVertices = new List<Vector2>();
            foreach (var vertex in unithull)
            {
                scaledVertices.Add(new Vector2(vertex.X * _resource.Width, vertex.Y * _resource.Height));
            }

            var vertices = new Vertices(scaledVertices);

            var body = new Body(world);
            body.BodyType = BodyType.Dynamic;
            body.IgnoreGravity = true;
            body.LinearDamping = 0.0f;
            body.FixedRotation = true;
            body.Mass = 0;
            var location = ((ILocatable)_actor).Location;
            body.Position = new Vector2(location.X, location.Y);

            var shape = new PolygonShape(vertices, 1f);

            var fixture = body.CreateFixture(shape, 0f);
            fixture.CollisionGroup = _resource.CollisionGroup;
            fixture.UserData = new CollisionData { Actor = _actor };
            fixture.OnCollision += OnCollision;
            _body = body;
            return body;
        }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:30,代码来源:CharacterPhysics.cs

示例10: cRigidBodyGameObject

 public cRigidBodyGameObject(float mass, Vertices v)
 {
     _rigidBody = new PolygonRigidBody(mass, v);
     cPhysics.Instance.addObject(this);
     _canAttachPortalTo = false;
     _portaling = false;
 }
开发者ID:mikecann,项目名称:Portal2D-XNA,代码行数:7,代码来源:cRigidBodyGameObject.cs

示例11: CreateLoopShape

 public static Body CreateLoopShape(World world, Vertices vertices, Vector2 position,
                                   DebugMaterial userData)
 {
     Body body = CreateBody(world, position);
     FixtureFactory.AttachLoopShape(vertices, body, userData);
     return body;
 }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:7,代码来源:BodyFactory.cs

示例12: CreateBody

        public override Body CreateBody(World world)
        {
            var unitHull = (Vector2[])ResourceDictionary.GetResource("UnitHull");

            var scaledVertices = new List<Vector2>();
            foreach (var vertex in unitHull)
            {
                scaledVertices.Add(new Vector2(vertex.X * _resource.Width, vertex.Y * _resource.Height));
            }
            
            var vertices = new Vertices(scaledVertices);

            var body = new Body(world);
            body.BodyType = BodyType.Static;
            
            var location = ((ILocatable)_actor).Location;
            body.Position = new Vector2(location.X, location.Y);

            var shape = new PolygonShape(vertices, 1f);

            var fixture = body.CreateFixture(shape, 0f);
            fixture.UserData = new CollisionData { Actor = _actor };
            fixture.CollisionGroup = _resource.CollisionGroup;            
            fixture.OnCollision += OnCollision;
            _body = body;
            return body;
        }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:27,代码来源:StarGatePhysics.cs

示例13: Snip

        /// <summary>
        /// Cut a the contour and add a triangle into V to describe the 
        /// location of the cut
        /// </summary>
        /// <param name="contour">The list of points defining the polygon</param>
        /// <param name="u">The index of the first point</param>
        /// <param name="v">The index of the second point</param>
        /// <param name="w">The index of the third point</param>
        /// <param name="n">The number of elements in the array.</param>
        /// <param name="V">The array to populate with indicies of triangles.</param>
        /// <returns>True if a triangle was found</returns>
        private static bool Snip(Vertices contour, int u, int v, int w, int n,
                                 int[] V)
        {
            if (Settings.Epsilon > MathUtils.Area(ref _tmpA, ref _tmpB, ref _tmpC))
            {
                return false;
            }

            for (int p = 0; p < n; p++)
            {
                if ((p == u) || (p == v) || (p == w))
                {
                    continue;
                }

                Vector2 point = contour[V[p]];

                if (InsideTriangle(ref _tmpA, ref _tmpB, ref _tmpC, ref point))
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:dvgamer,项目名称:GhostLegend-XNA,代码行数:36,代码来源:FlipcodeDecomposer.cs

示例14: SquareStack

        public SquareStack(Vector2 pos, Vector2 size, Vector2 subSize, float rot, SpriteBatch batch, Texture2D texture, World world)
            : base(pos, batch, texture, world)
        {
            this.size = size;
            this.subSize = subSize;
            this.rot = rot;
            this.texture = texture;
            this.color = Color.Green;
            this.spriteOrigin = new Vector2(texture.Width / 2, texture.Height / 2);
            this.backCol = new Color(color.R / 2, color.G / 2, color.B / 2);

            rMat = Matrix.CreateRotationZ(rot);

            if (Settings.MaxPolygonVertices < 24) Settings.MaxPolygonVertices = 24;

            Vector2 leftTop = Vector2.Transform(new Vector2(-size.X / 2, -size.Y / 2), rMat);
            Vector2 rightTop = Vector2.Transform(new Vector2(size.X / 2, -size.Y / 2), rMat);
            Vector2 leftBottom = Vector2.Transform(new Vector2(-size.X / 2, size.Y / 2), rMat);
            Vector2 rightBottom = Vector2.Transform(new Vector2(size.X / 2, size.Y / 2), rMat);

            Vertices verts = new Vertices();
            verts.Add(leftTop); verts.Add(rightTop); verts.Add(rightBottom); verts.Add(leftBottom);
            FixtureFactory.AttachPolygon(verts, density, body);

            this.width = max(max(leftTop.X, rightTop.X), max(leftBottom.X, rightBottom.X)) - min(min(leftTop.X, rightTop.X), min(leftBottom.X, rightBottom.X));
            this.height = max(max(leftTop.Y, rightTop.Y), max(leftBottom.Y, rightBottom.Y)) - min(min(leftTop.Y, rightTop.Y), min(leftBottom.Y, rightBottom.Y));
        }
开发者ID:eerkko,项目名称:TUGameDev2012,代码行数:27,代码来源:SquareStack.cs

示例15: CreateStaticCollidables

        /// <summary>
        /// Create static collidable bodies from vertices in each layer
        /// sent with the parameter
        /// </summary>
        /// <param name="layers">List of layers ment for making collisionboxes</param>
        void CreateStaticCollidables(List<Layer> layers, World world)
        {
            foreach (Layer layer in layers)
            {
                TileArray tileArray = layer.Tiles;
                Size tileSize = layer.TileSize;
                Size amntOfTiles = layer.LayerSize;
                Vertices vertices = new Vertices();

                for (int x = 0; x < amntOfTiles.Width; x++)
                {
                    for (int y = 0; y < amntOfTiles.Height; y++)
                    {
                        Location tileLocation = new Location(x, y);
                        Tile thisTile = tileArray[tileLocation];
                        if (thisTile != null)
                        {
                            //Vector2 vertex = new Vector2(x * tileSize.Width, y * tileSize.Height);
                            Vector2 vertex = new Vector2(ConvertUnits.ToSimUnits(x * tileSize.Width), ConvertUnits.ToSimUnits(y * tileSize.Height));
                            vertices.Add(vertex);
                        }
                    }
                }
                layerVertices.Add(vertices);

                Vertices hull = GiftWrap.GetConvexHull(vertices);
                Body body = BodyFactory.CreateLoopShape(world, hull);
                body.BodyType = BodyType.Static;
                body.Friction = 0.8f;
                body.Restitution = 0;
            }
        }
开发者ID:skakri09,项目名称:GameOfThreeTards-w-xTILE-Farseer,代码行数:37,代码来源:CollisionLayers.cs


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