Reset() public method

public Reset ( ) : void
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);
        }
    }
Ejemplo n.º 2
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);
	}
Ejemplo n.º 3
0
 public void stop()
 {
     if (mSplineInterp != null)
     {
         mSplineInterp.Reset();
     }
 }
Ejemplo n.º 4
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);
        }
    }
Ejemplo n.º 6
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);
        }
    }
Ejemplo n.º 7
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);
        }
    }
Ejemplo n.º 8
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);
        }
    }
Ejemplo n.º 10
0
    private SplineInterpolator SetupSpline(IEnumerable <GameObject> gos)
    {
        //converting gameobjects to a list of transforms
        List <Transform> transforms = new List <Transform>();

        foreach (GameObject go in gos)
        {
            transforms.Add(go.transform);
        }

        //setup spline
        SplineInterpolator interp = transform.GetComponent <SplineInterpolator>();

        interp.Reset();
        for (int c = 0; c < transforms.Count; c++)
        {
            interp.AddPoint(transforms[c].position, transforms[c].rotation, c, new Vector2(0, 1));
        }
        interp.StartInterpolation(null, false, eWrapMode.ONCE);
        return(interp);
    }
    public void RestartSpline(float newDuration)
    {
        EnableTransforms();

        mSplineInterp = GetComponent(typeof(SplineInterpolator)) as SplineInterpolator;

        mSplineInterp.Reset();

        Duration = newDuration;

        mTransforms = GetTransforms();

        if (HideOnExecute)
        {
            DisableTransforms();
        }

        if (AutoStart)
        {
            FollowSpline();
        }
    }
Ejemplo n.º 12
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);
    }
Ejemplo n.º 13
0
    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);
	}
Ejemplo n.º 15
0
    void SetupSplineInterpolator(SplineInterpolator interp, List<GameObject> gameObjects)
    {
        interp.Reset(splineObject);

        float step = duration / (gameObjects.Count - 1);

        for (int i = 0; i < gameObjects.Count; i++)
        {
            Transform trans = gameObjects[i].transform;
            Vector3 offset = new Vector3(trans.position.x, trans.position.y + 0.4f, trans.position.z);
            interp.AddPoint(gameObjects[i], offset, trans.rotation, step * i, new Vector2(0, 1));
        }
    }