예제 #1
0
        private void OnContactDown(object sender, ContactEventArgs e)
        {
            ContactInfo        contact    = e.Contact;
            ContactInfoModel   model      = new ContactInfoModel(contact);
            Point              localPoint = e.GetPosition(this);
            HitTestResult      test       = VisualTreeHelper.HitTest(this, localPoint);
            MultitouchListItem item       = ContainerFromElement(test.VisualHit) as MultitouchListItem;

            if (item != null)
            {
                MakeSelected(item);
                e.Handled = true;

                if (physicsController != null)
                {
                    Body body = physicsController.GetBody(item);
                    if (body != null)
                    {
                        Vector2D point = new Vector2D(localPoint.X, localPoint.Y);
                        if (!body.Shape.BroadPhaseDetectionOnly && body.Shape.CanGetIntersection)
                        {
                            Vector2D         temp = body.Matrices.ToBody * point;
                            IntersectionInfo info;
                            if (body.Shape.TryGetIntersection(temp, out info))
                            {
                                CustomFixedHingeJoint joint = new CustomFixedHingeJoint(body, point, new Lifespan());
                                physicsController.Engine.AddJoint(joint);
                                contactJoints[model.Id] = joint;
                            }
                        }
                    }
                }
            }
            UpdateAdorner();
        }