public void SetupJointTransforms(Vector3 twistAxis)
{
//Compute a vector which is perpendicular to the axis. It'll be added in local space to both connections.
Vector3 xAxis;
Vector3.Cross(ref twistAxis, ref Toolbox.UpVector, out xAxis);
float length = xAxis.LengthSquared();
if (length < Toolbox.Epsilon)
{
Vector3.Cross(ref twistAxis, ref Toolbox.RightVector, out xAxis);
}
Vector3 yAxis;
Vector3.Cross(ref twistAxis, ref xAxis, out yAxis);
//Put the axes into the joint transform of A.
basis.rotationMatrix = connectionA.orientationMatrix;
basis.SetWorldAxes(twistAxis, xAxis, yAxis);
//Put the axes into the 'joint transform' of B too.
TwistAxisB = twistAxis;
}