void Start() { if (AirportConfig.current == null) { Debug.LogError("No airport selected"); return; } VtsMapMakeLocal mml = gameObject.AddComponent <VtsMapMakeLocal>(); mml.latitude = AirportConfig.current.latitude; mml.longitude = AirportConfig.current.longitude; mml.altitude = AirportConfig.current.altitude; Destroy(this); // remove this component }
void Update() { if (string.IsNullOrEmpty(SelectMap.SelectedUrl)) { return; } VtsMap map = GetComponent <VtsMap>(); map.Map.SetMapconfigPath(SelectMap.SelectedUrl); VtsMapMakeLocal mml = gameObject.AddComponent <VtsMapMakeLocal>(); mml.x = SelectMap.SelectedPosition.x; mml.y = SelectMap.SelectedPosition.y; mml.z = SelectMap.SelectedPosition.z; mml.singleUse = true; GameObject sun = GameObject.Find("Sun"); sun.transform.rotation = Quaternion.Euler(SelectMap.SelectedSunDirection); Destroy(this); }
void Start() { if (isServer) { color = Color.HSVToRGB(Random.value, Random.value * 0.5f + 0.5f, Random.value * 0.5f + 0.5f); } if (isLocalPlayer) { Debug.Log("Initializing world '" + config.name + "'"); // initialize the map GameObject map = FindObjectOfType <VtsMap>().gameObject; map.GetComponent <VtsMap>().Map.SetMapconfigPath(config.mapconfigUrl); { VtsMapMakeLocal l = map.GetComponent <VtsMapMakeLocal>(); l.x = config.position[0]; l.y = config.position[1]; l.z = config.position[2]; } // initialize the car GetComponent <VtsRigidBodyActivate>().map = map; GetComponent <VtsColliderProbe>().mapObject = map; GetComponent <VtsColliderProbe>().collidersLod = config.collisionlod; // initialize other objects GameObject.Find("mainCamera").GetComponent <FollowingCamera>().target = gameObject; GameObject.Find("mainCamera").GetComponent <FollowingCamera>().enabled = true; GameObject.Find("minimapCamera").GetComponent <MinimapCamera>().target = gameObject; GameObject.Find("minimapCamera").GetComponent <MinimapCamera>().enabled = true; GameObject.Find("sun").transform.rotation = Quaternion.Euler(VtsUtil.V2U3(config.sunDirection)); // enable all components foreach (var c in gameObject.GetComponents <MonoBehaviour>()) { c.enabled = true; } } }
private void PerformShift() { // the focus object must be moved Debug.Assert(focusObject.GetComponentInParent <VtsObjectShiftingOriginBase>()); // compute the transformation change double[] originalNavigationPoint = umap.UnityToVtsNavigation(VtsUtil.ZeroV); double[] targetNavigationPoint = umap.UnityToVtsNavigation(VtsUtil.U2V3(focusObject.transform.position)); if (!VtsMapMakeLocal.MakeLocal(umap, targetNavigationPoint)) { Debug.Assert(false, "failed shifting origin"); return; } Vector3 move = -focusObject.transform.position; float Yrot = (float)(targetNavigationPoint[0] - originalNavigationPoint[0]) * Mathf.Sign((float)originalNavigationPoint[1]); // find objects that will be transformed var objs = new System.Collections.Generic.List <VtsObjectShiftingOriginBase>(); foreach (VtsObjectShiftingOriginBase obj in FindObjectsOfType <VtsObjectShiftingOriginBase>()) { // ask if the object allows to be transformed by this map if (obj.enabled && obj.OnBeforeOriginShift(this)) { objs.Add(obj); } } // actually transform the objects foreach (VtsObjectShiftingOriginBase obj in objs) { // only transform object's topmost ancestor - its childs will inherit the change // an object is shifted only once even if it has multiple VtsObjectShiftingOriginBase components if (!obj.transform.parent || !obj.transform.parent.GetComponentInParent <VtsObjectShiftingOriginBase>() && obj == obj.GetComponents <VtsObjectShiftingOriginBase>()[0]) { obj.transform.localPosition += move; obj.transform.RotateAround(Vector3.zero, Vector3.up, Yrot); } } // notify the object that it was transformed foreach (VtsObjectShiftingOriginBase obj in objs) { obj.OnAfterOriginShift(); } // force all objects cameras to recompute positions -> improves precision foreach (VtsCameraBase cam in FindObjectsOfType <VtsCameraBase>()) { cam.OriginShifted(); } // force all collider probes to recompute positions -> improves precision // warning: this has big performance impact! if (updateColliders) { foreach (VtsColliderProbe col in FindObjectsOfType <VtsColliderProbe>()) { col.OriginShifted(); } } }