Example #1
0
        public HingeJoint(Body body1, Body body2, Vector2D anchor, Lifespan lifetime)
            : base(lifetime)
        {
            if (body1 == null) { throw new ArgumentNullException("body1"); }
            if (body2 == null) { throw new ArgumentNullException("body2"); }
            this.body1 = body1;
            this.body2 = body2;
            body1.ApplyMatrix();
            body2.ApplyMatrix();

            Matrix3x3 matrix1 = body1.Shape.MatrixInv.VertexMatrix;
            Matrix3x3 matrix2 = body2.Shape.MatrixInv.VertexMatrix;
            Vector2D.Transform(ref matrix1, ref anchor, out localAnchor1);
            Vector2D.Transform(ref matrix2, ref anchor, out localAnchor2);

            relaxation = 1.0f;
            biasFactor = .1f;
        }