IEnumerator DefaultLineIE()
    {
//		Debug.Log ("before Fixed");
        yield return(new WaitForEndOfFrame());

//		Debug.Log ("after Fixed");
        lr.Reset();
        lr.JitterMultiplier = 0f;

        foreach (LaserLine line in laserLines)
        {
            if (line.leftEnd && line.rightEnd)
            {
                // create a new line in renderer
                //				Debug.Log ("drawing line");
                FastLineRendererProperties props = new FastLineRendererProperties();
                props.Start = line.leftEnd.position;
                props.End   = line.rightEnd.position;

                props.Radius = lineRadius * radiusFactor;
                props.GlowIntensityMultiplier = glowIntensity;
                props.GlowWidthMultiplier     = glowWidthMultiplier;

                lr.AddLine(props, true, true);
            }
        }
        lr.Apply();
    }
        private void DoShowEffects()
        {
            FastLineRendererProperties props = new FastLineRendererProperties();
            FastLineRenderer           r     = FastLineRenderer.CreateWithParent(null, LineRenderer);

            r.Material.EnableKeyword("DISABLE_CAPS");
            r.SetCapacity(8192 * FastLineRenderer.VerticesPerLine);
            r.Turbulence  = 350.0f;
            r.BoundsScale = new Vector3(4.0f, 4.0f, 4.0f);
            //r.JitterMultiplier = UnityEngine.Random.Range(0.25f, 1.5f);

            const float maxLifeTimeSeconds = 1.5f;

            for (int i = 0; i < 32; i++)
            {
                Vector3 pos  = new Vector3(10.0f, Screen.height * 0.5f);
                Vector3 pos2 = new Vector3(10.0f + (UnityEngine.Random.Range(50.0f, 150.0f)), Screen.height * 0.5f + (UnityEngine.Random.Range(-15.0f, 15.0f)));
                props.Start  = pos;
                props.End    = pos2;
                props.Radius = UnityEngine.Random.Range(8.0f, 16.0f);
                float s = UnityEngine.Random.Range(1.0f, maxLifeTimeSeconds);
                props.SetLifeTime(s, s * UnityEngine.Random.Range(0.1f, 0.2f));
                props.Color           = new Color32(RandomByte(), RandomByte(), RandomByte(), RandomByte());
                props.Velocity        = RandomVelocity(20.0f);
                props.Velocity.z      = 0.0f;
                props.AngularVelocity = UnityEngine.Random.Range(-0.1f, 0.1f);
                r.AddLine(props);
            }
            r.Apply();

            // send the script back into the cache, freeing up resources after max lifetime seconds.
            r.SendToCacheAfter(TimeSpan.FromSeconds(maxLifeTimeSeconds));
        }
Exemple #3
0
 public void Init(FastLineRenderer parent, float radius)
 {
     Assert.IsNotNull(parent);
     lineRenderer = FastLineRenderer.CreateWithParent(null, parent);
     lineRenderer.Material.EnableKeyword("DISABLE_CAPS");
     lineRenderer.SetCapacity(FastLineRenderer.MaxLinesPerMesh * FastLineRenderer.VerticesPerLine);
     props        = new FastLineRendererProperties();
     props.Radius = radius;
 }
Exemple #4
0
 void DrawTriangleOutline(Triangle t)
 {
     Vector2[][] edges = t.GetEdgesInWorldSpace();
     foreach (Vector2[] edge in edges)
     {
         FastLineRendererProperties props = new FastLineRendererProperties();
         props.Start  = edge[0] + (Vector2)transform.position;
         props.End    = edge[1] + (Vector2)transform.position;
         props.Radius = 0.02f;
         lineRenderer.AddLine(props);
     }
     lineRenderer.Apply();
 }
    void ElevationViz(GameObject go)
    {
        FastLineRendererProperties elevationRendererProps = new FastLineRendererProperties
        {
            Start  = go.transform.position,
            End    = new Vector3(go.transform.position.x, 0, go.transform.position.z),
            Radius = 0.0075f,
            Color  = new Color(0.165f, 0.173f, 0.2f)
        };

        elevationRenderer.AddLine(elevationRendererProps);
        elevationRenderer.Apply();
    }
Exemple #6
0
 void Start()
 {
     FLR               = FLR_Object.GetComponent <FastLineRenderer>();
     crnt_pos          = prev_pos = GetComponent <Transform>().position;
     FLR.UseWorldSpace = true;
     FLRP              = new FastLineRendererProperties();
     FLRP.Start        = FLRP.End = crnt_pos;
     FLRP.Radius       = 0.5f;
     FLRP.Color        = new Color32(255, 0, 0, 255);
     FLRP.LineJoin     = FastLineRendererLineJoin.AttachToPrevious;
     FLRP.SetLifeTime(1f, 999f, 0f);
     EC_points = new List <List <Vector2> >();
 }
        private void UpdateDynamicLines()
        {
            if (!Input.GetKeyDown(KeyCode.Space) || LineRenderer == null)
            {
                return;
            }
            else if (ShowEffects)
            {
                DoShowEffects();
                return;
            }

            const float maxLifeTimeSeconds   = 5.0f;
            FastLineRendererProperties props = new FastLineRendererProperties();
            FastLineRenderer           r     = FastLineRenderer.CreateWithParent(null, LineRenderer);

            r.Material.EnableKeyword("DISABLE_CAPS");
            r.SetCapacity(8192 * FastLineRenderer.VerticesPerLine);
            r.Turbulence  = 150.0f;
            r.BoundsScale = new Vector3(4.0f, 4.0f, 4.0f);
            props.GlowIntensityMultiplier = 0.1f;
            props.GlowWidthMultiplier     = 4.0f;

            for (int i = 0; i < 8192; i++)
            {
                Vector3 pos;
                if (Camera.main.orthographic)
                {
                    pos    = UnityEngine.Random.insideUnitCircle;
                    pos.x *= Screen.width * UnityEngine.Random.Range(0.1f, 0.4f);
                    pos.y *= Screen.height * UnityEngine.Random.Range(0.1f, 0.4f);
                }
                else
                {
                    pos    = UnityEngine.Random.insideUnitSphere;
                    pos.x *= Screen.width * UnityEngine.Random.Range(0.5f, 2.0f);
                    pos.y *= Screen.height * UnityEngine.Random.Range(0.5f, 2.0f);
                    pos.z *= UnityEngine.Random.Range(-200.0f, 200.0f);
                }
                props.End    = pos;
                props.Radius = UnityEngine.Random.Range(1.0f, 4.0f);
                float s = UnityEngine.Random.Range(1.0f, maxLifeTimeSeconds);
                props.SetLifeTime(s, s * 0.15f);
                props.Color           = new Color32(RandomByte(), RandomByte(), RandomByte(), RandomByte());
                props.Velocity        = RandomVelocity(100.0f);
                props.AngularVelocity = UnityEngine.Random.Range(-6.0f, 6.0f);
                r.AddLine(props);
            }
            r.Apply();
            r.SendToCacheAfter(TimeSpan.FromSeconds(maxLifeTimeSeconds));
        }
Exemple #8
0
        public void GenerateLotsOfLines()
        {
            for (int i = 0; i < 10; i++)
            {
                if (UseUnityLineRendererToggle != null && UseUnityLineRendererToggle.isOn && UnityLineRenderer != null)
                {
                    for (int j = 0; j < FastLineRenderer.MaxLinesPerMesh; j++)
                    {
                        Vector3 pos = new Vector3(UnityEngine.Random.Range(0.0f, Screen.width), UnityEngine.Random.Range(0.0f, Screen.height), UnityEngine.Random.Range(-400.0f, 400.0f));
                        UnityLineRendererPositions.Add(pos);
                    }
                    UnityLineRenderer.positionCount = UnityLineRendererPositions.Count;
                    UnityLineRenderer.SetPositions(UnityLineRendererPositions.ToArray());
                }
                else if (lotsOfLinesRenderer != null)
                {
                    // fast clone, just re-use the mesh!
                    const float      range = 1000.0f;
                    FastLineRenderer r     = FastLineRenderer.CreateWithParent(null, LineRenderer);
                    r.Material.EnableKeyword("DISABLE_CAPS");
                    r.Mesh = lotsOfLinesRenderer.Mesh;
                    r.transform.Translate(UnityEngine.Random.Range(-range, range), UnityEngine.Random.Range(-range, range), UnityEngine.Random.Range(-range, range));
                }
                else
                {
                    FastLineRenderer r = FastLineRenderer.CreateWithParent(null, LineRenderer);
                    r.Material.EnableKeyword("DISABLE_CAPS");
                    r.SetCapacity(FastLineRenderer.MaxLinesPerMesh * FastLineRenderer.VerticesPerLine);
                    FastLineRendererProperties props = new FastLineRendererProperties();
                    for (int j = 0; j < FastLineRenderer.MaxLinesPerMesh; j++)
                    {
                        Color32 randColor = new Color32(RandomByte(), RandomByte(), RandomByte(), RandomByte());
                        // Vector3 pos = new Vector3(UnityEngine.Random.Range(0.0f, Screen.width), UnityEngine.Random.Range(0.0f, Screen.height), UnityEngine.Random.Range(-400.0f, 400.0f));
                        Vector3 pos = new Vector3(UnityEngine.Random.Range(0.0f, Screen.width), UnityEngine.Random.Range(0.0f, Screen.height), 0);
                        props.Start  = pos;
                        props.End    = Vector3.zero;
                        props.Color  = randColor;
                        props.Radius = UnityEngine.Random.Range(1.0f, 4.0f);
                        props.SetLifeTime(float.MaxValue);
                        // props.AngularVelocity = UnityEngine.Random.Range(-6.0f, 6.0f);
                        // props.Velocity = RandomVelocity(50.0f);
                        r.AppendLine(props);
                    }
                    r.Apply();
                    lotsOfLinesRenderer = r;
                }

                LineCountLabel.text = "Lines: " + (lineCount += FastLineRenderer.MaxLinesPerMesh);
            }
        }
Exemple #9
0
    private void drawStreamLines()
    {
        List <Vector3> points = generateOneStreamLine(new Vector3(200 * DataBase.SpaceFactor, 100 * DataBase.SpaceFactor, 30 * DataBase.SpaceFactor));

        /*
         * VectorLine line = new VectorLine("Grid", points, 3f, LineType.Continuous);
         * //line.SetColors(GenerateColorsFromPositions(positions_TEST));
         * line.Draw3DAuto();
         */

        FastLineRenderer           LineRenderer = FastLineRenderer.CreateWithParent(gameObject, FastLineRendererTemplate);
        FastLineRendererProperties props        = new FastLineRendererProperties();

        props.Radius   = 0.01f;
        props.LineJoin = FastLineRendererLineJoin.AdjustPosition;
        LineRenderer.AddLine(props, points, null, false, false);
        LineRenderer.Apply();
    }
        private void AddCurvesAndSpline()
        {
            if (ShowCurves)
            {
                const float animationTime = 0.025f;

                ShowCurves = false;
                FastLineRendererProperties props = new FastLineRendererProperties();
                props.GlowIntensityMultiplier = 0.5f;
                props.Radius = 4.0f;
                props.Color  = UnityEngine.Color.white;
                // props.Start = new Vector3(Screen.width * 0.1f, Screen.height * 0.1f, 0.0f);
                // props.End = new Vector3(Screen.width * 1.1f, Screen.height * 1.0f, 0.0f);
                // LineRenderer.AppendCurve(props,
                //     new Vector3(Screen.width * 0.33f, Screen.height * 0.67f, 0.0f), // control point 1
                //     new Vector3(Screen.width * 0.67f, Screen.height * 0.33f, 0.0f), // control point 2
                //     16, true, true, animationTime);

                // props.Color = UnityEngine.Color.red;
                // props.Start = new Vector3(0.0f, Screen.height * 0.2f, 0.0f);
                // props.End = new Vector3(Screen.width * 1.2f, Screen.height * 0.2f, 0.0f);

                // Vector3[] spline = new Vector3[]
                // {
                //     props.Start,
                //     new Vector3(Screen.width * 0.2f, Screen.height * 0.8f, 0.0f),
                //     new Vector3(Screen.width * 0.4f, Screen.height * 0.2f, 0.0f),
                //     new Vector3(Screen.width * 0.6f, Screen.height * 0.8f, 0.0f),
                //     new Vector3(Screen.width * 0.8f, Screen.height * 0.2f, 0.0f),
                //     new Vector3(Screen.width, Screen.height * 0.8f, 0.0f),
                //     props.End
                // };
                LineRenderer.AppendLine(props);
                // LineRenderer.AppendSpline(props, spline, 128, FastLineRendererSplineFlags.StartCap | FastLineRendererSplineFlags.EndCap, animationTime);

                // add a circle and arc
                // props.Color = Color.green;
                // LineRenderer.AppendCircle(props, new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0.0f), 100.0f, 64, Vector3.forward, animationTime);
                // LineRenderer.AppendArc(props, new Vector3(Screen.width * 0.25f, Screen.height * 0.5f, 0.0f), 100.0f, 270.0f, 90.0f, 32, Vector3.forward, false, animationTime);
                // LineRenderer.AppendArc(props, new Vector3(Screen.width * 0.75f, Screen.height * 0.5f, 0.0f), 100.0f, 0.0f, 360.0f, 32, Vector3.forward, false, animationTime);

                LineRenderer.Apply();
            }
        }
    public void RenderPlanetOrbits()
    {
        for (int i = 0; i < orbitsMatrixPlanets.GetLength(0); i++)
        {
            FastLinePlanetline.Reset();
            GameObject go = new GameObject("Orbit");
            go.transform.SetParent(planetIDGameObjectMap[i].transform);
            go.transform.localPosition = new Vector3(0f, 0f, 0f);

            FastLineRenderer lr = FastLineRenderer.CreateWithParent(go, FastLinePlanetline);

            FastLineRendererProperties props = new FastLineRendererProperties();

            props.Radius     = orbitLineRadius;
            props.LineJoin   = FastLineRendererLineJoin.AttachToPrevious;
            lr.UseWorldSpace = true;
            // props.Color = new Color(0.67f, 0.66f, 0.50f, 0.25f);
            lr.AddLine(props, orbitsMatrixPlanets[i], null);
            lr.ScreenRadiusMultiplier = orbitLineScale;

            lr.Apply();
        }

        //for (int i = 0; i < orbitsMatrixPlanets.GetLength(0); i++)
        //{
        //    GameObject go = new GameObject("Orbit");
        //    go.transform.SetParent(planetIDGameObjectMap[i].transform);
        //    go.transform.localPosition = new Vector3(0f, 0f, 0f);


        //    LineRenderer lr = Instantiate<LineRenderer>(LineOrbits, go.transform);
        //    lr.enabled = true;

        //    lr.name = "Orbit-" + solarsystem.Planets[i].OrbitalID;
        //    orbitsPlanets.Add(lr);
        //    lr.startWidth = 1f;
        //    lr.endWidth = 1f;
        //    lr.positionCount = segments;
        //    lr.SetPositions(orbitsMatrixPlanets[i]);
        //}
    }
        private void CreateDistinctSegmentsFromList()
        {
            // we don't want to reset the line renderer here, because we are using the same line renderer from the CreateContinuousLineFromList method and we want to keep those points
            // LineRenderer.Reset();

            // generate random start and end points
            List <Vector3> points = new List <Vector3>();

            for (int i = 0; i < 10; i++)
            {
                float x = Random.Range(-150.0f, 150.0f);
                float y = Random.Range(-100.0f, 100.0f);
                points.Add(new Vector3(x, y, 0.0f));

                x = Random.Range(-150.0f, 150.0f);
                y = Random.Range(-100.0f, 100.0f);
                points.Add(new Vector3(x, y, 0.0f));
            }

            // animation time per segment - set to 0 to have the whole thing appear at once
            const float animationTime = 1.0f;

            // create properties - do this once, before your loop
            // note you don't need to set the join for distinct segments added via the AddLine or AddLines call
            FastLineRendererProperties props = new FastLineRendererProperties();

            LineRenderer.AddLines(props, points, (FastLineRendererProperties _props) =>
            {
                // random color
                props.Color = new Color32((byte)Random.Range(0, 256), (byte)Random.Range(0, 256), (byte)Random.Range(0, 256), byte.MaxValue);

                // random radius
                props.Radius = Random.Range(0.25f, 1.0f);

                // animate this line segment in later
                props.AddCreationTimeSeconds(animationTime);
            }, true, true);

            // must call apply to make changes permanent
            LineRenderer.Apply();
        }
        private void DoGrid()
        {
            FastLineRendererProperties props = new FastLineRendererProperties
            {
                Radius = 2.0f
            };
            Bounds gridBounds = new Bounds();

            // *** Note: For a 2D grid, pass a value of true for the fill parameter for optimization purposes ***

            // draw a grid cube without filling
            gridBounds.SetMinMax(new Vector3(-2200.0f, -1000.0f, 1000.0f), new Vector3(-200.0f, 1000.0f, 3000.0f));
            LineRenderer.AppendGrid(props, gridBounds, 250, false);

            // draw a grid cube with filling
            gridBounds.SetMinMax(new Vector3(200.0f, -1000.0f, 1000.0f), new Vector3(2200.0f, 1000.0f, 3000.0f));
            LineRenderer.AppendGrid(props, gridBounds, 250, true);

            // commit the changes
            LineRenderer.Apply();
        }
    public void RenderMoonOrbits()
    {
        //for (int i = 0; i < orbitsMatrixMoons.GetLength(0); i++)
        //{
        //     LineRenderer lr = Instantiate<LineRenderer>(
        //         LineOrbits, planetIDGameObjectMap[solarsystem.Moons[i].Parent.OrbitalID].transform);
        //    lr.enabled = enable;
        //    lr.useWorldSpace = false;
        //    lr.name = "Orbit-" + solarsystem.Moons[i].Parent.OrbitalID.ToString() +
        //        "-" + solarsystem.Moons[i].OrbitalID.ToString();
        //    orbitsMoons.Add(lr);
        //    lr.startWidth = 60f;
        //    lr.endWidth = 60f;
        //    lr.startColor = moonsOrbitColour;
        //    lr.endColor = moonsOrbitColour;
        //    lr.positionCount = segmentsMoons;
        //    lr.SetPositions(orbitsMatrixMoons[i]);
        //}

        for (int i = 0; i < orbitsMatrixMoons.GetLength(0); i++)
        {
            FastLineMoonline.Reset();
            GameObject go = new GameObject("Orbit-Moon");
            go.transform.SetParent(planetIDGameObjectMap[solarsystem.Moons[i].Parent.OrbitalID].transform);
            go.transform.localPosition = new Vector3(0f, 0f, 0f);

            FastLineRenderer lr = FastLineRenderer.CreateWithParent(go, FastLineMoonline);

            FastLineRendererProperties props = new FastLineRendererProperties();

            props.Radius     = orbitLineRadius;
            props.LineJoin   = FastLineRendererLineJoin.AttachToPrevious;
            lr.UseWorldSpace = false;
            // props.Color = new Color(0.51f, 0.67f, 0.50f, 0.25f);
            lr.AddLine(props, orbitsMatrixMoons[i], null);
            lr.ScreenRadiusMultiplier = orbitLineScale;

            lr.Apply();
        }
    }
        private void CreateContinuousLineFromList()
        {
            // reset the line renderer - if you are appending to an existing line, don't call reset, as you would lost all the previous points
            LineRenderer.Reset();

            // generate zig zag
            List <Vector3> points = new List <Vector3>();

            for (int i = 0; i < 50; i++)
            {
                points.Add(new Vector3(-200 + (i * 10.0f), 100 + (150.0f * -(i % 2)), 0.0f));
            }

            // animation time per segment - set to 0 to have the whole thing appear at once
            const float animationTime = 0.1f;

            // create properties - do this once, before your loop
            FastLineRendererProperties props = new FastLineRendererProperties();

            props.Radius   = 0.1f;
            props.LineJoin = FastLineRendererLineJoin.Round;

            // add the list of line points
            LineRenderer.AddLine(props, points, (FastLineRendererProperties _props) =>
            {
                // random color
                props.Color = new Color32((byte)Random.Range(0, 256), (byte)Random.Range(0, 256), (byte)Random.Range(0, 256), byte.MaxValue);

                // animate this line segment in later
                props.AddCreationTimeSeconds(animationTime);

                // increase the radius
                props.Radius += 0.05f;
            }, true, true);

            // must call apply to make changes permanent
            LineRenderer.Apply();
        }