Пример #1
0
        private LineJointTest()
        {
            Body ground;
            {
                PolygonShape shape = new PolygonShape(PolygonTools.CreateEdge(new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f)), 0);


                ground = World.CreateBody();
                ground.CreateFixture(shape);
            }

            {
                PolygonShape shape = new PolygonShape(PolygonTools.CreateRectangle(0.5f, 2.0f), 1);

                Body body = World.CreateBody();
                body.BodyType = BodyType.Dynamic;
                body.Position = new Vector2(0.0f, 7.0f);

                body.CreateFixture(shape);

                Vector2 axis = new Vector2(2.0f, 1.0f);
                axis.Normalize();
                //LineJoint jd = new LineJoint(ground, body, new Vector2(0.0f, 8.5f),new Vector2(1.0f, 2.5f), axis);
                FixedLineJoint jd = new FixedLineJoint(body, /*ground, */ new Vector2(1.0f, 1.5f), new Vector2(10.0f, 8.5f), axis);
                jd.MotorSpeed    = 100.0f;
                jd.MaxMotorForce = 100.0f;
                jd.MotorEnabled  = false;
                jd.LowerLimit    = -4.0f;
                jd.UpperLimit    = 4.0f;
                jd.EnableLimit   = true;
                World.CreateJoint(jd);
                _jd = jd;
            }
        }
Пример #2
0
        private LineJointTest()
        {
            Body ground = BodyFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));

            {
                PolygonShape shape = new PolygonShape(1);
                shape.SetAsBox(0.5f, 2.0f);

                Body body = new Body(World);
                body.BodyType = BodyType.Dynamic;
                body.Position = new Vector2(0.0f, 7.0f);

                body.CreateFixture(shape);

                Vector2 axis = new Vector2(-1000.0f, -2.0f);
                axis.Normalize();

                LineJoint jd = new LineJoint(ground, body, new Vector2(0, 8.5f), axis);
                jd.MotorSpeed     = 1.0f;
                jd.MaxMotorTorque = 1000.0f;
                jd.MotorEnabled   = true;
                jd.Frequency      = 1.0f;
                jd.DampingRatio   = 0.2f;
                World.AddJoint(jd);

                PolygonShape shape2 = new PolygonShape(1);
                shape2.SetAsBox(0.5f, 2.0f);
                Body body2 = BodyFactory.CreatePolygon(World, shape2.Vertices, 0.5f);
                body2.BodyType = BodyType.Dynamic;
                body2.Position = new Vector2(10.0f, 7.0f);

                FixedLineJoint jdf = new FixedLineJoint(body2, new Vector2(10, 8.5f), axis);
                jdf.MotorSpeed     = 1.0f;
                jdf.MaxMotorTorque = 1000.0f;
                jdf.MotorEnabled   = true;
                jdf.Frequency      = 1.0f;
                jdf.DampingRatio   = 0.2f;
                World.AddJoint(jdf);
            }
        }