MirrorPointAcrossPlane() public static méthode

Mirror point p across the plane defined by the normal n
public static MirrorPointAcrossPlane ( Vector3 p, Vector3 n ) : Vector3
p Vector3 /// A ///
n Vector3 /// A ///
Résultat Vector3
Exemple #1
0
    /*
     * Match this part to another, optionally forcing cardinal axis alignment
     * */
    public void MatchTo(BodyPart other, bool isCardinalAlignment)
    {
        // match the parts to each other
        oppositePart       = other;
        other.oppositePart = this;

        // error if the bones are on top of each other
        if ((bone.position - other.bone.position).sqrMagnitude == 0f)
        {
            Debug.LogWarning(string.Format("Could not compute corresponding axes for BodyParts {0} and {1} because they are coincident.", name, other.name));
        }

        // compute match axes for each part
        Vector3 reflectionDirection = (bone.position - other.bone.position).normalized;

        other.oppositeForward = other.bone.InverseTransformDirection(VectorHelpers.MirrorPointAcrossPlane(bone.forward, reflectionDirection)).normalized;
        other.oppositeRight   = other.bone.InverseTransformDirection(VectorHelpers.MirrorPointAcrossPlane(bone.right, reflectionDirection)).normalized;
        other.oppositeUp      = other.bone.InverseTransformDirection(VectorHelpers.MirrorPointAcrossPlane(bone.up, reflectionDirection)).normalized;
        oppositeForward       = bone.InverseTransformDirection(VectorHelpers.MirrorPointAcrossPlane(other.bone.forward, reflectionDirection)).normalized;
        oppositeRight         = bone.InverseTransformDirection(VectorHelpers.MirrorPointAcrossPlane(other.bone.right, reflectionDirection)).normalized;
        oppositeUp            = bone.InverseTransformDirection(VectorHelpers.MirrorPointAcrossPlane(other.bone.up, reflectionDirection)).normalized;

        // if isCardinalAlignment, then map the nearest cardinal axis as opposed to the raw axis
        if (isCardinalAlignment)
        {
            other.oppositeForward = VectorHelpers.FindNearestCardinalAxis(other.oppositeForward);
            other.oppositeRight   = VectorHelpers.FindNearestCardinalAxis(other.oppositeRight);
            other.oppositeUp      = VectorHelpers.FindNearestCardinalAxis(other.oppositeUp);
            oppositeForward       = VectorHelpers.FindNearestCardinalAxis(oppositeForward);
            oppositeRight         = VectorHelpers.FindNearestCardinalAxis(oppositeRight);
            oppositeUp            = VectorHelpers.FindNearestCardinalAxis(oppositeUp);
        }
    }