PointOnLineParameter() 공개 정적인 메소드

Returns the parameter for the projection of the point on the given line.

public static PointOnLineParameter ( Vector3 point, Vector3 linePoint, Vector3 lineDirection ) : float
point Vector3
linePoint Vector3
lineDirection Vector3
리턴 float
        private static float SizeHandle(Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix, bool isEdgeHandle)
        {
            Vector3 vector3_1  = matrix.MultiplyVector(localPullDir);
            Vector3 vector3_2  = matrix.MultiplyPoint(localPos);
            float   handleSize = HandleUtility.GetHandleSize(vector3_2);
            bool    changed    = GUI.changed;

            GUI.changed = false;
            Color color = Handles.color;
            float num1  = 0.0f;

            if (isEdgeHandle)
            {
                num1 = Mathf.Cos(0.7853982f);
            }
            if ((!Camera.current.orthographic ? (double)Vector3.Dot((Camera.current.transform.position - vector3_2).normalized, vector3_1) : (double)Vector3.Dot(-Camera.current.transform.forward, vector3_1)) < -(double)num1)
            {
                Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * Handles.backfaceAlphaMultiplier);
            }
            Vector3 point = Handles.Slider(vector3_2, vector3_1, handleSize * 0.03f, new Handles.DrawCapFunction(Handles.DotCap), 0.0f);
            float   num2  = 0.0f;

            if (GUI.changed)
            {
                num2 = HandleUtility.PointOnLineParameter(point, vector3_2, vector3_1);
            }
            GUI.changed  |= changed;
            Handles.color = color;
            return(num2);
        }
예제 #2
0
        private static float SizeHandle(Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix, bool isEdgeHandle)
        {
            Vector3 worldDir = matrix.MultiplyVector(localPullDir);
            Vector3 worldPos = matrix.MultiplyPoint(localPos);

            float handleSize    = HandleUtility.GetHandleSize(worldPos);
            bool  orgGUIchanged = GUI.changed;

            GUI.changed = false;
            Color tempColor = Handles.color;

            // Adjust color of handle if in background
            float displayThreshold = 0.0f;

            if (isEdgeHandle)
            {
                displayThreshold = Mathf.Cos(Mathf.PI * 0.25f);
            }
            float cosV;

            if (Camera.current.orthographic)
            {
                cosV = Vector3.Dot(-Camera.current.transform.forward, worldDir);
            }
            else
            {
                cosV = Vector3.Dot((Camera.current.transform.position - worldPos).normalized, worldDir);
            }
            if (cosV < -displayThreshold)
            {
                Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * Handles.backfaceAlphaMultiplier);
            }

            // Now do handle
            Vector3 newWorldPos = Handles.Slider(worldPos, worldDir, handleSize * 0.03f, Handles.DotHandleCap, 0f);
            float   adjust      = 0.0f;

            if (GUI.changed)
            {
                // Project newWorldPos to worldDir  (the sign of the return value indicates if we growing or shrinking)
                adjust = HandleUtility.PointOnLineParameter(newWorldPos, worldPos, worldDir);
            }

            // Reset states
            GUI.changed  |= orgGUIchanged;
            Handles.color = tempColor;

            return(adjust);
        }
예제 #3
0
        private static float SizeHandle(Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix, bool isEdgeHandle)
        {
            Vector3 vector     = matrix.MultiplyVector(localPullDir);
            Vector3 vector2    = matrix.MultiplyPoint(localPos);
            float   handleSize = HandleUtility.GetHandleSize(vector2);
            bool    changed    = GUI.changed;

            GUI.changed = false;
            Color color = Handles.color;
            float num   = 0f;

            if (isEdgeHandle)
            {
                num = Mathf.Cos(0.7853982f);
            }
            float num2;

            if (Camera.current.orthographic)
            {
                num2 = Vector3.Dot(-Camera.current.transform.forward, vector);
            }
            else
            {
                num2 = Vector3.Dot((Camera.current.transform.position - vector2).normalized, vector);
            }
            if (num2 < -num)
            {
                Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * Handles.backfaceAlphaMultiplier);
            }
            Vector3 arg_119_0 = vector2;
            Vector3 arg_119_1 = vector;
            float   arg_119_2 = handleSize * 0.03f;

            if (CharacterControllerEditor.< > f__mg$cache0 == null)
            {
                CharacterControllerEditor.< > f__mg$cache0 = new Handles.CapFunction(Handles.DotHandleCap);
            }
            Vector3 point  = Handles.Slider(arg_119_0, arg_119_1, arg_119_2, CharacterControllerEditor.< > f__mg$cache0, 0f);
            float   result = 0f;

            if (GUI.changed)
            {
                result = HandleUtility.PointOnLineParameter(point, vector2, vector);
            }
            GUI.changed  |= changed;
            Handles.color = color;
            return(result);
        }
예제 #4
0
        private static float SizeHandle(Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix, bool isEdgeHandle)
        {
            float   num3;
            Vector3 rhs        = matrix.MultiplyVector(localPullDir);
            Vector3 position   = matrix.MultiplyPoint(localPos);
            float   handleSize = HandleUtility.GetHandleSize(position);
            bool    changed    = GUI.changed;

            GUI.changed = false;
            Color color = Handles.color;
            float num2  = 0f;

            if (isEdgeHandle)
            {
                num2 = Mathf.Cos(0.7853982f);
            }
            if (Camera.current.orthographic)
            {
                num3 = Vector3.Dot(-Camera.current.transform.forward, rhs);
            }
            else
            {
                Vector3 vector4 = Camera.current.transform.position - position;
                num3 = Vector3.Dot(vector4.normalized, rhs);
            }
            if (num3 < -num2)
            {
                Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * Handles.backfaceAlphaMultiplier);
            }
            Vector3 point = Handles.Slider(position, rhs, handleSize * 0.03f, new Handles.DrawCapFunction(Handles.DotCap), 0f);
            float   num4  = 0f;

            if (GUI.changed)
            {
                num4 = HandleUtility.PointOnLineParameter(point, position, rhs);
            }
            GUI.changed  |= changed;
            Handles.color = color;
            return(num4);
        }