Ejemplo n.º 1
0
    private void DeselectStars(GameObject jewelcase)
    {
        bool updatedAsterism = false;

        foreach (Stars.StarBehavior starBehavior in jewelcase.transform.GetComponentsInChildren <Stars.StarBehavior>())
        {
            if (updatedAsterism == false)
            {
                Stars.StarData starData = starBehavior.GetStarData();

                if (starData != null)
                {
                    //int index = starData.AsterismIndex;
                    //Asterisms.Asterism asterism = Asterisms.AsterismParser.AsterismData[index];
                    //asterism.lineArt.SetWidth(1.0f);
                    updatedAsterism = true;
                }
            }

            starBehavior.IsSelected = false;
        }
    }
Ejemplo n.º 2
0
        public static void GetAsterismLines(ref StarData[] starData)
        {
            for(int i=0; i<AsterismParser.AsterismData.Length; i++) {
            Asterism asterism = AsterismParser.AsterismData[i];
            Vector3[] positionArray = new Vector3[asterism.HD_ids.Length];
            for(int j=0; j<asterism.HD_ids.Length;j++) {
              uint hdid = asterism.HD_ids[j];
              if(StarParser.HD_idToIndex != null && StarParser.HD_idToIndex.ContainsKey(hdid)) {
            StarData star = starData[StarParser.HD_idToIndex[hdid]];
            GameObject starObj = star.GameObjectRepresentation;
            if ( starObj != null ) {
              positionArray[j] = starObj.transform.position;
            }
            else {
              Debug.LogError("Ummm...this star is missing a game object. Skipping the asterism: " + asterism.name);
            }
              }
              else {
            Debug.LogError("Ummm...this star is missing. Skipping the asterism: " + asterism.name);
            continue;
              }
            }

            if ( asterism.lineArt == null ) {
              if ( m_lineMat == null ) {
            m_lineMat = Resources.Load("Lines/LineMat") as Material;
              }

              VectorLine asterismLines = new VectorLine(asterism.name + "_line", positionArray, m_lineMat, 1.0f, LineType.Discrete);
              asterism.lineArt = asterismLines;
            }
            else {
              asterism.lineArt.points3 = positionArray;
            }
            AsterismParser.AsterismData[i] = asterism;
              }

              setAsterismColor(m_asterismColor);
        }
Ejemplo n.º 3
0
        /*
        Index    STAR DATA
        ====  =================
        0  	  StarID,
        1  	  HIP,
        2  	  HD,
        3  	  HR,
        4  	  Gliese,
        5  	  BayerFlamsteed,
        6  	  ProperName,
        7  	  RA,
        8  	  Dec,
        9  	  Distance,
        10 	  PMRA,
        11 	  PMDec,
        12    RV,
        13 	  Mag,
        14 	  AbsMag,
        15 	  Spectrum,
        16	  ColorIndex,
        17	  X,
        18	  Y,
        19	  Z,
        20	  VX,
        21	  VY,
        22	  VZ
        */
        //uint id, string name, float ra, float dec, float dist, float mag
        private IEnumerator parseCSVLinesToStars(string[] lines)
        {
            //float lastTimeCheck = Time.time;
              		float lastFrameTime = Time.time;

              #if DEBUG
              		Debug.Log ("lines length: " + lines.Length);
              #endif

              		m_stars = new StarData[lines.Length - 2];
              		int count = 0;

              		foreach (string line in lines) {
            string[] lineData = line.Split (',');
            if (lineData.Length != 23) {
                    continue;
            } //ingnore incomplete lines
            if (lineData [0] == "StarID") {
              #if DEBUG
                    Debug.Log ("Ignoring first line");
              #endif
                    continue;
            }

            uint id;
            uint hdId;
            string starName = lineData [6];
            float ra;
            float dec;
            float dist;
            float mag;
            float absMag;
            float colorIndex;

            // Attempt parsing
            bool idParsed = uint.TryParse (lineData [0], out id);
            uint.TryParse (lineData [2], out hdId); // We don't care if it parses or not.
            bool raParsed = float.TryParse (lineData [7], out ra);
            bool decParsed = float.TryParse (lineData [8], out dec);
            bool distParsed = float.TryParse (lineData [9], out dist);
            bool magParsed = float.TryParse (lineData [13], out mag);
            bool absMagParsed = float.TryParse (lineData [14], out absMag);
            float.TryParse (lineData [16], out colorIndex); // We don't really care if it parses or not

            // Check if parsing successful
            if (!idParsed ||
                    !raParsed ||
                    !decParsed ||
                    !distParsed ||
                    !magParsed ||
                    !absMagParsed) {
                    Debug.Log ("missing key data: " + line);
                    continue;
            }

            if ( mag > 8.0f ) { continue; } // Keep to human eye limiting magnitude
            if (id == 0) {
                    continue;
            } // Skip sol

            m_stars [count] = new StarData (id, hdId, starName, ra, dec, dist, mag, absMag, colorIndex);

            if ( hdId != 0) {
              if ( !m_HD_idToIndex.ContainsKey(hdId) ) {
            m_HD_idToIndex.Add(hdId, count);
              }
              else {
            //            Debug.LogWarning("already parsed this HD_ID: " + hdId);
              }
            }

              			count++;

              			if (dist < MinStarDist) {
              				MinStarDist = dist;
              			} else if (dist > MaxStarDist) {
              				MaxStarDist = dist;
              			}

              			if (mag < MinStarMag) {
              				MinStarMag = mag;
              			} else if (mag > MaxStarMag) {
              				MaxStarMag = mag;
              			}

              			if (absMag < MinAbsStarMag) {
              				MinAbsStarMag = absMag;
              			} else if (absMag > MaxAbsStarMag) {
              				MaxAbsStarMag = absMag;
              			}

              			if (colorIndex < MinStarColorIndex) {
              				MinStarColorIndex = colorIndex;
              			} else if (colorIndex > MaxStarColorIndex) {
              				MaxStarColorIndex = colorIndex;
              			}

              			if (Time.time - lastFrameTime >= 0.25) {
              				lastFrameTime = Time.time;
              				yield return true;
              			}
              		}

              		Array.Resize<StarData> (ref m_stars, count);

              #if DEBUG

              		Debug.Log ("minDist: " + MinStarDist);
              		Debug.Log ("maxDist: " + MaxStarDist);
              		Debug.Log ("minMag: " + MinStarMag);
              		Debug.Log ("maxMag: " + MaxStarMag);
              		Debug.Log ("minAbsMag: " + MinAbsStarMag);
              		Debug.Log ("maxAbsMag: " + MaxAbsStarMag);
              		Debug.Log ("minColorIndex: " + MinStarColorIndex);
              		Debug.Log ("maxColorIndex: " + MaxStarColorIndex);

              #endif
             StartCoroutine( onStarsLoaded ());
              		yield break;
        }
Ejemplo n.º 4
0
 public StarLoadedEventArgs(StarData[] stars)
 {
     m_stars = stars;
 }
Ejemplo n.º 5
0
        // Set the position of a GameObject or Particle based star.
        private void setStarPosition(StarData sData, int index)
        {
            if(!m_distDirty) { return; }

              Vector3 position = starPositionFromNormalizedCoords(sData.NormalizedRightAscention, sData.NormalizedDeclination, sData.NormalisedDistance);
              sData.WorldPosition = position;
              if ( sData.GameObjectRepresentation != null ) {
            sData.GameObjectRepresentation.transform.position = position;
              }
              else
              {
            starParticles[index].position = position;
              }
        }
Ejemplo n.º 6
0
        // Set the visual properties of a Game Object or Particle based star.
        // This function only updates properties who's inputs have changed since the last update (via the "dirty" flags).
        private void setStarProperties(StarData sData, int index)
        {
            if(sData.WorldPosition == Vector3.zero) { Debug.Log("No world position."); return; }

              ParticleSystem.Particle starParticle = starParticles [index];

              if ( m_scaleDirty || m_distDirty) {
            float scaleFactor = AntiNorm(sData.NormalizedAbsoluteMagnitude, minScale, maxScale);
            float scaleDistanceAdjustment = calculateInverseScaleFactor(sData.WorldPosition);
            scaleFactor *= scaleDistanceAdjustment;

            if ( sData.GameObjectRepresentation != null )
            {
              sData.GameObjectRepresentation.transform.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor);
            }
            else {
              starParticle.size = scaleFactor;
            }
              }

              if ( m_colorDirty || m_luminosityDirty ) {
            Color starColor = Color.Lerp (blueColorSaturated, redColorSaturated, sData.NormalizedColorIndex);
            starColor = Color.Lerp(Color.white, starColor, saturationLevel);

            if ( sData.NormalizedMagnitude < minLuminance ) {
              starColor.a = 0.0f;
            }
            else {
              float luminosityMod = AntiNorm(sData.NormalizedMagnitude, minLuminosityMod , maxLuminosityMod);
              if ( luminanceCurve != null ) {
            luminosityMod = luminanceCurve.Evaluate(luminosityMod);
              }
              starColor.a = luminosityMod;
            }

            if ( sData.GameObjectRepresentation != null )
            {
              starParticle.color = new Color(0,0,0,0); // If we have a game object, don't show the particle version.
              sData.GameObjectRepresentation.transform.GetChild(0).renderer.material.color = starColor;
            }
            else {
              starParticle.color = starColor;
            }
              }

              // Save the updated particle to the array.
              starParticles [index] = starParticle;
        }
Ejemplo n.º 7
0
        // Create a label object along side a star
        private void generateStarLabel(StarData sData)
        {
            Vector3 position = starPositionFromNormalizedCoords(sData.NormalizedRightAscention, sData.NormalizedDeclination, sData.NormalisedDistance);

              StarLabel LabelItem = ((GameObject) Instantiate(Resources.Load ("Stars/Label"))).GetComponent<StarLabel>();
              LabelItem.LabelComp.color = new Color(255.0f, 255.0f, 255.0f, labelOpacity);
              LabelItem.Label = sData.Label;
              LabelItem.gameObject.transform.position = position.normalized * LABEL_DISTANCE;

              LabelItem.gameObject.transform.LookAt (transform.parent.parent.position, transform.parent.parent.up);
              sData.LabelObject = LabelItem;
              m_starLabels.Add(LabelItem);
        }
Ejemplo n.º 8
0
        // Set the position of a GameObject or Particle based star.
        private Vector3[] setStarPosition(StarData sData)
        {
            Vector3 position = starPositionFromNormalizedCoords(sData.NormalizedRightAscention, sData.NormalizedDeclination, sData.NormalisedDistance);
              sData.WorldPosition = position;

              if ( !m_isPolarAligned &&
            sData.Name == "Polaris" ) {
            m_polarAligner.transform.up = sData.WorldPosition.normalized;
            m_isPolarAligned = true;
                iAmPolaris.transform.position = sData.WorldPosition;
                iAmPolaris.name = "Polaris";
              }

            if ( sData.GameObjectRepresentation != null ) {
            sData.GameObjectRepresentation.transform.position = position;
            sData.GameObjectRepresentation.GetComponent<StarBehavior>().UpdateRepresentation();
              }

              float width = 0.006f;
              float scaleDistanceAdjustment = CalculateInverseScaleFactor(position);
              width *= scaleDistanceAdjustment;
              return calculateStarVerticesFromPositionAndWidth(position, width);
        }
Ejemplo n.º 9
0
 private void setGameObjectStarScale(StarData sData)
 {
     if ( m_scaleDirty || m_distDirty) {
     if ( sData.GameObjectRepresentation != null )
     {
       float scaleFactor = AntiNorm(sData.NormalizedAbsoluteMagnitude, minScale, maxScale);
       // Set the scale factors for the star.
       StarBehavior behavior = sData.GameObjectRepresentation.GetComponent<StarBehavior>();
       if ( behavior != null ) {
     behavior.BaseScaleFactor = scaleFactor;
     behavior.SelectedScaleFactor = scaleFactor * 1.5f;
       }
     }
       }
 }
Ejemplo n.º 10
0
        // Set the visual properties of a Game Object or Particle based star.
        // This function only updates properties who's inputs have changed since the last update (via the "dirty" flags).
        private Color32 calcStarColor(StarData sData)
        {
            if(sData.WorldPosition == Vector3.zero) {
            throw new Exception("No world position.");
              }

              Color32 starColor = Color32.Lerp (blueColorSaturated, redColorSaturated, sData.NormalizedColorIndex);
              starColor = Color32.Lerp(Color.white, starColor, saturationLevel);

              if ( sData.NormalizedMagnitude < minLuminance ) {
            starColor.a = 0;
              }
              else {
            float luminosityMod = AntiNorm(sData.NormalizedMagnitude, minLuminosityMod , maxLuminosityMod);
            if ( luminanceCurve != null ) {
              luminosityMod = luminanceCurve.Evaluate(luminosityMod);
            }
            byte byteMod = (byte)Mathf.RoundToInt(luminosityMod * 255.0f);
            starColor.a = byteMod;
              }

              if ( sData.GameObjectRepresentation != null )
              {
            sData.GameObjectRepresentation.transform.GetChild(0).GetComponent<Renderer>().material.color = starColor;
            return new Color32(0,0,0,0); // If we have a game object, don't show the particle version.
              }

              return starColor;
        }
Ejemplo n.º 11
0
        // Create a label object along side a star
        public void GenerateStarLabel(StarData sData, Transform root = null)
        {
            StarLabel LabelItem = ((GameObject) Instantiate(StarLabelPrototype)).GetComponent<StarLabel>();
              LabelItem.gameObject.SetActive(true);

              if ( root != null ) {
            LabelItem.transform.parent = root;
              }

              LabelItem.LabelComp.color = new Color(255.0f, 255.0f, 255.0f, labelOpacity);
              LabelItem.Label = sData.Label;
              LabelItem.transform.localPosition = Vector3.zero;
              if ( sData.GameObjectRepresentation != null ) {
            LabelItem.StarReference = sData.GameObjectRepresentation;
              }

              sData.LabelObject = LabelItem;
              m_starLabels.Add(LabelItem);
        }