Пример #1
0
        List <List <Vector3> > DeterminePoints(bool plottingParallels)
        {
            int segmentIncrement = 360 / segments;
            var points           = new List <List <Vector3> >();

            for (int i = -90; i <= 90; i += degreesBetweenLines)
            {
                var currPoints = new List <Vector3>();
                for (int j = 0; j < 360; j += segmentIncrement)
                {
                    var line = PlanetUtility.VectorFromLatLng(plottingParallels ? i : j, plottingParallels ? j : i, Vector3.right);

                    var hitInfo = PlanetUtility.LineFromOriginToSurface(transform, line, LayerMask.GetMask("Planet"));
                    if (hitInfo.HasValue)
                    {
                        currPoints.Add(hitInfo.Value.point);
                    }
                }

                if (currPoints.Count > 1)
                {
                    points.Add(currPoints);
                }
            }

            return(points);
        }
        private float CheckCameraDistance()
        {
            var distance = PlanetUtility.LineToSurface(lookAt.transform, cam.transform, maxCameraDistance, LayerMask.GetMask("Planet"));

            if (distance.HasValue)
            {
                return((distance.Value.point - cam.transform.position).magnitude);
            }
            return(maxCameraDistance);
        }
Пример #3
0
        public static GameObject PlacePoint(Transform planet, Transform container, Location location, GameObject prefab)
        {
            var placingAdjustment = 0.0f;
            var point             = PlanetUtility.VectorFromLatLng(location.latitude, location.longitude, Vector3.right);

            var hitInfo = PlanetUtility.LineFromOriginToSurface(planet, point, LayerMask.GetMask("Planet")); //TODO: Don't use "Planet" default layer?

            if (hitInfo.HasValue)
            {
                var go = UnityEngine.Object.Instantiate(prefab, hitInfo.Value.point + point * placingAdjustment, Quaternion.identity, container);
                go.name = location.name;
                return(go);
            }

            return(null);
        }
        public GameObject Plot(Transform planet, Transform container, int layer)
        {
            var plotted = PlanetUtility.PlacePoint(planet, container, location, pointPrefab);

            if (plotted != null)
            {
                plotted.layer = layer;
                var cp = plotted.AddComponent <DefaultCoordinatePoint>();
                //Copy over info from this point to the one on the gameobject
                cp.info = this;

                var point = (plotted.transform.position - planet.transform.position).normalized;
                plotted.transform.localScale = new Vector3(plotted.transform.localScale.x, plotted.transform.localScale.y, plotted.transform.localScale.z * magnitude);
                plotted.transform.rotation   = Quaternion.LookRotation(point);
            }

            return(plotted);
        }