示例#1
0
        private void LoadObstacles()
        {
            DebugMaterial material = new DebugMaterial(MaterialType.Dots)
                                         {
                                             Color = Color.SandyBrown,
                                             Scale = 8f
                                         };

            for (int i = 0; i < 5; i++)
            {
                _obstacles[i] = FixtureFactory.CreateRectangle(World, 8, 1.5f, 1, material);
                _obstacles[i].Body.IsStatic = true;

                if (i == 0)
                {
                    _obstacles[i].Restitution = .2f;
                    _obstacles[i].Friction = .2f;
                }
            }

            _obstacles[0].Body.Position = new Vector2(-5, -15);
            _obstacles[1].Body.Position = new Vector2(15, -10);
            _obstacles[2].Body.Position = new Vector2(10, 5);
            _obstacles[3].Body.Position = new Vector2(-10, 15);
            _obstacles[4].Body.Position = new Vector2(-17, 0);
        }
示例#2
0
        public override void LoadContent()
        {
            World = new World(Vector2.Zero);
            base.LoadContent();

            Vertices rect1 = PolygonTools.CreateRectangle(2, 2);
            Vertices rect2 = PolygonTools.CreateRectangle(2, 2);

            Vector2 trans = new Vector2(-2, 0);
            rect1.Translate(ref trans);
            trans = new Vector2(2, 0);
            rect2.Translate(ref trans);

            List<Vertices> vertices = new List<Vertices>(2);
            vertices.Add(rect1);
            vertices.Add(rect2);

            DebugMaterial material = new DebugMaterial(MaterialType.Circles)
                                         {
                                             Color = Color.Gold,
                                             Scale = 2.5f
                                         };

            _rectangles = FixtureFactory.CreateCompoundPolygon(World, vertices, 1, material);
            _rectangles[0].Body.BodyType = BodyType.Dynamic;
        }
示例#3
0
        public Turret(Vector2 farseerLoc, World w, RagdollManager r, Fixture f)
        {
            

            DebugMaterial gray = new DebugMaterial(MaterialType.Blank)
            {
                Color = Color.DarkGray
            };

            body = new Body(w);
            pivot = FixtureFactory.AttachCircle(.9f, 1, body, gray);
            FixtureFactory.AttachRectangle(barrelLength, .5f, 1, new Vector2(barrelLength / 2, 0), body, gray);
            body.Position = farseerLoc;
            body.BodyType = BodyType.Dynamic;
            //b.CollidesWith = Category.None;

            if (f == null)
            {

                motor = JointFactory.CreateFixedRevoluteJoint(w, body, Vector2.Zero, farseerLoc);
            }
            else
            {
                motor = new RevoluteJoint(body, f.Body, Vector2.Zero, f.Body.GetLocalPoint(farseerLoc));
                w.AddJoint(motor);
            }

            motor.MotorEnabled = true;
            motor.MaxMotorTorque = 5000;

            Init(w, r);
        }
示例#4
0
        public override void LoadContent()
        {
            World = new World(new Vector2(0, -20));
            base.LoadContent();

            DebugMaterial material = new DebugMaterial(MaterialType.Waves)
                                         {
                                             Color = Color.OliveDrab,
                                             Scale = 4f
                                         };

            Fixture _temp;
            _temp = FixtureFactory.CreateEdge(World, new Vector2(-20f, 17f), new Vector2(10f, 8f));
            _temp = FixtureFactory.CreateEdge(World, new Vector2(13.5f, 11f), new Vector2(13.5f, 7f));

            _temp = FixtureFactory.CreateEdge(World, new Vector2(-10f, -4f), new Vector2(20f, 4f));
            _temp = FixtureFactory.CreateEdge(World, new Vector2(-13.5f, -1f), new Vector2(-13.5f, -5f));

            _temp = FixtureFactory.CreateEdge(World, new Vector2(-20f, -8f), new Vector2(10f, -17f));

            float[] friction = new[] {0.75f, 0.5f, 0.35f, 0.1f, 0.0f};
            for (int i = 0; i < 5; ++i)
            {
                _temp = FixtureFactory.CreateRectangle(World, 2.5f, 2.5f, 1f, material);
                _temp.Body.BodyType = BodyType.Dynamic;
                _temp.Body.Position = new Vector2(-18f + 5.2f*i, 20.0f);
                _temp.Friction = friction[i];
            }
        }
示例#5
0
        private void CreateBorder(float width, float height, float borderWidth)
        {
            width = Math.Abs(width);
            height = Math.Abs(height);

            _anchor = new Body(_world);
            List<Vertices> borders = new List<Vertices>(4);

            //Bottom
            borders.Add(PolygonTools.CreateRectangle(width, borderWidth, new Vector2(0, height), 0));

            //Left
            borders.Add(PolygonTools.CreateRectangle(borderWidth, height, new Vector2(-width, 0), 0));

            //Top
            borders.Add(PolygonTools.CreateRectangle(width, borderWidth, new Vector2(0, -height), 0));

            //Right
            borders.Add(PolygonTools.CreateRectangle(borderWidth, height, new Vector2(width, 0), 0));

            DebugMaterial material = new DebugMaterial(MaterialType.Pavement)
                                         {
                                             Color = Color.LightGray,
                                             Scale = 8f
                                         };
            List<Fixture> fixtures = FixtureFactory.CreateCompoundPolygon(borders, 1, _anchor, material);

            foreach (Fixture t in fixtures)
            {
                t.CollisionFilter.CollisionCategories = Category.All;
                t.CollisionFilter.CollidesWith = Category.All;
            }
        }
示例#6
0
 public static Body CreateLoopShape(World world, Vertices vertices, Vector2 position,
                                   DebugMaterial userData)
 {
     Body body = CreateBody(world, position);
     FixtureFactory.AttachLoopShape(vertices, body, userData);
     return body;
 }
示例#7
0
        private void Bubble()
        {

            if (bubbled) return;

            //foreach (Body b in ragdoll.AllBodies) {
            //    b.AngularVelocity = 0;
            //    b.LinearVelocity = Vector2.Zero;
            //}

            DebugMaterial mat = new DebugMaterial(MaterialType.Blank);
            mat.Color = Color.Transparent;

            bubble = new Body(world, mat);
            FixtureFactory.AttachCircle(6, .5f, bubble, mat);
            bubble.CollidesWith = Category.Cat2;
            bubble.CollisionCategories = Category.Cat3;
            bubble.Position = ragdoll.Body.Position;
            bubble.BodyType = BodyType.Dynamic;
            bubble.IgnoreGravity = true;

            joint = new RevoluteJoint(ragdoll.Body, bubble, Vector2.Zero, Vector2.Zero);
            world.AddJoint(joint);
            bubbled = true;

        }
示例#8
0
        public static Fixture AttachCircle(float radius, float density, Body body, DebugMaterial userData)
        {
            if (radius <= 0)
                throw new ArgumentOutOfRangeException("radius", "Radius must be more than 0 meters");

            CircleShape circleShape = new CircleShape(radius, density);
            return body.CreateFixture(circleShape, userData);
        }
示例#9
0
 public static Fixture AttachRectangle(float width, float height, float density, Vector2 offset, Body body,
                                       DebugMaterial userData)
 {
     Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
     rectangleVertices.Translate(ref offset);
     PolygonShape rectangleShape = new PolygonShape(rectangleVertices, density);
     return body.CreateFixture(rectangleShape, userData);
 }
示例#10
0
        public override void LoadContent()
        {
            World = new World(Vector2.Zero);
            base.LoadContent();

            DebugMaterial material = new DebugMaterial(MaterialType.Circles)
                                         {
                                             Color = Color.Gold,
                                             Scale = 2.5f
                                         };

            _rectangle = FixtureFactory.CreateRectangle(World, 5, 5, 1, material);
            _rectangle.Body.BodyType = BodyType.Dynamic;
        }
示例#11
0
        public BreakableBody(IEnumerable<Vertices> vertices, World world, float density, DebugMaterial userData)
        {
            _world = world;
            _world.ContactManager.PostSolve += PostSolve;
            MainBody = new Body(_world);
            MainBody.BodyType = BodyType.Dynamic;

            foreach (Vertices part in vertices)
            {
                PolygonShape polygonShape = new PolygonShape(part, density);
                Fixture fixture = MainBody.CreateFixture(polygonShape, userData);
                Parts.Add(fixture);
            }
        }
示例#12
0
        public WallPopper(Vector2 farseerLoc, World w, RagdollManager r)
        {
            DebugMaterial gray = new DebugMaterial(MaterialType.Blank)
            {
                Color = Color.DarkGray
            };

            body = new Body(w);
            body.Rotation = -(float)Math.PI / 2;
            Vertices popperShape = new Vertices(new Vector2[] {new Vector2(-1.2f, .8f), new Vector2(-1.2f, -.8f), new Vector2(1.2f, -.4f), new Vector2(1.2f, .4f)});
            FixtureFactory.AttachPolygon(popperShape, 1, body, gray);
            body.Position = farseerLoc;
            body.BodyType = BodyType.Dynamic;
            body.IsBullet = true;
            //b.CollidesWith = Category.None;

            Init(w, r);

        }
示例#13
0
        private void CreateObstacles()
        {
            DebugMaterial material = new DebugMaterial(MaterialType.Dots)
                                         {
                                             Color = Color.SandyBrown,
                                             Scale = 8f
                                         };

            Fixture[] rect = new Fixture[4];

            for (int i = 0; i < 4; i++)
            {
                rect[i] = FixtureFactory.CreateRectangle(World, 6, 1.5f, 1, material);
            }
            rect[0].Body.Position = new Vector2(-9, -5);
            rect[1].Body.Position = new Vector2(-8, 7);
            rect[2].Body.Position = new Vector2(9, -7);
            rect[3].Body.Position = new Vector2(7, 5);
        }
示例#14
0
        public Agent(World world, Vector2 position)
        {
            _collidesWith = Category.All;
            _collisionCategories = Category.All;

            _agentBody = BodyFactory.CreateBody(world, position);
            _agentBody.BodyType = BodyType.Dynamic;

            DebugMaterial matBody = new DebugMaterial(MaterialType.Blank)
                                        {
                                            Color = Color.LightGray
                                        };
            DebugMaterial matHands = new DebugMaterial(MaterialType.Squares)
                                         {
                                             Color = Color.DarkOrange,
                                             Scale = 8f,
                                             Depth = 0.0f
                                         };

            //Center
            FixtureFactory.CreateCircle(1, 1, _agentBody, matBody);

            //Left arm
            FixtureFactory.CreateRectangle(3, 0.8f, 1, new Vector2(-2, 0), _agentBody, matBody);
            FixtureFactory.CreateCircle(1, 1, _agentBody, new Vector2(-4, 0), matHands);

            //Right arm
            FixtureFactory.CreateRectangle(3, 0.8f, 1, new Vector2(2, 0), _agentBody, matBody);
            FixtureFactory.CreateCircle(1, 1, _agentBody, new Vector2(4, 0), matHands);

            //Top arm
            FixtureFactory.CreateRectangle(0.8f, 3, 1, new Vector2(0, 2), _agentBody, matBody);
            FixtureFactory.CreateCircle(1, 1, _agentBody, new Vector2(0, 4), matHands);

            //Bottom arm
            FixtureFactory.CreateRectangle(0.8f, 3, 1, new Vector2(0, -2), _agentBody, matBody);
            FixtureFactory.CreateCircle(1, 1, _agentBody, new Vector2(0, -4), matHands);
        }
示例#15
0
        public Rocket(Vector2 farseerLoc, World w, RagdollBase r)
        {
            ragdoll = r;
            world = w;
            Alive = true;

            DebugMaterial gray = new DebugMaterial(MaterialType.Blank)
            {
                Color = Color.DarkGray
            };
            body = new Body(w);
            pivot = FixtureFactory.AttachEllipse(.8f, .2f, 8, 1, body, gray);

            body.Position = farseerLoc;
            body.BodyType = BodyType.Dynamic;
            body.IgnoreGravity = true;

            Vector2 toRagdoll = r.Body.Position - farseerLoc;
            body.Rotation = (float) Math.Atan2(toRagdoll.Y, toRagdoll.X);

            body.OnCollision += new OnCollisionEventHandler(body_OnCollision);

        }
示例#16
0
        public override void LoadContent()
        {
            World = new World(new Vector2(0, -20));
            base.LoadContent();

            _agent = new Agent(World, new Vector2(5, 10));

            Vertices box = PolygonTools.CreateRectangle(0.75f, 0.75f);
            PolygonShape shape = new PolygonShape(box, 1);

            Vector2 x = new Vector2(-14.0f, -23.0f);
            Vector2 deltaX = new Vector2(1.0f, 1.50f);
            Vector2 deltaY = new Vector2(2, 0.0f);

            DebugMaterial matBox = new DebugMaterial(MaterialType.Blank)
                                       {
                                           Color = Color.WhiteSmoke
                                       };

            for (int i = 0; i < PyramidBaseBodyCount; ++i)
            {
                Vector2 y = x;

                for (int j = i; j < PyramidBaseBodyCount; ++j)
                {
                    Body body = BodyFactory.CreateBody(World);
                    body.BodyType = BodyType.Dynamic;
                    body.Position = y;
                    body.CreateFixture(shape, matBox);

                    y += deltaY;
                }

                x += deltaX;
            }
        }
示例#17
0
        public override void LoadContent()
        {
            World = new World(new Vector2(0, -20));
            base.LoadContent();

            DebugMaterial material = new DebugMaterial(MaterialType.Waves)
                                         {
                                             Color = Color.Chocolate,
                                             Scale = 4f
                                         };

            _circle = new Fixture[6];
            Vector2 _position = new Vector2(-14f, 0f);
            float _restitution = 0f;

            for (int i = 0; i < 6; ++i)
            {
                _circle[i] = FixtureFactory.CreateCircle(World, 2f, 1f, _position, material);
                _circle[i].Body.BodyType = BodyType.Dynamic;
                _circle[i].Restitution = _restitution;
                _position.X += 6f;
                _restitution += 0.2f;
            }
        }
示例#18
0
        public static void Init()
        {
            


            
            
            editingTexture = new DebugMaterial(MaterialType.Stars)
            {
                Color = Microsoft.Xna.Framework.Color.Red,
                Scale = 8f
            };

            selectTexture = new DebugMaterial(MaterialType.Stars)
            {
                Color = Microsoft.Xna.Framework.Color.Yellow,
                Scale = 8f
            };

            objectiveTexture = new DebugMaterial(MaterialType.Stars)
            {
                Color = Color.OrangeRed,
                Scale = 4f
            };

            completedObjectiveTexture = new DebugMaterial(MaterialType.Stars)
            {
                Color = Color.Gray,
                Scale = 4f
            };
            powerupTexture = new DebugMaterial(MaterialType.Stars)
            {
                Color = new Color(.8f, 0, .8f),
                Scale = 4f
            };
        }
示例#19
0
 public static Body CreateRoundedRectangle(World world, float width, float height, float xRadius,
                                           float yRadius,
                                           int segments, float density,DebugMaterial userData)
 {
     return CreateRoundedRectangle(world, width, height, xRadius, yRadius, segments, density, Vector2.Zero,
                                   userData);
 }
示例#20
0
        //Torso
        private void CreateBody(World world, Vector2 position)
        {
            DebugMaterial matHead = new DebugMaterial(MaterialType.Face)
                                        {
                                            Color = Color.DeepSkyBlue,
                                            Scale = 2f
                                        };
            DebugMaterial matBody = new DebugMaterial(MaterialType.Squares)
                                        {
                                            Color = Color.DeepSkyBlue,
                                            Scale = 8f
                                        };

            //Head
            _head = FixtureFactory.CreateCircle(world, .9f, 10, matHead);
            _head.Body.BodyType = BodyType.Dynamic;
            _head.Body.AngularDamping = LimbAngularDamping;
            _head.Body.Mass = 2;
            _head.Body.Position = position;

            //Body
            _body = FixtureFactory.CreateRoundedRectangle(world, 2, 4, .5f, .7f, 2, 10, matBody);
            _body[0].Body.BodyType = BodyType.Dynamic;
            _body[0].Body.Mass = 2;
            _body[0].Body.Position = position + new Vector2(0, -3);

            //Left Arm
            _lowerLeftArm = FixtureFactory.CreateCapsule(world, 1, .45f, ArmDensity, matBody);
            _lowerLeftArm[0].Body.BodyType = BodyType.Dynamic;
            _lowerLeftArm[0].Body.AngularDamping = LimbAngularDamping;
            _lowerLeftArm[0].Body.Mass = 2;
            _lowerLeftArm[0].Body.Rotation = -1.4f;
            _lowerLeftArm[0].Body.Position = position + new Vector2(-4, -2.2f);

            _upperLeftArm = FixtureFactory.CreateCapsule(world, 1, .45f, ArmDensity, matBody);
            _upperLeftArm[0].Body.BodyType = BodyType.Dynamic;
            _upperLeftArm[0].Body.AngularDamping = LimbAngularDamping;
            _upperLeftArm[0].Body.Mass = 2;
            _upperLeftArm[0].Body.Rotation = -1.4f;
            _upperLeftArm[0].Body.Position = position + new Vector2(-2, -1.8f);

            //Right Arm
            _lowerRightArm = FixtureFactory.CreateCapsule(world, 1, .45f, ArmDensity, matBody);
            _lowerRightArm[0].Body.BodyType = BodyType.Dynamic;
            _lowerRightArm[0].Body.AngularDamping = LimbAngularDamping;
            _lowerRightArm[0].Body.Mass = 2;
            _lowerRightArm[0].Body.Rotation = 1.4f;
            _lowerRightArm[0].Body.Position = position + new Vector2(4, -2.2f);

            _upperRightArm = FixtureFactory.CreateCapsule(world, 1, .45f, ArmDensity, matBody);
            _upperRightArm[0].Body.BodyType = BodyType.Dynamic;
            _upperRightArm[0].Body.AngularDamping = LimbAngularDamping;
            _upperRightArm[0].Body.Mass = 2;
            _upperRightArm[0].Body.Rotation = 1.4f;
            _upperRightArm[0].Body.Position = position + new Vector2(2, -1.8f);

            //Left Leg
            _lowerLeftLeg = FixtureFactory.CreateCapsule(world, 1, .5f, LegDensity, matBody);
            _lowerLeftLeg[0].Body.BodyType = BodyType.Dynamic;
            _lowerLeftLeg[0].Body.AngularDamping = LimbAngularDamping;
            _lowerLeftLeg[0].Body.Mass = 2;
            _lowerLeftLeg[0].Body.Position = position + new Vector2(-0.6f, -8);

            _upperLeftLeg = FixtureFactory.CreateCapsule(world, 1, .5f, LegDensity, matBody);
            _upperLeftLeg[0].Body.BodyType = BodyType.Dynamic;
            _upperLeftLeg[0].Body.AngularDamping = LimbAngularDamping;
            _upperLeftLeg[0].Body.Mass = 2;
            _upperLeftLeg[0].Body.Position = position + new Vector2(-0.6f, -6);

            //Right Leg
            _lowerRightLeg = FixtureFactory.CreateCapsule(world, 1, .5f, LegDensity, matBody);
            _lowerRightLeg[0].Body.BodyType = BodyType.Dynamic;
            _lowerRightLeg[0].Body.AngularDamping = LimbAngularDamping;
            _lowerRightLeg[0].Body.Mass = 2;
            _lowerRightLeg[0].Body.Position = position + new Vector2(0.6f, -8);

            _upperRightLeg = FixtureFactory.CreateCapsule(world, 1, .5f, LegDensity, matBody);
            _upperRightLeg[0].Body.BodyType = BodyType.Dynamic;
            _upperRightLeg[0].Body.AngularDamping = LimbAngularDamping;
            _upperRightLeg[0].Body.Mass = 2;
            _upperRightLeg[0].Body.Position = position + new Vector2(0.6f, -6);
        }
示例#21
0
        public Fixture(Body body, Shape shape,DebugMaterial userData)
        {
            if (Settings.UseFPECollisionCategories)
                _collisionCategories = Category.All;
            else
                _collisionCategories = Category.Cat1;

            _collidesWith = Category.All;
            _collisionGroup = 0;

            //Fixture defaults
            Friction = 0.2f;
            Restitution = 0;

            IsSensor = false;

            Body = body;
            UserData = userData;

            if (Settings.ConserveMemory)
                Shape = shape;
            else
                Shape = shape.Clone();

            RegisterFixture();
        }
示例#22
0
        public static Body CreateRectangle(World world, float width, float height, float density, Vector2 position,
                                          DebugMaterial userData)
        {
            if (width <= 0)
                throw new ArgumentOutOfRangeException("width", "Width must be more than 0 meters");

            if (height <= 0)
                throw new ArgumentOutOfRangeException("height", "Height must be more than 0 meters");

            Body newBody = CreateBody(world, position);
            Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
            PolygonShape rectangleShape = new PolygonShape(rectangleVertices, density);
            newBody.CreateFixture(rectangleShape, userData);

            return newBody;
        }
示例#23
0
 public static Body CreateRectangle(World world, float width, float height, float density, DebugMaterial userData)
 {
     return CreateRectangle(world, width, height, density, Vector2.Zero, userData);
 }
示例#24
0
        /// <summary>
        /// Creates a rounded rectangle.
        /// Note: Automatically decomposes the capsule if it contains too many vertices (controlled by Settings.MaxPolygonVertices)
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="xRadius">The x radius.</param>
        /// <param name="yRadius">The y radius.</param>
        /// <param name="segments">The segments.</param>
        /// <param name="density">The density.</param>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public static Body CreateRoundedRectangle(World world, float width, float height, float xRadius,
                                                  float yRadius,
                                                  int segments, float density, Vector2 position,
                                                 DebugMaterial userData)
        {
            Vertices verts = PolygonTools.CreateRoundedRectangle(width, height, xRadius, yRadius, segments);

            //There are too many vertices in the capsule. We decompose it.
            if (verts.Count >= Settings.MaxPolygonVertices)
            {
                List<Vertices> vertList = EarclipDecomposer.ConvexPartition(verts);
                Body body = CreateCompoundPolygon(world, vertList, density, userData);
                body.Position = position;
                return body;
            }

            return CreatePolygon(world, verts, density);
        }
示例#25
0
 public static Body CreateLoopShape(World world, Vertices vertices,DebugMaterial userData)
 {
     return CreateLoopShape(world, vertices, Vector2.Zero, userData);
 }
示例#26
0
 public static Body CreateEdge(World world, Vector2 start, Vector2 end, DebugMaterial userData)
 {
     Body body = CreateBody(world);
     FixtureFactory.AttachEdge(start, end, body, userData);
     return body;
 }
示例#27
0
        /// <summary>
        /// Creates a breakable body. You would want to remove collinear points before using this.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="vertices">The vertices.</param>
        /// <param name="density">The density.</param>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public static BreakableBody CreateBreakableBody(World world, Vertices vertices, float density, Vector2 position,
                                                       DebugMaterial userData)
        {
            List<Vertices> triangles = EarclipDecomposer.ConvexPartition(vertices);

            BreakableBody breakableBody = new BreakableBody(triangles, world, density, userData);
            breakableBody.MainBody.Position = position;
            world.AddBreakableBody(breakableBody);

            return breakableBody;
        }
示例#28
0
        /// <summary>
        /// Duplicates the given Body along the given path for approximatly the given copies.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="path">The path.</param>
        /// <param name="shape">The shape.</param>
        /// <param name="type">The type.</param>
        /// <param name="copies">The copies.</param>
        /// <param name="userData">The user data.</param>
        /// <returns></returns>
        public static List<Body> EvenlyDistributeShapesAlongPath(World world, Path path, Shape shape, BodyType type,
                                                                 int copies, DebugMaterial userData)
        {
            List<Shape> shapes = new List<Shape>(1);
            shapes.Add(shape);

            return EvenlyDistributeShapesAlongPath(world, path, shapes, type, copies, userData);
        }
示例#29
0
        /// <summary>
        /// Duplicates the given Body along the given path for approximatly the given copies.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="path">The path.</param>
        /// <param name="shapes">The shapes.</param>
        /// <param name="type">The type.</param>
        /// <param name="copies">The copies.</param>
        /// <param name="userData"></param>
        /// <returns></returns>
        public static List<Body> EvenlyDistributeShapesAlongPath(World world, Path path, IEnumerable<Shape> shapes,
                                                                 BodyType type, int copies, DebugMaterial userData)
        {
            List<Vector3> centers = path.SubdivideEvenly(copies);
            List<Body> bodyList = new List<Body>();

            for (int i = 0; i < centers.Count; i++)
            {
                Body b = new Body(world);

                // copy the type from original body
                b.BodyType = type;
                b.Position = new Vector2(centers[i].X, centers[i].Y);
                b.Rotation = centers[i].Z;

                foreach (Shape shape in shapes)
                {
                    b.CreateFixture(shape, userData);
                }

                bodyList.Add(b);
            }

            return bodyList;
        }
示例#30
0
 public static BreakableBody CreateBreakableBody(World world, Vertices vertices, float density,DebugMaterial userData)
 {
     return CreateBreakableBody(world, vertices, density, Vector2.Zero, userData);
 }