예제 #1
0
    //Updated
    private void DrawNodeNet(ref bool elementClicked)
    {
        //Nodes
        for (int i = 0; i < creator.NNodes; i++)
        {
            DrawNode(creator.GetNode(i), ref elementClicked);
            DrawNodeID(i);
        }
        //Stretches
        for (int i = 0; i < creator.NStretches; i++)
        {
            Stretch   st     = creator.GetStretch(i);
            Vector3[] points = st.GetPoints();

            DrawHandler(st, ref elementClicked);

            DrawStretch(points);
            if (creator.displayNet)
            {
                DrawBezier(points, netDisplaySettings, st.IsIntersection());
            }
            DrawDeleteButton(st);
            if (netDisplaySettings.showArrows)
            {
                DrawArrow(st);
            }
            if (netDisplaySettings.showVertices)
            {
                DrawVertices(st);
            }
        }
    }
예제 #2
0
    public Stretch GetClosestStretch(Vector3 worldPos)
    {
        Debug.Log(Time.timeSinceLevelLoad);
        Stretch closestStretch = null;
        float   minDistance    = float.MaxValue;

        float   dst = 0f;
        Stretch st  = null;

        for (int i = 0; i < stretches.Count; i++)
        {
            st = GetStretch(i);

            dst = CubicBezierUtility.EstimateDistanceToCurve(st.GetPoints(), worldPos);

            if (dst < minDistance)
            {
                minDistance    = dst;
                closestStretch = st;
            }
        }

        return(closestStretch);
    }
예제 #3
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        labelStyle.normal.textColor = netDisplaySettings.guiStyle.normal.textColor;

        GUILayout.Space(20);

        if (GUILayout.Button("Stick Nodes to Ground"))
        {
            StickNodesToGround();
        }

        if (GUILayout.Button("Recalculate Vertices"))
        {
            for (int i = 0; i < creator.NStretches; i++)
            {
                Stretch st = creator.GetStretch(i);
                st.OnPathModified();
            }
        }

        if (GUILayout.Button("Reassign Nodes"))
        {
            for (int i = 0; i < creator.NNodes; i++)
            {
                Node n = creator.GetNode(i);
                n.id             = i;
                n.transform.name = "NODE_" + i;
            }
        }

        if (GUILayout.Button("Print curvature percentages"))
        {
            for (int i = 0; i < creator.NStretches; i++)
            {
                Stretch st = creator.GetStretch(i);
                Debug.Log("Stretch: " + st.Name + ": " + PathCreation.Utility.CubicBezierUtility.AproximateAmountOfCurvature(st.GetPoints()));
            }
        }

        GUILayout.Space(20);

        if (GUILayout.Button("Load from xml file"))
        {
            creator.LoadFromXml();
        }
        if (GUILayout.Button("Save to xml file"))
        {
            creator.SaveToXml();
        }

        GUILayout.Space(20);

        if (selectedNode != null)
        {
        }

        DrawNetDisplaySettingsInspector();
    }