Esempio n. 1
0
    void CreatePoints()
    {
        points = new ParticleSystem.Particle[skyModel.GetStars().Count];

        currentStarSize = maxStarSize;

        for (int i = 0; i < skyModel.GetStars().Count; i++)
        {
            StarModel star = skyModel.GetStars() [i];


            points[i].position = star.GetEquatorialRectangularCoords() * sim.radius;

            points[i].startColor = star.GetStarRGB();

            points [i].startSize = maxStarSize * Mathf.Pow(star.getClampedMagnitude(), exponent) + minStarSize;

            points[i].velocity        = Vector3.zero;
            points[i].angularVelocity = 0.0f;
            points[i].rotation        = 0.0f;
        }

        ps.maxParticles = Mathf.RoundToInt(points.Length);
        ps.SetParticles(points, points.Length);
    }
    public void GenerateConstellations()
    {
        foreach (Constellation constellation in sim.skyModel.GetConstellations())
        {
            GameObject goConst = new GameObject();
            goConst.transform.parent = gameObject.transform;
            goConst.name             = constellation.GetAbbr();

            List <StarModel> stars          = skyModel.GetStars();
            int[]            reverseMapping = skyModel.GetReverseMapping();
            int i = 0;
            foreach (int[] line in constellation.GetLines())
            {
                GameObject go = new GameObject();
                go.transform.parent = goConst.transform;
                LineRenderer renderer = go.AddComponent <LineRenderer> ();
                renderer.useWorldSpace = false;                 //essential to make
                renderer.name          = "line_" + i;
                renderer.SetVertexCount(2);
                renderer.material = lineMaterial;
                renderer.SetColors(lineColor, lineColor);
                renderer.SetWidth(lineWidth, lineWidth);
                renderer.enabled = true;

                StarModel star1 = stars [reverseMapping [line [0]]];
                StarModel star2 = stars [reverseMapping [line [1]]];

                renderer.SetPosition(0, star1.GetEquatorialRectangularCoords() * (sim.radius + 1.0f));
                renderer.SetPosition(1, star2.GetEquatorialRectangularCoords() * (sim.radius + 1.0f));
                ++i;
            }
        }
    }
    void DrawConstellations()
    {
        CreateLineMaterial();
        lineMaterial.SetPass(0);

        Transform zero = go.transform;

        zero.position   = Vector3.zero;
        zero.rotation   = Quaternion.identity;
        zero.localScale = new Vector3(1.0f, 1.0f, 1.0f);

        GL.MultMatrix(zero.worldToLocalMatrix);


        List <StarModel> stars = skyModel.GetStars();

        int[] reverseMapping = skyModel.GetReverseMapping();

        GL.PushMatrix();
        GL.Begin(GL.LINES);

        GL.Color(constellationColor);
        foreach (Constellation constellation in skyModel.GetConstellations())
        {
            foreach (int[] line in constellation.GetLines())
            {
                StarModel star1 = stars [reverseMapping [line [0]]];
                StarModel star2 = stars [reverseMapping [line [1]]];
                GL.Vertex(star1.GetEquatorialRectangularCoords() * sim.radius);
                GL.Vertex(star2.GetEquatorialRectangularCoords() * sim.radius);
            }
        }

        GL.End();
        GL.PopMatrix();
    }