A mouse joint is used to make a point on a body track a specified world point. This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces. NOTE: this joint is not documented in the manual because it was developed to be used in the testbed. If you want to learn how to use the mouse joint, look at the testbed.
Inheritance: Joint
コード例 #1
0
ファイル: HexScene.cs プロジェクト: hgrandry/Mgx
        private Body BuildHexagon(BodyRenderer renderer, Color color, Vector2 pos, float radius, float spacing)
        {
            var poly = ShapeFactory.Hexagon(Vector2.Zero, radius);
            var body = Physic.World.CreatePolygon(new Vertices(poly), 1, pos);
            body.SetCollisionType(HexPhysicTypes.Ground);

            if (radius < 5)
            {
                body.BodyType = BodyType.Dynamic;
                body.AngularDamping = 5f;
                /*var distanceJoint = K2.Physic.JointFactory.CreateFixedDistanceJoint(body, Vector2.Zero, pos);
                    distanceJoint.Frequency = 10;
                    distanceJoint.Length = radius * .2f;
                    distanceJoint.DampingRatio = 1;*/

                var j = new FixedMouseJoint(body, pos)
                        {
                            Frequency = 1000,
                            MaxForce = 100,
                            DampingRatio = 1,
                            Breakpoint = 150,
                        };
                Physic.World.AddJoint(j);
            }

            renderer.Add(body, color);

            return body;
        }
コード例 #2
0
ファイル: Wheel.cs プロジェクト: slavede/InitialGame
        public void clearLock()
        {
            if(fixedMouseJoint != null)
            {
                world.RemoveJoint(fixedMouseJoint);
                fixedMouseJoint = null;
            }

            if (idleJoint != null)
            {
                return;
            }

            selectedEntryIndex = (int)Math.Round(entries.Count * normalizeOrientation(wheelBody.Rotation) / (2 * Math.PI), 0, MidpointRounding.AwayFromZero) % entries.Count;
            selectedEntryPosition = getSeletedEntryPosition();
            Fixture savedFixture = world.TestPoint(selectedEntryPosition);
            if (savedFixture != null)
            {
                Body body = savedFixture.Body;
                idleJoint = new FixedMouseJoint(body, new Vector2(radius, 0));

                idleJoint.DampingRatio = 0f;
                idleJoint.MaxForce = 3000.0f * body.Mass;
                world.AddJoint(idleJoint);
                body.Awake = true;
                idleJoint.WorldAnchorB = selectedEntryPosition;
            }
        }
コード例 #3
0
        protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            MouseState ms = Mouse.GetState();
            Vector2 position = camera.ConvertScreenToWorld(new Vector2(ms.X,ms.Y),true,false);
            
            if (ms.LeftButton == ButtonState.Pressed && _fixedMouseJoint == null)
            {
                Fixture savedFixture = world.World.TestPoint(position);
                if (savedFixture != null)
                {
                    Body body = savedFixture.Body;
                    _fixedMouseJoint = new FixedMouseJoint(body, position);
                    _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                    world.World.AddJoint(_fixedMouseJoint);
                    body.Awake = true;
                }
            }

            if (ms.LeftButton == ButtonState.Released && _fixedMouseJoint != null)
            {
                world.World.RemoveJoint(_fixedMouseJoint);
                _fixedMouseJoint = null;
            }

            if (_fixedMouseJoint != null)
            {
                _fixedMouseJoint.WorldAnchorB = position;
            }
        }        
コード例 #4
0
ファイル: FSWorld.cs プロジェクト: prime31/Nez
		public override void update()
		{
			if( enableMousePicking )
			{
				if( Input.leftMouseButtonPressed )
				{
					var pos = Core.scene.camera.screenToWorldPoint( Input.mousePosition );
					var fixture = world.testPoint( FSConvert.displayToSim * pos );
					if( fixture != null && !fixture.body.isStatic && !fixture.body.isKinematic )
						_mouseJoint = fixture.body.createFixedMouseJoint( pos );
				}

				if( Input.leftMouseButtonDown && _mouseJoint != null )
				{
					var pos = Core.scene.camera.screenToWorldPoint( Input.mousePosition );
					_mouseJoint.worldAnchorB = FSConvert.displayToSim * pos;
				}

				if( Input.leftMouseButtonReleased && _mouseJoint != null )
				{
					world.removeJoint( _mouseJoint );
					_mouseJoint = null;
				}
			}

			world.step( MathHelper.Min( Time.deltaTime, minimumUpdateDeltaTime ) );
		}
コード例 #5
0
        public static FixedMouseJoint CreateFixedMouseJoint(World world, Body body, Vector2 worldAnchor)
        {
            FixedMouseJoint joint = new FixedMouseJoint(body, worldAnchor);

            world.Add(joint);
            return(joint);
        }
コード例 #6
0
ファイル: FSMouseTest.cs プロジェクト: rllamas/Quantum
    public virtual void MouseDrag()
    {
        // mouse press
        if(Input.GetMouseButtonDown(0) && mouseJoint == null)
        {
            Body body = GetBodyAtMouse();
            if(body != null)
            {
                FVector2 target = new FVector2(MouseXWorldPhys, MouseYWorldPhys);
                mouseJoint = JointFactory.CreateFixedMouseJoint(FSWorldComponent.PhysicsWorld, body, target);
                mouseJoint.CollideConnected = true;
                mouseJoint.MaxForce = 300f * body.Mass;
                body.Awake = true;
            }
        }
        // mouse release
        if(Input.GetMouseButtonUp(0))
        {
            if(mouseJoint != null)
            {
                FSWorldComponent.PhysicsWorld.RemoveJoint(mouseJoint);
                mouseJoint = null;
            }
        }

        // mouse move
        if(mouseJoint != null)
        {
            FVector2 p2 = new FVector2(MouseXWorldPhys, MouseYWorldPhys);
            mouseJoint.WorldAnchorB = p2;
        }
    }
コード例 #7
0
ファイル: FixedMouseJointInfo.cs プロジェクト: undue/duality
		protected override Joint CreateJoint(Body bodyA, Body bodyB)
		{
			if (bodyA == null) return null;
			FixedMouseJoint mj = new FixedMouseJoint(bodyA, Vector2.Zero);
			Scene.PhysicsWorld.AddJoint(mj);
			return mj;
		}
コード例 #8
0
        protected override void CreateExtraJoints(World world)
        {
            rightHandSpring = new FixedMouseJoint(_lowerRightArm, _lowerRightArm.Position);
            rightHandSpring.MaxForce = 1000.0f * _lowerRightArm.Mass;
            world.AddJoint(rightHandSpring);

            leftHandSpring = new FixedMouseJoint(_lowerLeftArm, _lowerLeftArm.Position);
            leftHandSpring.MaxForce = 1000.0f * _lowerLeftArm.Mass;
            world.AddJoint(leftHandSpring);
        }
コード例 #9
0
ファイル: DGPlayer.cs プロジェクト: rantingmong/Diseases-game
        public override void LoadContent(ContentManager content, World physics)
        {
            base.LoadContent(content, physics);

            this.physics.Position = ConvertUnits.ToSimUnits(50, 50);
            this.physics.CollisionCategories = Category.Cat1;
            this.physics.CollidesWith = Category.Cat1;

            fixture = new FixedMouseJoint(this.physics, ConvertUnits.ToSimUnits(new Vector2(50)));
            fixture.MaxForce = float.MaxValue;

            physics.AddJoint(fixture);
        }
コード例 #10
0
 public void Update(GameTime gameTime, CameraOperator cameraOperator, World world)
 {
     _sprite.Body.Center = Input.Mouse.Position;
     if (_mouseJoint != null)
     {
         if (Input.Mouse.IsButtonDown(Input.Mouse.MouseButton.Left))
         {
             _mouseJoint.WorldAnchorB = cameraOperator.Camera.PositionOnWorld(Input.Mouse.Position);
         }
         else
         {
             world.RemoveJoint(_mouseJoint);
             _mouseJoint = null;
         }
     }
     else
     {
         Vector2 cursorWorldPosition = cameraOperator.Camera.PositionOnWorld(Input.Mouse.Position);
         if (Input.Mouse.IsButtonClicked(Input.Mouse.MouseButton.Left))
         {
             Fixture fixture;
             float radiusMeters = _sprite.Body.Projection.BoundingBox.Dimensions.X.ToMeters();
             if ((fixture =
                 world.TestPoint(cursorWorldPosition - new Vector2(radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition + new Vector2(radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition + new Vector2(radiusMeters, -radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition - new Vector2(radiusMeters, -radiusMeters))) != null)
             {
                 if (fixture.UserData is Coin)
                 {
                     _mouseJoint = new FixedMouseJoint(fixture.Body, cursorWorldPosition)
                     {
                         MaxForce = 200*fixture.Body.Mass
                     };
                     world.AddJoint(_mouseJoint);
                 }
             }
         }
     }
 }
コード例 #11
0
        protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            // Process touch events
            TouchCollection touchCollection = TouchPanel.GetState();
            if (touchCollection.Count > 0)
            {
                TouchLocation tl = touchCollection[0];

                Vector2 position = camera.ConvertScreenToWorld(new Vector2(tl.Position.X,
                         tl.Position.Y),true,false);

                if (tl.State == TouchLocationState.Pressed && _fixedMouseJoint == null)
                {
                    Fixture savedFixture = world.World.TestPoint(position);
                    if (savedFixture != null)
                    {
                        Body body = savedFixture.Body;
                        _fixedMouseJoint = new FixedMouseJoint(body, position);
                        _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                        world.World.AddJoint(_fixedMouseJoint);
                        body.Awake = true;
                    }
                }

                if (tl.State == TouchLocationState.Released && _fixedMouseJoint != null)
                {
                    world.World.RemoveJoint(_fixedMouseJoint);
                    _fixedMouseJoint = null;
                }

                if (_fixedMouseJoint != null)
                {
                    _fixedMouseJoint.WorldAnchorB = position;
                }

            }
        }
コード例 #12
0
ファイル: Test.cs プロジェクト: boris2/mmogameproject2
        private void MouseDown(Vector2 p)
        {
            if (_fixedMouseJoint != null)
                return;

            Fixture fixture = World.TestPoint(p);

            if (fixture != null)
            {
                Body body = fixture.Body;
                _fixedMouseJoint = new FixedMouseJoint(body, p);
                _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                World.AddJoint(_fixedMouseJoint);
                body.Awake = true;
            }
        }
コード例 #13
0
ファイル: Test.cs プロジェクト: boris2/mmogameproject2
 protected virtual void JointRemoved(Joint joint)
 {
     if (_fixedMouseJoint == joint)
         _fixedMouseJoint = null;
 }
コード例 #14
0
        private void HandleCursor(InputHelper input)
        {
            Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);

            if ((input.IsNewButtonPress(Buttons.A) ||
                 input.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
                _fixedMouseJoint == null)
            {
                Fixture savedFixture = World.TestPoint(position);
                if (savedFixture != null)
                {
                    Body body = savedFixture.Body;
                    _fixedMouseJoint = new FixedMouseJoint(body, position);
                    _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                    World.AddJoint(_fixedMouseJoint);
                    body.Awake = true;
                }
            }

            if ((input.IsNewButtonRelease(Buttons.A) ||
                 input.IsNewMouseButtonRelease(MouseButtons.LeftButton)) &&
                _fixedMouseJoint != null)
            {
                World.RemoveJoint(_fixedMouseJoint);
                _fixedMouseJoint = null;
            }

            if (_fixedMouseJoint != null)
            {
                _fixedMouseJoint.WorldAnchorB = position;
            }
        }
コード例 #15
0
ファイル: FSJointDef.cs プロジェクト: prime31/Nez
		public override Joint createJoint()
		{
			var joint = new FixedMouseJoint( bodyA, worldAnchor * FSConvert.displayToSim );
			joint.collideConnected = collideConnected;

			// conditionally set the maxForce
			if( maxForce > 0 )
				joint.maxForce = maxForce;
			
			joint.frequency = frequency;
			joint.dampingRatio = dampingRatio;
			return joint;
		}
コード例 #16
0
        private void MouseDown(Vector2 p)
        {

            InputHelper inputHelper = game.inputManager.inputHelper;

            if (_fixedMouseJoint != null)
            {
                return;
            }

            savedFixture = game.farseerManager.world.TestPoint(p);

            if (savedFixture != null)
            {
                Body body = savedFixture.Body;
                if (!body.IsStatic)
                {
                    _fixedMouseJoint = new FixedMouseJoint(body, p);
                    _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                    game.farseerManager.world.AddJoint(_fixedMouseJoint);
                    body.Awake = true;
                }
                else
                {
                    dragging = true;
                }
            }
            else // start a selection rectangle
            {
                dragStartWorld = p;
                dragStartPixel = inputHelper.MousePosition;
                selectingRectangle = true;
                dragArea = new DragArea(dragStartPixel, dragStartPixel);
            }
        }
コード例 #17
0
        public void sendCreateMouseJoint(FixedMouseJoint mouseJoint)
        {
            NetOutgoingMessage om = _peer.CreateMessage();
            Body body = mouseJoint.BodyA;
            Vector2 localAnchorA = body.GetLocalVector(mouseJoint.WorldAnchorA);
            Vector2 point = mouseJoint.WorldAnchorB;

            om.Write((int)MessageType.CreateMouseJoint);
            om.Write((int)body.UserData);   // entityId
            om.Write(localAnchorA.X);
            om.Write(localAnchorA.Y);
            om.Write(point.X);
            om.Write(point.Y);

            _peer.SendMessage(om, _peer.Connections[0], NetDeliveryMethod.ReliableUnordered);
        }
コード例 #18
0
 private void MouseUp()
 {
     if (_fixedMouseJoint != null)
     {
         World.RemoveJoint(_fixedMouseJoint);
         _fixedMouseJoint = null;
     }
 }
コード例 #19
0
ファイル: Balloon.cs プロジェクト: dotKokott/MathFighter
 public void Loose()
 {
     Screen.World.RemoveJoint(fixedJoint);
     fixedJoint = null;
     AttachedEntity = null;
 }
コード例 #20
0
ファイル: Balloon.cs プロジェクト: dotKokott/MathFighter
 public void Cut()
 {
     Screen.World.RemoveJoint(HalfJoint);
     Screen.World.RemoveJoint(fixedJoint);
     AttachedEntity = null;
     fixedJoint = null;
 }
コード例 #21
0
        public void CreatePickSpring(sw.Point ptMouse)
        {
            xna.Vector2 pointScreen = new xna.Vector2((float)(ptMouse.X), (float)(ptMouse.Y));

            xna.Vector2 point = PhysicsCanvas.BoundaryHelper.ScreenToWorld(pointScreen);
            _mousePickSpring = new FixedMouseJoint(this.BodyObject, point);
            _mousePickSpring.MaxForce = 1000.0f * this.BodyObject.Mass;
            _mousePickSpring.Enabled = true;

            _physicsCanvas.Simulator.AddJoint(_mousePickSpring);
            this.BodyObject.Awake = true;




            xna.Vector2 pointBody = PhysicsCanvas.BoundaryHelper.WorldToScreen(this.BodyObject.Position);
            _lineShowSpring.X1 = pointBody.X;
            _lineShowSpring.Y1 = pointBody.Y;
            _lineShowSpring.X2 = pointScreen.X;
            _lineShowSpring.Y2 = pointScreen.Y;
            _lineShowSpring.Visibility = Visibility.Visible;
        }
コード例 #22
0
        public void DestroyPickSpring()
        {
            if (_mousePickSpring != null)
            {
                _mousePickSpring.Enabled = false;
                _physicsCanvas.Simulator.RemoveJoint(_mousePickSpring);
                _mousePickSpring = null;

                if (_lineShowSpring != null)
                {
                    _lineShowSpring.Visibility = Visibility.Collapsed;
                }


                if (AllowStaticObjectManipulation && _bodyWasStatic)
                {
                    // save the static attributes
                    BodyObject.AngularDamping = _originalAngularDamping;
                    BodyObject.IsStatic = true;
                    _bodyWasStatic = false;
                }

                if (MousePickCompleted != null)
                    MousePickCompleted(this, _posMouseMoveStart);
            }
        }
コード例 #23
0
        public virtual void HandleCursor(InputState input)
        {
            PlayerIndex player;
            Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);

            if ((input.IsNewButtonPress(Buttons.A, PlayerIndex.One, out player) ||
                    input.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
                _fixedMouseJoint == null)
            {
                Fixture savedFixture = World.TestPoint(position);
                if (savedFixture != null && savedFixture.UserData is SimpleAxiosGameObject && ((SimpleAxiosGameObject)(savedFixture.UserData)).AllowAutomaticMouseJoint)
                {
                    Body body = savedFixture.Body;
                    _fixedMouseJoint = new FixedMouseJoint(body, position);
                    _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                    World.AddJoint(_fixedMouseJoint);
                    body.Awake = true;
                }
            }

            if ((input.IsNewButtonRelease(Buttons.A, ControllingPlayer.Value, out player) ||
                    input.IsNewMouseButtonRelease(MouseButtons.LeftButton)) &&
                _fixedMouseJoint != null)
            {
                World.RemoveJoint(_fixedMouseJoint);
                _fixedMouseJoint = null;
            }

            if (_fixedMouseJoint != null)
            {
                _fixedMouseJoint.WorldAnchorB = position;
            }
        }
コード例 #24
0
        private void MouseUp(Vector2 p)
        {

            InputHelper inputHelper = game.inputManager.inputHelper;
            prevWorldLoc = new Vector2();

            dragging = false;

            if (_fixedMouseJoint != null)
            {
                game.farseerManager.world.RemoveJoint(_fixedMouseJoint);
                _fixedMouseJoint = null;
            }

            if (selectingRectangle)
            {
                selectingRectangle = false;
                if (!ProjectionHelper.InsidePixelBounds(inputHelper.MousePosition)) return;
                DragArea d = new DragArea(dragStartWorld, p);
                List<Object> selected = new List<object>();
                foreach (Body b in game.farseerManager.world.BodyList)
                {
                    if (d.ContainsPixel(b.Position))
                        selected.Add(b);
                }

                foreach (Joint j in game.farseerManager.world.JointList)
                {
                    if (d.ContainsPixel(j.WorldAnchorA))
                        selected.Add(j);
                }

                if (selected.Count > 0)
                {
                    FormManager.Property.setPendingObjects(selected);
                    //if (!FormManager.Property.Visible)
                    //    FormManager.Property.Show();

                }
            }
        }
コード例 #25
0
        private void Circle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //Debug.Print("Circle_MouseLeftButtonDown");
            if (_isDragging) return;
            Debug.Print("Circle_MouseLeftButtonDown - drag start");
            //Mouse.Capture(this, CaptureMode.SubTree);
            //this.CaptureMouse();
            _isDragging = true;
            var circlePoint = e.GetPosition(this);
            var screenPoint = PointToScreen(circlePoint);
            var screenPosition = GetVector2(screenPoint);
            var worldPosition = ConvertUnits.ToSimUnits(screenPosition);

            Textout.Text = "down";

            var fixture = _world.TestPoint(worldPosition);

            if (fixture != null)
            {
                Body body = fixture.Body;
                _mouseJoint = new FixedMouseJoint(body, worldPosition) { MaxForce = 1000000.0f * body.Mass };
                _world.AddJoint(_mouseJoint);
                body.Awake = true;
            }
        }
コード例 #26
0
        private void MouseDown(Vector2 p)
        {
            if (_fixedMouseJoint != null)
            {
                return;
            }

            // Make a small box.
            AABB aabb;
            Vector2 d = new Vector2(0.001f, 0.001f);
            aabb.LowerBound = p - d;
            aabb.UpperBound = p + d;

            Fixture savedFixture = null;

            // Query the world for overlapping shapes.
            World.QueryAABB(
                fixture =>
                {
                    Body body = fixture.Body;
                    if (body.BodyType == BodyType.Dynamic)
                    {
                        bool inside = fixture.TestPoint(ref p);
                        if (inside)
                        {
                            savedFixture = fixture;

                            // We are done, terminate the query.
                            return false;
                        }
                    }

                    // Continue the query.
                    return true;
                }, ref aabb);

            if (savedFixture != null)
            {
                Body body = savedFixture.Body;
                _fixedMouseJoint = new FixedMouseJoint(body, p);
                _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                World.AddJoint(_fixedMouseJoint);
                body.Awake = true;
            }
        }
コード例 #27
0
ファイル: Balloon.cs プロジェクト: dotKokott/MathFighter
        public void AttachTo(BaseEntity entity)
        {
            if (fixedJoint != null) {
                Screen.World.RemoveJoint(fixedJoint);
            }

            AttachedEntity = entity;
            var grabJoint = joints.Last();

            var pos = grabJoint.WorldCenter;
            pos.Y += ConvertUnits.ToSimUnits(10);

            fixedJoint = new FixedMouseJoint(grabJoint, pos);
            fixedJoint.MaxForce = 1000f * 10000; //I don't really know which numbers are good here lol

            fixedJoint.Frequency = 10;

            Screen.World.AddJoint(fixedJoint);

            fixedJoint.WorldAnchorB = ConvertUnits.ToSimUnits(entity.BoundingBox.Center.X, entity.BoundingBox.Center.Y);
            grabJoint.Awake = true;
        }
コード例 #28
0
        private void LoadDynamicObstacles()
        {
            _plankBody = BodyFactory.CreateRectangle(World, 300, 10, 1f);
            _plankBody.BodyType = BodyType.Dynamic;
            _plankBody.Restitution = 1f;

            _plankBodySprite = new Sprite(ScreenManager.Assets.TextureFromShape(_plankBody.FixtureList[0].Shape,
                                                                                MaterialType.Squares,
                                                                                Color.Orange, 1f));

            _fixedMouseJoint = new FixedMouseJoint(_plankBody, plankPosition.getLeftHandPosition());

            _fixedMouseJoint.MaxForce = 1000.0f * _plankBody.Mass;
            World.AddJoint(_fixedMouseJoint);
            _plankBody.Awake = true;

            UpdateDynamicObstacles();
        }
コード例 #29
0
ファイル: PhysicsManager.cs プロジェクト: xaznblade/hwkinect
        private void CreateHandFixture(Hand hand)
        {
            Vector2 handPos = new Vector2(hand.Position.X, hand.Position.Y);
            Body handBody = BodyFactory.CreateCircle(world, handSize, 1f, handPos / MeterInPixels);
            handBody.BodyType = BodyType.Dynamic;

            // Check what hands should be colliding with
            if (handCollisionsEnabled)
            {
                handBody.OnCollision += HandCollisionCheckDelegate;
            }
            else
            {
                handBody.OnCollision += HandCollisionFalseDelegate;
            }

            FixedMouseJoint handJoint = new FixedMouseJoint(handBody, handBody.Position);
            handJoint.MaxForce = 10000f;
            world.AddJoint(handJoint);

            WorldEntity handEntity = new WorldEntity(handBody, handJoint, WorldEntity.EntityType.Hand);
            handBodies.Add(hand, handEntity);
            entities.Add(handBody, handEntity);
        }
コード例 #30
0
        public void sendMoveMouseJoint(FixedMouseJoint joint)
        {
            NetOutgoingMessage om = _peer.CreateMessage();

            om.Write((int)MessageType.MoveMouseJoint);
            om.Write(joint.WorldAnchorB.X);
            om.Write(joint.WorldAnchorB.Y);
            _peer.SendMessage(om, _peer.Connections[0], NetDeliveryMethod.ReliableUnordered);
        }
コード例 #31
0
 public static FixedMouseJoint CreateFixedMouseJoint(World world, Body body, Vector2 worldAnchor)
 {
     FixedMouseJoint joint = new FixedMouseJoint(body, worldAnchor);
     world.AddJoint(joint);
     return joint;
 }