コード例 #1
0
    void Start()
    {
        //create the game object that will hold the spline plus component and catch the SPData to use further
        SPData = SplinePlusAPI.CreateSplinePlus(Vector3.zero);

        //create the 2 nodes
        var node1 = SplinePlusAPI.CreateNode(SPData, new Vector3(10, 0, 0));
        var node2 = SplinePlusAPI.CreateNode(SPData, new Vector3(-10, 0, 0));

        //connect the 2 node
        SplinePlusAPI.ConnectTwoNodes(SPData, node1, node2);

        //change the node points to get the oval shape,
        // just copy the values from the editor example it's easier this way
        node1.Point1.position = new Vector3(10, 0, Power);
        node1.Point2.position = new Vector3(10, 0, -Power);

        node2.Point1.position = new Vector3(-10, 0, Power);
        node2.Point2.position = new Vector3(-10, 0, -Power);

        //set looped to true to close the shape
        SPData.IsLooped = true;

        //trigger a spline plus update
        SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData);
    }
コード例 #2
0
ファイル: APITest.cs プロジェクト: JKDaluga/AlmostRace
    public void Start()
    {
        SPData = SplinePlusAPI.CreateSplinePlus(Vector3.zero);

        var pathPoint1 = SplinePlusAPI.CreateNode(SPData, new Vector3(0, 0, 0));
        var pathPoint2 = SplinePlusAPI.CreateNode(SPData, new Vector3(10, 0, 0));
        var pathPoint3 = SplinePlusAPI.CreateNode(SPData, new Vector3(10, 0, 10));
        var pathPoint4 = SplinePlusAPI.CreateNode(SPData, new Vector3(0, 0, 10));

        SplinePlusAPI.ConnectTwoNodes(SPData, pathPoint1, pathPoint2);
        SplinePlusAPI.ConnectTwoNodes(SPData, pathPoint2, pathPoint3);
        SplinePlusAPI.ConnectTwoNodes(SPData, pathPoint3, pathPoint4);
        SplinePlusAPI.ConnectTwoNodes(SPData, pathPoint4, pathPoint1);

        SplinePlusAPI.SmoothAllSharedNodes(SPData, 0.5f);
        FollowerSettings(SPData);
    }
コード例 #3
0
    public void SmoothSharedPathPoint(SPData SPData)
    {
        var node = SPData.Selections._PathPoint;

        //cach data for restore procedure
        SPData.SmoothData.InitNodePos = node.Point.position;
        var sharedPathPointIndex = SPData.Selections._SharedPathPointIndex;

        SPData.SmoothData.Nodes           = new Node[SPData.SharedNodes[sharedPathPointIndex].ConnectedBranches.Count];
        SPData.SmoothData.BranchesIndices = SPData.SharedNodes[sharedPathPointIndex].ConnectedBranches.ToArray();

        //shared path point breaking
        for (int i = 0; i < SPData.SmoothData.Nodes.Length; i++)
        {
            var branchKey  = SPData.SharedNodes[sharedPathPointIndex].ConnectedBranches[i];
            var localIndex = node.LocalIndex(SPData, branchKey);

            var duplicate = SplinePlusAPI.DuplicatePathPoint(SPData, node);
            SPData.SmoothData.Nodes[i] = duplicate;
            SPData.DictBranches[branchKey].Nodes[localIndex] = duplicate;
            if (localIndex != 0)
            {
                BranchesClass.FlipHandles(SPData, branchKey, localIndex);
            }
        }
        SPData.SmoothData.newBranchesIndices = new List <int>();
        //path points welding
        for (int i = 0; i < SPData.SmoothData.Nodes.Length; i++)// path points created after chamfer,
        {
            for (int n = i; n < SPData.SmoothData.Nodes.Length; n++)
            {
                if (n == i)
                {
                    continue;
                }
                //UpdateAllLinks
                var t = SplinePlusAPI.ConnectTwoNodes(SPData, SPData.SmoothData.Nodes[n], SPData.SmoothData.Nodes[i]);
                SPData.SmoothData.newBranchesIndices.Add(t);
                BranchesClass.FlipHandles(SPData, t, 0);
                BranchesClass.FlipHandles(SPData, t, 1);
            }
        }
        EditSmoothNodePoint(SPData, SPData.SmoothRadius);
    }
コード例 #4
0
ファイル: PathGenerator.cs プロジェクト: JKDaluga/AlmostRace
    public void CreatePath()
    {
        var SplinePlus = SplinePlusAPI.CreateSplinePlus(Vector3.zero);

        Node pathPoint1 = new Node();
        Node pathPoint2 = new Node();

        for (int i = 0; i < Points.Count - 1; i = i + 2)
        {
            if (Points[i] == null || Points[i + 1] == null)
            {
                DestroyImmediate(SplinePlus.DataParent);
                return;
            }

            pathPoint1 = SplinePlusAPI.CreateNode(SplinePlus, Points[i].transform.position);
            pathPoint2 = SplinePlusAPI.CreateNode(SplinePlus, Points[i + 1].transform.position);

            SplinePlusAPI.ConnectTwoNodes(SplinePlus, pathPoint1, pathPoint2);
        }
        SplinePlusAPI.SmoothAllSharedNodes(SplinePlus, Radius);
    }