public AxisOrientationConstraint(ConstraintAxis axis, float angleMin, float angleMax)
{
// Set the axis that we will rotate around
this.axis = (int)axis;
switch (axis)
{
case ConstraintAxis.X:
this.rotateAround = Vector3.right;
break;
case ConstraintAxis.Y:
this.rotateAround = Vector3.up;
break;
case ConstraintAxis.Z:
this.rotateAround = Vector3.forward;
break;
default:
this.rotateAround = Vector3.zero;
break;
}
// Set the min and max rotations in degrees
this.angleMin = angleMin;
this.angleMax = angleMax;
// Set the min and max rotations in quaternion space
this.minQuaternion = Quaternion.AngleAxis(angleMin, this.rotateAround);
this.maxQuaternion = Quaternion.AngleAxis(angleMax, this.rotateAround);
this.angleRange = angleMax - angleMin;
}