예제 #1
0
    } //NavigationLine of PlayerCar and TrafficCar in SF

    public void DrawCenterLine(float carTf, PlayerCarLines.Lane lane, CurvySpline curvySpline, Texture2D lineRendererTxt)
    {
        float increaseAmount = 1f / (curvySpline.Length * SPLINE_GIZMO_SMOOTHNESS);

        float endTf = carTf;

        if (lane.Equals(PlayerCarLines.Lane.RIGHT))
        {
            int direction = 1;
            curvySpline.MoveByLengthFast(ref endTf, ref direction, 75.0f, CurvyClamping.Clamp); //this is to determine a constant length of the curve drawn, since Tf isn't proportional to the curve length, so you can't use a constant value!
            for (float i = carTf; i < endTf; i += increaseAmount)
            {
                Vector3 pos = curvySpline.Interpolate(i);
                CenterPoints.Add(pos);
            }
        }
        else
        {
            int direction = -1;
            curvySpline.MoveByLengthFast(ref endTf, ref direction, 75.0f, CurvyClamping.Clamp); //this is to determine a constant length of the curve drawn, since Tf isn't proportional to the curve length, so you can't use a constant value!
            for (float i = carTf; i > endTf; i -= increaseAmount)
            {
                Vector3 pos = curvySpline.Interpolate(i);
                CenterPoints.Add(pos);
            }
        }

        lineRenderer2.positionCount = CenterPoints.Count;
        lineRenderer2.SetPositions(CenterPoints.ToArray());
        lineRenderer2.colorGradient = MakeLineRendererGradient(centerLineColor);
        lineRenderer2.material.SetColor("_Color", CenterLineColor); //set tint color of particle shader
        Texture2D txt = UpdateParams(centerLineColor, lineRendererTxt);

        lineRenderer2.material.SetTexture("_MainTex", txt);
        CenterPoints.Clear();
    } //centerLine of PlayerCar in PCH
예제 #2
0
    public void DrawLine(GameObject car, CurvySpline curvySpline, float carTf)
    {
        float increaseAmount = 1f / (curvySpline.Length * SPLINE_GIZMO_SMOOTHNESS);
        int   direction      = 1;
        float endTf          = carTf;

        curvySpline.MoveByLengthFast(ref endTf, ref direction, 75.0f, CurvyClamping.Clamp); //this is to determine a constant length of the curve drawn, since Tf isn't proportional to the curve length, so you can't use a constant value!

        for (float i = carTf; i < endTf; i += increaseAmount)
        {
            Vector3 pos = curvySpline.Interpolate(i);
            LinePoints.Add(pos);
        }

        lineRenderer.positionCount = LinePoints.Count;
        lineRenderer.SetPositions(LinePoints.ToArray());
        LinePoints.Clear();
    } //NavigationLine of PlayerCar and TrafficCar in PCH