예제 #1
0
    protected void DrawDottedLine(LineBase line, int numSteps)
    {
        Vector3 firstPos = Vector3.zero;
        Vector3 lastPos  = Vector3.zero;

        switch (EditorStepMode)
        {
        case StepModeEnum.FromSource:
            firstPos = line.GetPoint(0);
            lastPos  = firstPos;

            for (int i = 1; i < line.NumPoints; i++)
            {
                Vector3 currentPos = line.GetPoint(i);
                Handles.DrawDottedLine(lastPos, currentPos, MRTKEditor.DottedLineScreenSpace);
                lastPos = currentPos;
            }

            if (line.Loops)
            {
                Handles.DrawDottedLine(lastPos, firstPos, MRTKEditor.DottedLineScreenSpace);
            }
            break;

        case StepModeEnum.Interpolated:
        default:
            firstPos      = line.GetPoint(0f);
            lastPos       = firstPos;
            Handles.color = DefaultDisplayLineColor;

            for (int i = 1; i < numSteps; i++)
            {
                float   normalizedLength = (1f / (numSteps - 1)) * i;
                Vector3 currentPos       = line.GetPoint(normalizedLength);
                Handles.DrawDottedLine(lastPos, currentPos, MRTKEditor.DottedLineScreenSpace);
                lastPos = currentPos;
            }

            if (line.Loops)
            {
                Handles.DrawDottedLine(lastPos, firstPos, MRTKEditor.DottedLineScreenSpace);
            }
            break;
        }
    }
예제 #2
0
    protected void DrawLinePoints(LineBase line)
    {
        Handles.color = DefaultDisplayLineColor;
        float dotSize = HandleUtility.GetHandleSize(line.transform.position) * 0.025f;

        for (int i = 0; i < line.NumPoints; i++)
        {
            Handles.DotHandleCap(0, line.GetPoint(i), Quaternion.identity, dotSize, EventType.Repaint);
        }
    }
예제 #3
0
    protected void DrawManualUpVectorHandles(LineBase line)
    {
        if (line.ManualUpVectors == null || line.ManualUpVectors.Length < 2)
        {
            line.ManualUpVectors = new Vector3[2];
        }

        for (int i = 0; i < line.ManualUpVectors.Length; i++)
        {
            float   normalizedLength = (1f / (line.ManualUpVectors.Length - 1)) * i;
            Vector3 currentPoint     = line.GetPoint(normalizedLength);
            Vector3 currentUpVector  = line.ManualUpVectors[i];
            line.ManualUpVectors[i] = VectorHandle(currentPoint, currentUpVector, false, lineManualUpVectorLength);
        }
    }
예제 #4
0
    protected void DrawLineRotations(LineBase line, int numSteps)
    {
        Handles.color = lineVelocityColor;
        float arrowSize = HandleUtility.GetHandleSize(line.transform.position) * lineRotationLength;

        for (int i = 1; i < numSteps; i++)
        {
            float      normalizedLength = (1f / (numSteps - 1)) * i;
            Vector3    currentPos       = line.GetPoint(normalizedLength);
            Quaternion rotation         = line.GetRotation(normalizedLength);

            Handles.color = Color.Lerp(lineVelocityColor, Handles.zAxisColor, 0.75f);
            Handles.ArrowHandleCap(0, currentPos, Quaternion.LookRotation(rotation * Vector3.forward), arrowSize, EventType.Repaint);
            Handles.color = Color.Lerp(lineVelocityColor, Handles.xAxisColor, 0.75f);
            Handles.ArrowHandleCap(0, currentPos, Quaternion.LookRotation(rotation * Vector3.right), arrowSize, EventType.Repaint);
            Handles.color = Color.Lerp(lineVelocityColor, Handles.yAxisColor, 0.75f);
            Handles.ArrowHandleCap(0, currentPos, Quaternion.LookRotation(rotation * Vector3.up), arrowSize, EventType.Repaint);
        }
    }