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(); }