Beispiel #1
0
        public static float GetTerrainElevation(LatLon geoCoord)
        {
            float elevation = 0f;

            Vector3 pointOnUnitSphere = GeoCoord.GetPosRadius(geoCoord, 1);

            //Vector3 realWorldPos = geoCoord.planet.GetShapeGenerator().CalculatePointOnPlanet(pointOnUnitSphere);
            //geoCoord.planet.marker.transform.position = realWorldPos;
            //elevation = Vector3.Distance(geoCoord.centre, realWorldPos) - geoCoord.radius;
            elevation = 0f; // geoCoord.planet.GetShapeGenerator().CalculateHeight(pointOnUnitSphere) - geoCoord.radius;

            return(elevation);
        }
 public void SetPos(Vector3 pos)
 {
     planet = planetObj.GetComponent <GravitationalBody>();
     if (planet)
     {
         GeoCoord.SetPosATL(transform, new LatLon(planet, pos.x, pos.y), pos.z + (ObjectHeightOffset / 2));
         Debug.Log(transform.name + " placed at (" + pos.x + "," + pos.y + ")");
     }
     else
     {
         Debug.LogWarning("No planet data provided!");
     }
 }
Beispiel #3
0
        // Update is called once per frame
        void Update()
        {
            vehicle = controller.ControlTarget;
            if (vehicle != null)
            {
                LatLon geoPos        = vehicle.GetGeoPos();
                float  TerrainHeight = GeoCoord.GetTerrainElevation(geoPos);
                tmpPosition.text = ("LatLonHeight: (" + Mathf.Round(geoPos.lat * 10f) / 10f + "," + Mathf.Round(geoPos.lon * 10f) / 10f + "," + Mathf.Round(TerrainHeight * 100f) / 100f) + ")";

                /*
                 * tmpGravity.text = ("Gravity: " + Mathf.Round(vehicle.GetGravitationalForce() * 100f) / 100f);
                 *
                 * tmpHeight.text = ("Height: " + Mathf.Round(vehicle.GetHeight() * 100f) / 100f);
                 *
                 * tmpTemp.text = ("Temp: " + Mathf.Round(vehicle.GetAirDensity() * 1000f) / 1000f);
                 *
                 * tmpLift.text = ("Lift: " + Mathf.Round(vehicle.GetLiftForce() * 100f) / 100f);
                 */
            }
        }
        public void CacheChunks(Chunk[] chunks)
        {
            for (int j = 0; j < chunks.Length; j++)
            {
                if (chunks[j].hasMesh)
                {
                    chunks[j].gameObject.SetActive(false);
                }
            }

            for (int i = 0; i < triggerObjects.Length; i++)
            {
                float  nearestDist  = Mathf.Infinity;
                Chunk  nearestChunk = null;
                LatLon position     = GeoCoord.GetLatLon(planet, triggerObjects[i].position);

                for (int j = 0; j < chunks.Length; j++)
                {
                    float dist = GeoCoord.GetDistance(position, chunks[j].centre);
                    if (dist < nearestDist)
                    {
                        nearestDist  = dist;
                        nearestChunk = chunks[j];
                    }
                }

                if (nearestChunk != null)
                {
                    ActivateChunk(nearestChunk);
                    Chunk[] connectedChunks = nearestChunk.ConnectedChunks;
                    for (int j = 0; j < connectedChunks.Length; j++)
                    {
                        ActivateChunk(connectedChunks[j]);
                    }
                }
            }
        }
Beispiel #5
0
 //A quick script to get pos above ground
 public virtual LatLon GetGeoPos()
 {
     return(GeoCoord.GetLatLon(gb, transform.position));
 }