SetAutoCloseMode() public method

public SetAutoCloseMode ( float joiningPointTime ) : void
joiningPointTime float
return void
    void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
    {
        interp.Reset();

        float step = (AutoClose) ? DURATION / trans.Length :
                     DURATION / (trans.Length - 1);

        int c;

        for (c = 0; c < trans.Length; c++)
        {
            Quaternion rot;
            if (c != trans.Length - 1)
            {
                rot = Quaternion.LookRotation(trans[c + 1].position - trans[c].position, trans[c].up);
            }
            else if (AutoClose)
            {
                rot = Quaternion.LookRotation(trans[0].position - trans[c].position, trans[c].up);
            }
            else
            {
                rot = trans[c].rotation;
            }

            interp.AddPoint(trans[c].position, rot, step * c, new Vector2(0, 1));
        }

        if (AutoClose)
        {
            interp.SetAutoCloseMode(step * c);
        }
    }
Esempio n. 2
0
    void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans, int indexToStart)
    {
        interp.Reset();

        float step = (AutoClose) ? Duration / trans.Length :
                     Duration / (trans.Length - 1);

        for (int c = 0; c < trans.Length; c++)
        {
            int which = c;
            if (Reverse)
            {
                which = indexToStart - c;
                if (which < 0)
                {
                    which += trans.Length;
                }
            }
            else
            {
                which = (c + indexToStart) % trans.Length;
            }
            if (OrientationMode == eOrientationMode.NODE)
            {
                interp.AddPoint(trans[which].position, trans[which].rotation, step * c, new Vector2(0, 1));
            }

            // WILL NOT USE THIS, CAN LEAVE BROKEN
            else if (OrientationMode == eOrientationMode.TANGENT)
            {
                Quaternion rot;
                if (c != trans.Length - 1)
                {
                    rot = Quaternion.LookRotation(trans[c + 1].position - trans[c].position, trans[c].up);
                }
                else if (AutoClose)
                {
                    rot = Quaternion.LookRotation(trans[0].position - trans[c].position, trans[c].up);
                }
                else
                {
                    rot = trans[c].rotation;
                }

                interp.AddPoint(trans[c].position, rot, step * c, new Vector2(0, 1));
            }
        }

        if (AutoClose)
        {
            interp.SetAutoCloseMode(step * trans.Length);
        }
    }
    void SetupSplineInterpolator(SplineInterpolator interp, SplineNode[] ninfo)
    {
        interp.Reset();

        float currTime = 0;

        for (uint c = 0; c < ninfo.Length; c++)
        {
            if (OrientationMode == eOrientationMode.NODE)
            {
                interp.AddPoint(ninfo[c].Name, ninfo[c].Point,
                                ninfo[c].Rot,
                                currTime, ninfo[c].BreakTime,
                                new Vector2(0, 1));
            }
            else if (OrientationMode == eOrientationMode.TANGENT)
            {
                Quaternion rot;
                Vector3    up = ninfo[c].Rot * Vector3.up;

                if (c != ninfo.Length - 1)                                                  // is c the last point?
                {
                    rot = Quaternion.LookRotation(ninfo[c + 1].Point - ninfo[c].Point, up); // no, we can use c+1
                }
                else if (AutoClose)
                {
                    rot = Quaternion.LookRotation(ninfo[0].Point - ninfo[c].Point, up);
                }
                else
                {
                    rot = ninfo[c].Rot;
                }

                interp.AddPoint(ninfo[c].Name, ninfo[c].Point, rot,
                                currTime, ninfo[c].BreakTime,
                                new Vector2(0, 1));
            }

            // when ninfo[i].StopHereForSecs == 0, then each node of the spline is reached at
            // Time.time == timePerNode * c (so that last node is reached when Time.time == TimeBetweenAdjacentNodes).
            // However, when ninfo[i].StopHereForSecs > 0, then the arrival time of node (i+1)-th needs
            // to account for the stop time of node i-th
            TimeBetweenAdjacentNodes = 1.0f / (ninfo.Length - 1);
            currTime += TimeBetweenAdjacentNodes + ninfo[c].BreakTime;
        }

        if (AutoClose)
        {
            interp.SetAutoCloseMode(currTime);
        }
    }
Esempio n. 4
0
    void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
    {
        interp.Reset();

        int c;

        for (c = 0; c < trans.Length; c++)
        {
            interp.AddPoint(trans[c].position, trans[c].rotation, c, new Vector2(0, 1));
        }

        if (AutoClose)
        {
            interp.SetAutoCloseMode(c);
        }
    }
Esempio n. 5
0
    void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
    {
        interp.Reset();

        float step = (AutoClose) ? Duration / trans.Length :
                     Duration / (trans.Length - 1);

        int c;

        for (c = 0; c < trans.Length; c++)
        {
            if (OrientationMode == eOrientationMode.NODE)
            {
                interp.AddPoint(trans[c].position, trans[c].rotation, step * c, new Vector2(0, 1));
            }
            else if (OrientationMode == eOrientationMode.TANGENT)
            {
                Quaternion rot;
                if (c != trans.Length - 1)
                {
                    if (trans[c + 1].position - trans[c].position != Vector3.zero)
                    {
                        rot = Quaternion.LookRotation(trans[c + 1].position - trans[c].position, trans[c].up);
                    }
                    else
                    {
                        rot = Quaternion.identity;
                    }
                }
                else if (AutoClose)
                {
                    rot = Quaternion.LookRotation(trans[0].position - trans[c].position, trans[c].up);
                }
                else
                {
                    rot = trans[c].rotation;
                }

                interp.AddPoint(trans[c].position, rot, step * c, new Vector2(0, 1));
            }
        }

        if (AutoClose)
        {
            interp.SetAutoCloseMode(step * c);
        }
    }
Esempio n. 6
0
        //Drawn Spline for WayPoints
        void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
        {
            interp.Reset();

            float step = (ClosedRacingLine) ? (Duration / trans.Length) : Duration / (trans.Length - 1);

            int c;

            for (c = 0; c < trans.Length; c++)
            {
                interp.AddPoint(trans[c].position, trans[c].rotation, step * c, new Vector2(0, 1));
            }

            if (ClosedRacingLine)
            {
                interp.SetAutoCloseMode(step * c);
            }
        }
    void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
    {
        //Debug.Log(Time.realtimeSinceStartup + " " + this + " SetupSplineInterpolator " + interp + " " + trans);
        interp.Reset();

        float step = (AutoClose) ? Duration / trans.Length :
                     Duration / (trans.Length - 1);

        //Debug.Log(Time.realtimeSinceStartup + " " + this + " step = " + step);
        int c;

        for (c = 0; c < trans.Length; c++)
        {
            if (OrientationMode == eOrientationMode.NODE)
            {
                interp.AddPoint(trans[c].position, trans[c].rotation, step * c, new Vector2(0, 1));
            }
            else if (OrientationMode == eOrientationMode.TANGENT)
            {
                Quaternion rot;
                if (c != trans.Length - 1)
                {
                    rot = Quaternion.LookRotation(trans[c + 1].position - trans[c].position, trans[c].up);
                }
                else if (AutoClose)
                {
                    rot = Quaternion.LookRotation(trans[0].position - trans[c].position, trans[c].up);
                }
                else
                {
                    rot = trans[c].rotation;
                }

                interp.AddPoint(trans[c].position, rot, step * c, new Vector2(0, 1));
            }
        }

        if (AutoClose)
        {
            interp.SetAutoCloseMode(step * c);
        }
    }
Esempio n. 8
0
	void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
	{
		interp.Reset();

		float step = (AutoClose) ? Duration / trans.Length :
			Duration / (trans.Length - 1);

		int c;
		for (c = 0; c < trans.Length; c++)
		{
			if (OrientationMode == eOrientationModeVineeth.NODE)
			{
				interp.AddPoint(trans[c].position, trans[c].rotation, step * c, new Vector2(0, 1));
			}
			else if (OrientationMode == eOrientationModeVineeth.TANGENT)
			{
				Quaternion rot;
				if (c != trans.Length - 1)
					rot = Quaternion.LookRotation(trans[c + 1].position - trans[c].position, trans[c].up);
				else if (AutoClose)
					rot = Quaternion.LookRotation(trans[0].position - trans[c].position, trans[c].up);
				else
					rot = trans[c].rotation;

				interp.AddPoint(trans[c].position, rot, step * c, new Vector2(0, 1));
			}
		}

		if (AutoClose)
			interp.SetAutoCloseMode(step * c);
	}
Esempio n. 9
0
    protected virtual void SetupSplineInterpolator(SplineInterpolator interp, SplineNode[] ninfo)
    {
        interp.Clear();

        float currTime = 0;

        List<SplineNode> nInfoAsList = new List<SplineNode>(ninfo);

        for (uint c = 0; c < ninfo.Length; c++)
        {
            if (OrientationMode == eOrientationMode.NODE)
            {
                interp.AddPoint(ninfo[c].Name, ninfo[c].Point,
                                ninfo[c].Rot,
                                currTime, ninfo[c].BreakTime,
                                new Vector2(0, 1));
            }
            else if (OrientationMode == eOrientationMode.TANGENT)
            {
                Quaternion rot;
                Vector3 up = ninfo[c].Rot * Vector3.up;

                if (c != ninfo.Length - 1)		// is c the last point?
                    rot = Quaternion.LookRotation(ninfo[c+1].Point - ninfo[c].Point, up);	// no, we can use c+1
                else if (AutoClose)
                    rot = Quaternion.LookRotation(ninfo[0].Point - ninfo[c].Point, up);
                else
                    rot = ninfo[c].Rot;

                interp.AddPoint(ninfo[c].Name, ninfo[c].Point, rot,
                                currTime, ninfo[c].BreakTime,
                                new Vector2(0, 1));
            }

            // when ninfo[i].StopHereForSecs == 0, then each node of the spline is reached at
            // Time.time == timePerNode * c (so that last node is reached when Time.time == TimeBetweenAdjacentNodes).
            // However, when ninfo[i].StopHereForSecs > 0, then the arrival time of node (i+1)-th needs
            // to account for the stop time of node i-th
            currTime += ninfo[c].BreakTime;

            if ((Speed <= 0 || Application.isEditor) && !Application.isPlaying) {
                currTime += TimeBetweenAdjacentNodes;
            }
        }

        //Debug.Log("SplineController, there are " + eOrientationMode.NODE + " nodes currently");

        //Normalizes the speed by adjusting which times our spline interpolator
        //needs to arrive at a particular node before they are added to the actual
        //interpolator.
        if (Speed > 0 && Application.isPlaying) {
            ConstructCurve(interp, ninfo);
        }

        if (AutoClose)
            interp.SetAutoCloseMode(currTime);
    }
Esempio n. 10
0
    void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
    {
        //Debug.Log(Time.realtimeSinceStartup + " " + this + " SetupSplineInterpolator " + interp + " " + trans);
        interp.Reset();

        float step = (AutoClose) ? Duration / trans.Length :
            Duration / (trans.Length - 1);

        //Debug.Log(Time.realtimeSinceStartup + " " + this + " step = " + step);
        int c;
        for (c = 0; c < trans.Length; c++)
        {
            if (OrientationMode == eOrientationMode.NODE)
            {
                interp.AddPoint(trans[c].position, trans[c].rotation, step * c, new Vector2(0, 1));
            }
            else if (OrientationMode == eOrientationMode.TANGENT)
            {
                Quaternion rot;
                if (c != trans.Length - 1)
                    rot = Quaternion.LookRotation(trans[c + 1].position - trans[c].position, trans[c].up);
                else if (AutoClose)
                    rot = Quaternion.LookRotation(trans[0].position - trans[c].position, trans[c].up);
                else
                    rot = trans[c].rotation;

                interp.AddPoint(trans[c].position, rot, step * c, new Vector2(0, 1));
            }
        }

        if (AutoClose)
            interp.SetAutoCloseMode(step * c);
    }
    void SetupSplineInterpolator(SplineInterpolator interp, Transform[] trans)
    {
        interp.Reset();
        float Step;

        int   Counter;
        float TotalLength = 0;

        float[] DistanceList = new float[trans.Length];

        if (AutoClose)
        {
            for (int i = 0; i < trans.Length; i++)
            {
                float Distance;

                if (i == trans.Length - 1)
                {
                    Distance     = Vector3.Distance(trans[i].position, trans[0].position);
                    TotalLength += Distance;
                }
                else
                {
                    Distance     = Vector3.Distance(trans[i].position, trans[i + 1].position);
                    TotalLength += Distance;
                }
                DistanceList[i] = Distance;
            }
        }
        else
        {
            for (int i = 0; i < trans.Length - 1; i++)
            {
                float Distance;
                Distance        = Vector3.Distance(trans[i].position, trans[i + 1].position);
                TotalLength    += Distance;
                DistanceList[i] = Distance;
            }
        }

        float CurrentDis = 0;

        for (Counter = 0; Counter < trans.Length; Counter++)
        {
            Quaternion rot;
            if (Counter != trans.Length - 1)
            {
                rot = Quaternion.LookRotation(trans[Counter + 1].position - trans[Counter].position, trans[Counter].up);
            }
            else if (AutoClose)
            {
                rot = Quaternion.LookRotation(trans[0].position - trans[Counter].position, trans[Counter].up);
            }
            else
            {
                rot = trans[Counter].rotation;
            }

            Step = CurrentDis / TotalLength / STEP_DIVIDER;

            interp.AddPoint(trans[Counter].position, rot, Step, new Vector2(0, 1));
            CurrentDis = CurrentDis + DistanceList[Counter];
        }



        if (AutoClose)
        {
            interp.SetAutoCloseMode(CurrentDis / TotalLength / STEP_DIVIDER);
        }
    }
	void SetupSplineInterpolator(SplineInterpolator interp, SplineNode[] ninfo)
	{
		interp.Reset();
		
		float currTime = 0;
		for (uint c = 0; c < ninfo.Length; c++)
		{
			if (OrientationMode == eOrientationMode.NODE)
			{
				interp.AddPoint(ninfo[c].Name, ninfo[c].Point, 
								ninfo[c].Rot, 
								currTime, ninfo[c].BreakTime, 
								new Vector2(0, 1));
			}
			else if (OrientationMode == eOrientationMode.TANGENT)
			{
				Quaternion rot;
				Vector3 up = ninfo[c].Rot * Vector3.up;
				
				if (c != ninfo.Length - 1)		// is c the last point?
					rot = Quaternion.LookRotation(ninfo[c+1].Point - ninfo[c].Point, up);	// no, we can use c+1
				else if (AutoClose)
					rot = Quaternion.LookRotation(ninfo[0].Point - ninfo[c].Point, up);
				else
					rot = ninfo[c].Rot;

				interp.AddPoint(ninfo[c].Name, ninfo[c].Point, rot, 
								currTime, ninfo[c].BreakTime, 
								new Vector2(0, 1));
			}
			
			// when ninfo[i].StopHereForSecs == 0, then each node of the spline is reached at
			// Time.time == timePerNode * c (so that last node is reached when Time.time == TimeBetweenAdjacentNodes).
			// However, when ninfo[i].StopHereForSecs > 0, then the arrival time of node (i+1)-th needs
			// to account for the stop time of node i-th
		    TimeBetweenAdjacentNodes = 1.0f / (ninfo.Length - 1);
			currTime += TimeBetweenAdjacentNodes + ninfo[c].BreakTime;
		}

		if (AutoClose)
			interp.SetAutoCloseMode(currTime);
	}