예제 #1
0
    /// <summary>
    /// Checks the angle restrictions.
    /// </summary>
    /// <param name="jointEntity">Joint entity</param>
    void CheckAngleRestrictions(JointEntity jointEntity)
    {
        Vector3 euler = jointEntity.Joint.localRotation.eulerAngles;

        if (jointEntity.AngleRestrictionRange.xAxis)
        {
            if (euler.x > 180f)
            {
                euler.x -= 360f;
            }
            euler.x = Mathf.Clamp(euler.x, jointEntity.AngleRestrictionRange.xMin, jointEntity.AngleRestrictionRange.xMax);
        }

        if (jointEntity.AngleRestrictionRange.yAxis)
        {
            if (euler.y > 180f)
            {
                euler.y -= 360f;
            }
            euler.y = Mathf.Clamp(euler.y, jointEntity.AngleRestrictionRange.yMin, jointEntity.AngleRestrictionRange.yMax);
        }

        if (jointEntity.AngleRestrictionRange.zAxis)
        {
            if (euler.z > 180f)
            {
                euler.z -= 360f;
            }
            euler.z = Mathf.Clamp(euler.z, jointEntity.AngleRestrictionRange.zMin, jointEntity.AngleRestrictionRange.zMax);
        }

        jointEntity.Joint.localEulerAngles = euler;
    }
예제 #2
0
    /// <summary>
    /// Checks the angle restrictions.
    /// </summary>
    /// <param name="jointEntity">Joint entity</param>
    void CheckAngleRestrictions(JointEntity jointEntity)
    {
        Vector3 euler    = normalizeEuler(jointEntity.Joint.localRotation.eulerAngles);
        Vector3 newEuler = Vector3.zero;

        JointActiveAngle jointActiveAngle = jointEntity.activeJointAngle;

        if (jointEntity.enabled)
        {
            if (jointActiveAngle == JointActiveAngle.X)
            {
                newEuler.x = Mathf.Clamp(euler.x, jointEntity.angleMin, jointEntity.angleMax);
            }

            if (jointActiveAngle == JointActiveAngle.Y)
            {
                newEuler.y = Mathf.Clamp(euler.y, jointEntity.angleMin, jointEntity.angleMax);
            }

            if (jointActiveAngle == JointActiveAngle.Z)
            {
                newEuler.z = Mathf.Clamp(euler.z, jointEntity.angleMin, jointEntity.angleMax);
            }
        }

        jointEntity.Joint.localEulerAngles = newEuler;
    }
예제 #3
0
    void ShowInfo()
    {
        for (int i = 0; i < JointEntities.Length - 1; i++)
        {
            JointEntity joint = JointEntities[i];

            int jointAngle = Mathf.RoundToInt(WrapAngle(getActiveAngle(joint)));

            Lebug.Log(joint.Joint.name, jointAngle + ":" + joint.servoAngle, "IKServo");
        }
    }
예제 #4
0
	/// <summary>
	/// Checks the angle restrictions.
	/// </summary>
	/// <param name="jointEntity">Joint entity</param>
	void CheckAngleRestrictions (JointEntity jointEntity)
	{
		Vector3 euler = jointEntity.Joint.localRotation.eulerAngles;
		
		if(jointEntity.AngleRestrictionRange.xAxis) {
			if(euler.x > 180f)
				euler.x -= 360f;
			euler.x = Mathf.Clamp(euler.x, jointEntity.AngleRestrictionRange.xMin, jointEntity.AngleRestrictionRange.xMax);
		}
		
		if(jointEntity.AngleRestrictionRange.yAxis) {
			if(euler.y > 180f)
				euler.y -= 360f;
			euler.y = Mathf.Clamp(euler.y, jointEntity.AngleRestrictionRange.yMin, jointEntity.AngleRestrictionRange.yMax);
		}
		
		if(jointEntity.AngleRestrictionRange.zAxis) {
			if(euler.z > 180f)
				euler.z -= 360f;
			euler.z = Mathf.Clamp(euler.z, jointEntity.AngleRestrictionRange.zMin, jointEntity.AngleRestrictionRange.zMax);
		}
		
		jointEntity.Joint.localEulerAngles = euler;
	}