Esempio n. 1
0
 public pinData(RSDESPin pin, Vector3 contactPoint)
 {
     RSDESManager.onEarthTilt += pin.onEarthTilt;
     this.pin          = pin;
     this.contactPoint = contactPoint;
     this.latLong      = GeoPlanetMaths.latlong(contactPoint, RSDESManager.earthPos);
     //pin.Latlong = this.latLong;
 }
Esempio n. 2
0
        public override void checkClassifier(EmbodiedClassifier classifier)
        {
            //look at whether the gesture being performed is close to the surface of the Earth
            float dist = IMRE.Math.Operations.magnitude((float3)RSDESManager.earthPos - classifier.origin);

            if (Unity.Mathematics.math.abs(RSDESManager.EarthRadius - dist) < tolerance && Time.time > _startTime + cooldown)
            {
                //figure out when the gesture began
                _startTime = Time.time;

                //make a pin at a location on the Earth closest to where the gesture is
                RSDESPin.Constructor(GeoPlanetMaths.latlong(classifier.origin, RSDESManager.earthPos));

                //the gesture has completed the functionality.
                classifier.shouldFinish = true;
            }
        }
Esempio n. 3
0
        // Use this for initialization
        void Awake()
        {
            Mesh m = GetComponent <MeshFilter>().mesh;

            Vector2[] uvs = m.uv;

            Vector3[] verts = m.vertices;
            for (int i = 0; i < uvs.Length; i++)
            {
                Vector2 tmp = GeoPlanetMaths.latlong(verts[i]);
                uvs[i] = new Vector2((tmp.y + 180f) / 360f, (tmp.x + 90f) / 180f);
                if (uvs[i].x < 0 || uvs[i].x > 1 || uvs[i].y < 0 || uvs[i].y > 1)
                {
                    Debug.LogWarning("UV OUT OF BOUND " + i + "  " + uvs[i].ToString());
                }
            }
            m.uv = uvs;
        }
Esempio n. 4
0
        private void updateLineRenderers()
        {
            switch (LineType)
            {
            case lineType.arc:
                thisLR.SetPositions(GeoPlanetMaths.greatArcCoordinates(associatedPins[0], associatedPins[1]));
                updateDistanceText();
                break;

            case lineType.circle:
                thisLR.SetPositions(GeoPlanetMaths.greatCircleCoordinates(associatedPins[0], associatedPins[1]));
                break;

            default:

                isVisible = false;
                break;
            }
        }
Esempio n. 5
0
 public void instantiateGreatArc(pinData pinA, pinData pinB)
 {
     if (!greatArcsExist.Contains(pinA.pin.name + pinB.pin.name))
     {
         greatArcsExist.Add(pinA.pin.name + pinB.pin.name);
         LineRenderer newLR = RSDESGeneratedLine();
         newLR.GetComponent <RSDESLineData>().associatedPins = new List <pinData>()
         {
             pinA, pinB
         };
         newLR.GetComponent <RSDESLineData>().LineType = lineType.arc;
         greatArcsLRs.Add(new List <pinData> {
             pinA, pinB
         }, newLR);
         newLR.startWidth    = LR_width;
         newLR.endWidth      = LR_width;
         newLR.positionCount = LR_Resolution;
         newLR.SetPositions(GeoPlanetMaths.greatArcCoordinates(pinA.pin.transform.position, pinB.pin.transform.position, LR_Resolution));
         newLR.loop = false;
     }
 }
Esempio n. 6
0
 public void instantiateGreatCircle(pinData pinA, pinData pinB)
 {
     if (!circlesExist.Contains(pinA.pin.name + pinB.pin.name))
     {
         circlesExist.Add(pinA.pin.name + pinB.pin.name);
         LineRenderer newLR = RSDESGeneratedLine();
         newLR.GetComponent <RSDESLineData>().associatedPins = new List <pinData> {
             pinA, pinB
         };
         newLR.GetComponent <RSDESLineData>().LineType = lineType.circle;
         newLR.startWidth    = LR_width;
         newLR.endWidth      = LR_width;
         newLR.positionCount = LR_Resolution;
         newLR.SetPositions(GeoPlanetMaths.greatCircleCoordinates(pinA.pin.transform.position, pinB.pin.transform.position, LR_Resolution));
         if (verboseLogging)
         {
             Debug.Log(newLR.name + " was created for the two points.");
         }
         newLR.loop = true;
     }
 }
Esempio n. 7
0
        private void SetSunMoonPositions()
        {
            Vector3 EarthOffset = Vector3.zero;

            if (Horizons.planetsHaveValues)
            {
                EarthOffset = Horizons.Planets.Find(p => p.id == 399).position;
            }
            if (Sun != null && sunPin != null && Horizons.planetsHaveValues)
            {
                if (sunBetweenTropics)
                {
                    Vector2 tmp = GeoPlanetMaths.latlong(Horizons.Planets.Find(p => p.id == 10).position - EarthOffset);
                    tmp.x          = (tmp.x / realEarthtilt) * earthTiltDeg;
                    sunPin.Latlong = tmp;
                }
                else
                {
                    sunPin.Latlong = GeoPlanetMaths.latlong(Horizons.Planets.Find(p => p.id == 10).position - EarthOffset);
                }
            }
            else
            {
                Debug.LogWarning("Sun, " + Sun + " ,or Sunpin, " + sunPin + " ,are not set.");
                RSDESPin.Constructor().GetComponent <RSDESPin>().setupSun();
            }
            if (Moon != null && moonPin != null && Horizons.planetsHaveValues)
            {
                moonPin.Latlong = GeoPlanetMaths.latlong(Horizons.Planets.Find(p => p.id == 301).position - EarthOffset);
            }
            else
            {
                Debug.LogWarning("moon, " + Moon + " ,or moonpin, " + moonPin + " ,are not set.");
                RSDESPin.Constructor().GetComponent <RSDESPin>().setupMoon();
            }
        }
Esempio n. 8
0
 private void setAltitudePos()
 {
     altitudeRenderer.SetPosition(0, GeoPlanetMaths.directionFromLatLong(0f, this.latlong.y).ScaleMultiplier(RSDESManager.radiusOfLargerSphere).Translate(RSDESManager.earthPos));
     altitudeRenderer.SetPosition(1, RSDESManager.earthPos);
     altitudeRenderer.SetPosition(2, GeoPlanetMaths.directionFromLatLong(this.latlong).ScaleMultiplier(RSDESManager.radiusOfLargerSphere).Translate(RSDESManager.earthPos));
 }
Esempio n. 9
0
 void Update()
 {
     GetComponent <TextMeshPro>().SetText(GeoPlanetMaths.timeOfSimulation(sunsubpoint.contactPoint).ToLongDateString());
 }
Esempio n. 10
0
 private void calculateDist()
 {
     _distance             = GeoPlanetMaths.greatArcLength(associatedPins[0], associatedPins[1]);
     _distanceTextPosition = thisLR.GetPosition(Mathf.FloorToInt(thisLR.positionCount / 2));
 }
Esempio n. 11
0
        public void updateLatLongLines()
        {
            if (latRenderer == null)
            {
                latRenderer = new LineRenderer[nLatDivisions + specialLatitudeCount];
                for (int i = 0; i < nLatDivisions + specialLatitudeCount; i++)
                {
                    latRenderer[i] = RSDESGeneratedLine();
                    latRenderer[i].positionCount = RSDESManager.LR_Resolution;
                    if (i % 2 == 0 && i < nLatDivisions)
                    {
                        latRenderer[i].startWidth = RSDESManager.LR_width * 3f;
                        latRenderer[i].endWidth   = RSDESManager.LR_width * 3f;
                    }
                    else
                    {
                        latRenderer[i].startWidth = RSDESManager.LR_width;
                        latRenderer[i].endWidth   = RSDESManager.LR_width;
                    }
                    latRenderer[i].useWorldSpace = true;
                }
            }
            if (decRenderer == null)
            {
                decRenderer = new LineRenderer[nLatDivisions + specialLatitudeCount];
                for (int i = 0; i < nLatDivisions + specialLatitudeCount; i++)
                {
                    decRenderer[i] = RSDESGeneratedLine();
                    decRenderer[i].positionCount = RSDESManager.LR_Resolution;
                    if (i % 2 == 0 && i < nLatDivisions)
                    {
                        decRenderer[i].startWidth = RSDESManager.LR_width * 3f;
                        decRenderer[i].endWidth   = RSDESManager.LR_width * 3f;
                    }
                    else
                    {
                        decRenderer[i].startWidth = RSDESManager.LR_width;
                        decRenderer[i].endWidth   = RSDESManager.LR_width;
                    }
                    decRenderer[i].useWorldSpace = true;
                }
            }
            //need to add subdivided grid.
            if (longRenderer == null)
            {
                longRenderer = new LineRenderer[nLongDivisions];
                for (int i = 0; i < nLongDivisions; i++)
                {
                    {
                        longRenderer[i] = RSDESGeneratedLine();
                    }
                    longRenderer[i].positionCount = RSDESManager.LR_Resolution;
                    if (i % 2 == 0)
                    {
                        longRenderer[i].startWidth = RSDESManager.LR_width * 3f;
                        longRenderer[i].endWidth   = RSDESManager.LR_width * 3f;
                    }
                    else
                    {
                        longRenderer[i].startWidth = RSDESManager.LR_width;
                        longRenderer[i].endWidth   = RSDESManager.LR_width;
                    }
                    longRenderer[i].useWorldSpace = true;
                }
            }
            if (ghaRenderer == null)
            {
                ghaRenderer = new LineRenderer[nLongDivisions];
                for (int i = 0; i < nLongDivisions; i++)
                {
                    ghaRenderer[i] = RSDESGeneratedLine();
                    ghaRenderer[i].positionCount = RSDESManager.LR_Resolution;
                    if (i % 2 == 0)
                    {
                        ghaRenderer[i].startWidth = RSDESManager.LR_width * 3f;
                        ghaRenderer[i].endWidth   = RSDESManager.LR_width * 3f;
                    }
                    else
                    {
                        ghaRenderer[i].startWidth = RSDESManager.LR_width;
                        ghaRenderer[i].endWidth   = RSDESManager.LR_width;
                    }
                    ghaRenderer[i].useWorldSpace = true;
                }
            }
            bool lat        = (myLatMode == latitudeMode.both || myLatMode == latitudeMode.incremental);
            bool specialLat = (myLatMode == latitudeMode.both || myLatMode == latitudeMode.special);
            bool dec        = showDeclination.ToggleState && !(myLatMode == latitudeMode.special);
            bool specialDec = showDeclination.ToggleState && specialLat;

            for (int i = 0; i < nLatDivisions + specialLatitudeCount; i++)
            {
                if (lat || dec || specialLat)
                {
                    float theta = (i * 180f / (nLatDivisions - 1)) - 90f;
                    if (i >= nLatDivisions)
                    {
                        theta = _specialLat[i - nLatDivisions];
                    }
                    Vector3[] positions = GeoPlanetMaths.latAtPoint(GeoPlanetMaths.directionFromLatLong(theta, 0) + earthPos, LR_Resolution).Translate(-earthPos).ScaleMultiplier(EarthRadius).Translate(earthPos);
                    latRenderer[i].SetPositions(positions);
                    decRenderer[i].SetPositions(positions.Translate(-earthPos).ScaleMultiplier(radiusOfLargerSphere / EarthRadius).Translate(earthPos));
                }
                if (i < nLatDivisions)
                {
                    latRenderer[i].enabled = lat;
                    decRenderer[i].enabled = dec;
                }
                else
                {
                    latRenderer[i].enabled = specialLat;
                    decRenderer[i].enabled = specialDec;
                }
                //arctics
                latRenderer[nLatDivisions].startColor     = articRenderer;
                latRenderer[nLatDivisions].endColor       = articRenderer;
                decRenderer[nLatDivisions].startColor     = articRenderer;
                decRenderer[nLatDivisions].endColor       = articRenderer;
                latRenderer[nLatDivisions + 1].startColor = articRenderer;
                latRenderer[nLatDivisions + 1].endColor   = articRenderer;
                decRenderer[nLatDivisions + 1].startColor = articRenderer;
                decRenderer[nLatDivisions + 1].endColor   = articRenderer;
                //tropics
                latRenderer[nLatDivisions + 2].startColor = tropicsRenderer;
                latRenderer[nLatDivisions + 2].endColor   = tropicsRenderer;
                decRenderer[nLatDivisions + 2].startColor = tropicsRenderer;
                decRenderer[nLatDivisions + 2].endColor   = tropicsRenderer;
                latRenderer[nLatDivisions + 3].startColor = tropicsRenderer;
                latRenderer[nLatDivisions + 3].endColor   = tropicsRenderer;
                decRenderer[nLatDivisions + 3].startColor = tropicsRenderer;
                decRenderer[nLatDivisions + 3].endColor   = tropicsRenderer;
            }


            bool sLong = showLongitude.ToggleState;
            bool sGHA  = showGHA.ToggleState;

            for (int i = 0; i < nLongDivisions; i++)
            {
                if (sLong || sGHA)
                {
                    //we only need to consider positive longitude since they are great circles.
                    Vector3[] positions = GeoPlanetMaths.longAtPoint(GeoPlanetMaths.directionFromLatLong(new Vector2(0, (180f / (nLongDivisions)) * i)) + earthPos, LR_Resolution);
                    longRenderer[i].SetPositions(positions);
                    ghaRenderer[i].SetPositions(positions.Translate(-earthPos).ScaleMultiplier(radiusOfLargerSphere / EarthRadius).Translate(earthPos));
                }
                longRenderer[i].enabled = sLong;
                ghaRenderer[i].enabled  = sGHA;
            }
        }
Esempio n. 12
0
 public override void pinFunction(RSDESPin pin, EmbodiedClassifier classifier)
 {
     pin.Latlong = GeoPlanetMaths.latlong(classifier.origin, RSDESManager.earthPos);
 }