void SpawnNewImagePOI(float dec, float ra)
    {
        //get the world coordinates
        float   radius   = ImageRadius + UnityEngine.Random.Range(-ImageRadiusVariance, ImageRadius);
        Vector3 spawnPos = CoordinateTransformation.ToWorldCoordiantes(dec, ra, radius);

        //spawn new POI object
        GameObject newPOI = Instantiate(ImagePOI, spawnPos, Quaternion.identity);

        newPOI.transform.SetParent(UniverseTransform);
        newPOI.transform.localPosition = spawnPos;

        //assign index
        //int index = numberOfImages + 1;
        newPOI.GetComponent <ImageDot>().SetIndex(numberOfImages);
        numberOfImages += 1;
    }
    public void UpdateTelescopePosition(float lat, float lng, float alt, float az)
    {
        //find position
        Vector3 planetCoor = CoordinateTransformation.ToWorldCoordiantes(lat, lng, planetRadius);

        transform.localPosition = planetCoor;

        //find orientation
        float x_rot = 0;
        float y_rot = -lng + az;
        float z_rot = lat - 90;

        transform.localRotation = Quaternion.Euler(new Vector3(x_rot, y_rot, z_rot));

        //update lens rotation
        float z_rot_lens = -alt;

        TelescopeLens.localRotation = Quaternion.Euler(new Vector3(0, 0, z_rot_lens));
    }
Beispiel #3
0
    void LoadConstellationLines()
    {
        //references to scriptable object(s)
        List <ConstellationStore> storeRef = EditorExtentionMethods.FindAssetsByType <ConstellationStore>();

        //each string contains a row
        string[] data = ConstellationData.text.Split(new char[] { '\n' });

        for (int i = 0; i < data.Length - 1; i++)
        {
            //break each row into individual elements
            string[] row = data[i].Split(new char[] { ',' });

            if (row.Length > 5)
            {
                // parse data
                string CON;
                nameConversion.TryGetValue(row[0], out CON);

                int HR1;
                int.TryParse(row[1], out HR1);

                float RA1;
                float.TryParse(row[2], out RA1);

                float DEC1;
                float.TryParse(row[3], out DEC1);

                float MAG1;
                float.TryParse(row[4], out MAG1);

                string GREEK1 = row[5];

                string NAME1 = GetElement(row[6], '|', 0);
                if (NAME1 == null)
                {
                    NAME1 = row[6];
                }

                int HR2;
                int.TryParse(row[7], out HR2);

                float RA2;
                float.TryParse(row[8], out RA2);

                float DEC2;
                float.TryParse(row[9], out DEC2);

                float MAG2;
                float.TryParse(row[10], out MAG2);

                string GREEK2 = row[11];

                string NAME2 = GetElement(row[12], '|', 0);
                if (NAME2 == null)
                {
                    NAME2 = row[12];
                }

                //add to star dictionary is not already present
                if (!stars.ContainsKey(HR1))
                {
                    //create star object
                    Star newStar = new Star();
                    newStar.StarName   = NAME1;
                    newStar.HR_Number  = HR1;
                    newStar.Brightness = MAG1;
                    newStar.Declination_RightAcsension = new Vector2(DEC1, RA1);
                    newStar.WorldPosition = CoordinateTransformation.ToWorldCoordiantes(DEC1, RA1, dataStore.CelsestialSphereRadius);
                    stars.Add(HR1, newStar);
                }
                if (!stars.ContainsKey(HR2))
                {
                    //create star object
                    Star newStar = new Star();
                    newStar.StarName   = NAME2;
                    newStar.HR_Number  = HR2;
                    newStar.Brightness = MAG2;
                    newStar.Declination_RightAcsension = new Vector2(DEC2, RA2);
                    newStar.WorldPosition = CoordinateTransformation.ToWorldCoordiantes(DEC2, RA2, dataStore.CelsestialSphereRadius);
                    stars.Add(HR2, newStar);
                }

                starConnections.Add(HR1);
                starConnections.Add(HR2);
            }
        }

        Star[] StarArray = ConvertToArray(stars);
        storeRef[0].allStars   = StarArray;
        storeRef[0].starGroups = GetConstellations(starConnections, StarArray);
    }