protected void Update() { double latitude = Input.location.lastData.latitude; double longitude = Input.location.lastData.longitude; var position = this.celestialManager.CalculatePosition(DateTime.UtcNow, latitude, longitude); double distance = CelestialScale.MoonScale(0.04f).AproxDistance; Vector3 v = Spherical.SphericalToCartesian(Math.PI / 2 - position.altitude, position.azimuth, distance /* moonPosition.distance / 405629.76174948126*/); Spherical vSpherical = (Spherical)v; Vector3 titlePosition = v.AddTheta(-Mathf.PI / 16); //titlePosition.y+=1.5f; myTextMesh.text = String.Format("{0}\n{1}\n{2} Km.", celestialManager.Name, celestialManager.Status, distance); myText.transform.position = titlePosition; myText.transform.rotation = Quaternion.EulerAngles(0, vSpherical.phi, 0); transform.rotation = Quaternion.EulerAngles(0, vSpherical.phi + Mathf.PI / 2, 0); transform.position = v; }
void Update() { double latitude = Input.location.lastData.latitude; double longitude = Input.location.lastData.longitude; foreach (var iManager in this.celestialManagers) { double deltaTheta, deltaPhi; var position = iManager.CalculatePosition(DateTime.UtcNow, latitude, longitude); double distance = CelestialScale.MoonScale(0.04f).AproxDistance; Vector3 v = Spherical.SphericalToCartesian(Math.PI / 2 - position.altitude, position.azimuth, distance /* moonPosition.distance / 405629.76174948126*/); Vector3 cameraDirection = Camera.main.transform.rotation * Vector3.forward; CalculateHelper(cameraDirection, v, out deltaPhi, out deltaTheta); double angle = Math.Atan2(deltaTheta, -deltaPhi) + Math.PI; double carboardRadius = 25f; double module = Math.Sqrt(deltaTheta * deltaTheta + deltaPhi * deltaPhi); if (module < (4 * Math.PI) / 180) { moonTargetCardboard.rectTransform.localPosition = new Vector3(200f, 200f, 0f); Application.LoadLevel("GoToTheMoonScene"); } else { moonTargetCardboard.rectTransform.localPosition = new Vector3((float)(1.5f * carboardRadius * Math.Cos(angle)), (float)(carboardRadius * Math.Sin(angle)), 0f); } } }
// Use this for initialization void Start() { distance = (float)CelestialScale.MoonScale(2f).AproxDistance; GameObject moon = GameObject.Find("/Moon"); GameObject cardBoardObject = GameObject.Find("/Moon/CardObject"); //cardBoardObject.transform.position = moon.transform.position; GameObject cardBoardObject1 = GameObject.Find("/Moon/CardObject1"); GameObject cardBoardObject2 = GameObject.Find("/Moon/CardObject2"); GameObject cardBoardObject3 = GameObject.Find("/Moon/CardObject3"); GameObject cardBoardObject4 = GameObject.Find("/Moon/CardObject4"); GameObject cardBoardObject5 = GameObject.Find("/Moon/CardObject5"); GameObject cardBoardObject6 = GameObject.Find("/Moon/CardObject6"); GameObject cardBoardObject7 = GameObject.Find("/Moon/CardObject7"); GameObject cardBoardObject8 = GameObject.Find("/Moon/CardObject8"); GameObject cardBoardObject9 = GameObject.Find("/Moon/CardObject9"); GameObject cardBoardObject10 = GameObject.Find("/Moon/CardObject10"); ArrayList list = new ArrayList(); list.Add(cardBoardObject); list.Add(cardBoardObject1); list.Add(cardBoardObject2); list.Add(cardBoardObject3); list.Add(cardBoardObject4); list.Add(cardBoardObject5); list.Add(cardBoardObject6); list.Add(cardBoardObject7); list.Add(cardBoardObject8); list.Add(cardBoardObject9); list.Add(cardBoardObject10); // Debug.Log (distance); Vector3 moonVector = new Vector3(0f, 0f, -distance); transform.position = moonVector; Random random = new Random(); for (int i = 0; i < list.Count; i++) { //list [i].transform.position = new Vector3 (); Vector3 noise = new Vector3(Random.Range(-10f, 10f), Random.Range(-10f, 10f), Random.Range(-10f, 10f)); ((GameObject)list[i]).transform.position = moonVector / (list.Count + 1) * (i + 1) + noise; } }