// Start is called before the first frame update void Start() { wifiMarkers = new List <WifiMarker>(); if (dataStore.markerData == null) { dataStore.markerData = new List <WifiMarkerData>(); } // todo add manually here to set up scenario. if (spawnMode == WFSpawnMode.Auto) { foreach (var loadedMarker in dataStore.markerData) { //var latLongAlt = Api.Instance.SpacesApi.WorldToGeographicPoint(player.transform.position); LatLongAltitude latLongAlt = new LatLongAltitude(loadedMarker.Latitude, loadedMarker.Longitude, loadedMarker.Altitude); var wifi = Instantiate(spawnWifiObj) as GameObject; wifi.GetComponent <GeographicTransform>().SetPosition(latLongAlt.GetLatLong()); wifi.GetComponent <GeographicTransform>().SetElevation(latLongAlt.GetAltitude()); var marker = wifi.GetComponent <WifiMarker>(); marker.markerData.Latitude = (float)latLongAlt.GetLatitude(); marker.markerData.Longitude = (float)latLongAlt.GetLongitude(); marker.markerData.Altitude = (float)latLongAlt.GetAltitude(); marker.markerData.name = loadedMarker.name; marker.markerData.strengthLevel = loadedMarker.strengthLevel; marker.EnabledWifiSignaler(); marker.SetTextName(); wifiMarkers.Add(marker); } } }
private static void LogPathInformation( LatLong inputPositionA, LatLong inputPositionB, TransportPathfindResult pathfindResult, List <TransportWay> pathResultWays, List <TransportNode> pathResultNodes) { Debug.Log(string.Format("Found path from {0} to {1}: distance {2:0.00}m", inputPositionA.ToString(), inputPositionB.ToString(), pathfindResult.DistanceMeters)); foreach (var way in pathResultWays) { Debug.Log(string.Format("Way id [{0}] has classification {1}, length {2:0.00}m, width {3:0.00}m", Api.Instance.TransportApi.WayIdToString(way.Id), way.Classification, way.LengthMeters, way.HalfWidthMeters * 2 )); } foreach (var node in pathResultNodes) { Debug.Log(string.Format("Node id [{0}] at {1} has {2} incident edges", Api.Instance.TransportApi.NodeIdToString(node.Id), LatLongAltitude.FromECEF(node.Point).ToString(), node.IncidentDirectedEdges.Count )); } }
public bool TryFindIntersectionWithBuilding(DoubleRay rayEcef, out LatLongAltitude out_intersectionPoint) { LatLongAltitudeInterop intersectionPointInterop; bool didIntersect = NativeBuildingsApi_TryFindIntersectionWithBuilding(NativePluginRunner.API, ref rayEcef.origin, ref rayEcef.direction, out intersectionPointInterop); out_intersectionPoint = intersectionPointInterop.ToLatLongAltitude(); return(didIntersect); }
public static LatLonS SerializeLatLon(LatLongAltitude arg) { LatLonS ret = new LatLonS(); ret.lat = arg.GetLatitude(); ret.lon = arg.GetLongitude(); return(ret); }
protected void OnEnable() { PlayerTransform = VRTK_DeviceFinder.PlayAreaTransform(); if (!isHeightOnly) { latLongAlt = Api.Instance.SpacesApi.WorldToGeographicPoint(PlayerTransform.position);// new LatLongAltitude(37.7858, -122.401, 0); Api.Instance.SetOriginPoint(latLongAlt); } }
/// <summary> /// Try to get the transformed position as a LatLongAltitude of this Positioner. This can be used with SpacesApi.GeographicToWorldPoint to calculate a Vector3 translation for this Positioner. It is recommended to use a GeographicTransform for placing GameObjects on the map, however. /// </summary> /// <param name="out_latLongAlt">The LatLongAltitude that represents the Positioner's position with the desired elevation and ElevationMode applied. The value is only valid if this function returns true.</param> /// <returns>Whether or not this function was successful.</returns> public bool TryGetLatLongAltitude(out LatLongAltitude out_latLongAlt) { if (m_positionerApiInternal.TryFetchLatLongAltitudeForPositioner(this, out out_latLongAlt)) { return(true); } return(false); }
/// <summary> /// Transforms a point from local Unity space to a geographic coordinate using the supplied camera. If no camera is specified, the currently controlled camera will be used. /// Note: If using the ECEF coordinate system, the returned position will only be valid until the camera is moved. To robustly position an object on the map, use the GeographicTransform component. /// </summary> /// <param name="position">The geographical coordinates of the position to transform to local space.</param> /// <param name="camera">The camera for which to perform the transform. If this is left out, any camera which has previously been passed to SetControlledCamera will be used.</param> /// <returns>The transformed geographic LatLongAltitude in local space.</returns> public Vector3 GeographicToWorldPoint(LatLongAltitude position, Camera camera = null) { camera = camera ?? m_controlledCamera; if (camera == null) { throw new ArgumentNullException("camera", m_nonNullCameraMessage); } return(m_apiImplementation.GeographicToWorldPoint(position, camera)); }
private void OnPositionerPositionUpdated() { var boxLocation = new LatLongAltitude(); if (boxPositioner.TryGetLatLongAltitude(out boxLocation)) { box.position = Api.Instance.SpacesApi.GeographicToWorldPoint(boxLocation); } }
public static LatLongAltitudeInterop FromLatLongAltitude(LatLongAltitude lla) { return(new LatLongAltitudeInterop { LatitudeDegrees = lla.GetLatitude(), LongitudeDegrees = lla.GetLongitude(), Altitude = lla.GetAltitude() }); }
public void GetBuildingAtLocation(LatLongAltitude location, BuildingReceivedCallback callback) { int buildingRequestId = m_nextBuildingRequestId; BuildingRequest request; request.callback = callback; BuildingRequests.Add(buildingRequestId, request); NativeGetBuildingAtLocation(NativePluginRunner.API, location.GetLatitude(), location.GetLongitude(), location.GetAltitude(), OnBuildingReceived, buildingRequestId); m_nextBuildingRequestId += 1; }
public void SetOriginPoint(LatLongAltitude lla) { if (m_coordinateSystem == CoordinateSystem.ECEF) { m_cameraController.MoveTo(lla.GetLatLong()); } else { m_frame.SetCentralPoint(lla); } }
public void HighlightBuildingAtLocation(LatLongAltitude location, Material material, HighlightReceivedCallback callback) { int highlightRequestId = m_nextHighlightRequestId; HighlightRequest request; request.material = material; request.callback = callback; HighlightRequests.Add(highlightRequestId, request); NativeHighlightBuildingAtLocation(NativePluginRunner.API, location.GetLatitude(), location.GetLongitude(), location.GetAltitude(), OnHighlightReceived, highlightRequestId); m_nextHighlightRequestId += 1; }
/// <summary> /// Transforms the supplied geographical coordinates into screen space, using the supplied camera (if specified) or the camera previously set via SetControlledCamera if not. /// </summary> /// <param name="position">The geographical coordinates of the position to transform to screen space.</param> /// <param name="camera">The camera for which to perform the transform. If this is left out, any camera which has previously been passed to SetControlledCamera will be used.</param> /// <returns>The transformed geographic LatLongAltitude in screen space.</returns> public Vector3 GeographicToScreenPoint(LatLongAltitude position, Camera camera = null) { camera = camera ?? m_controlledCamera; if (camera == null) { throw new ArgumentNullException("camera", m_nonNullCameraMessage); } return(camera.ViewportToScreenPoint(GeographicToViewportPoint(position, camera))); }
internal Vector3 GeographicToWorldPoint(LatLongAltitude position, Camera camera) { if (m_coordinateSystem == CoordinateSystem.UnityWorld) { return(m_frame.ECEFToLocalSpace(position.ToECEF())); } else { return((position.ToECEF() - m_originECEF).ToSingleVector()); } }
IEnumerator lateStart() { yield return(new WaitForSeconds(4.0f)); var positionOpt = new Wrld.Space.Positioners.PositionerOptions(); //Api.Instance.PositionerApi.CreatePositioner(positionOpt); latLongAlt = new LatLongAltitude(37.7858, -122.401, 0); // Debug.Log(currentPosition.ToString()); initialized = true; }
internal LatLongAltitude WorldToGeographicPoint(Vector3 position, Camera camera) { if (m_coordinateSystem == CoordinateSystem.UnityWorld) { return(m_frame.LocalSpaceToLatLongAltitude(position)); } else { var ecefPosition = m_originECEF + position; return(LatLongAltitude.FromECEF(ecefPosition)); } }
internal Vector3 GeographicToViewportPoint(LatLongAltitude position, Camera camera) { if (m_coordinateSystem == CoordinateSystem.UnityWorld) { var point = m_frame.ECEFToLocalSpace(position.ToECEF()); return(camera.WorldToViewportPoint(point)); } else { var point = (position.ToECEF() - m_originECEF).ToSingleVector(); return(camera.WorldToViewportPoint(point)); } }
/// <summary> /// Smoothly animates the camera to view the supplied interest point. Requires that a camera has been set using SetControlledCamera. /// </summary> /// <param name="interestPoint">The latitude and longitude of the point on the ground which the camera should be looking at once the transition is complete.</param> /// <param name="cameraPosition">The latitude, longitude and altitude from which the camera will look at the interest point when the transition is complete.</param> /// <param name="transitionDuration">Optional. The total duration of the transition, in seconds. If not specified the duration will be calculated from the distance to be travelled and the camera's maximum speed.</param> /// <param name="jumpIfFarAway">Optional. By default AnimateTo will provide a smooth transition for short distances, but an instantaneous transition if there is a large distance to be covered (rather than waiting for a lengthy animation to play). If you want to override this behaviour and force an animation (even over large distances), you can set this to false.</param> /// <returns>Whether the camera successfully animated or not.</returns> public bool AnimateTo( LatLong interestPoint, LatLongAltitude cameraPosition, double?transitionDuration = null, bool jumpIfFarAway = true) { double distance; double headingDegrees; double tiltDegrees; GetTiltHeadingAndDistanceFromCameraAndTargetPosition(interestPoint, cameraPosition, out tiltDegrees, out headingDegrees, out distance); return(AnimateTo(interestPoint, distance, headingDegrees, tiltDegrees, transitionDuration, jumpIfFarAway)); }
void Start() { camapi = Api.Instance.CameraApi; cam = transform.GetComponentInChildren <Camera>(); float latitude = PlayerPrefs.GetFloat("latitude"); float longitude = PlayerPrefs.GetFloat("longitude"); GameObject.Find("WrldMap").GetComponentInChildren <WrldMap>().m_latitudeDegrees = latitude; GameObject.Find("WrldMap").GetComponentInChildren <WrldMap>().m_longitudeDegrees = longitude; Api.Instance.SetOriginPoint(LatLongAltitude.FromDegrees(latitude, longitude, 500)); cam.farClipPlane = cam.farClipPlane * 2 / 5; Input.simulateMouseWithTouches = false; spawn(); }
internal LatLongAltitude WorldToGeographicPoint(Vector3 position) { var mapSpacePoint = m_root.transform.InverseTransformPoint(position); if (m_coordinateSystem == CoordinateSystem.UnityWorld) { return(m_frame.LocalSpaceToLatLongAltitude(mapSpacePoint)); } else { var ecefPosition = m_originECEF + mapSpacePoint; return(LatLongAltitude.FromECEF(ecefPosition)); } }
internal LatLongAltitude ViewportToGeographicPoint(Vector3 viewportSpacePosition, UnityEngine.Camera camera) { var unityWorldSpacePosition = camera.ViewportToWorldPoint(viewportSpacePosition); if (m_coordinateSystem == CoordinateSystem.UnityWorld) { return(m_frame.LocalSpaceToLatLongAltitude(unityWorldSpacePosition)); } else { var finalPositionECEF = m_originECEF + unityWorldSpacePosition; return(LatLongAltitude.FromECEF(finalPositionECEF)); } }
internal Vector3 GeographicToWorldPoint(LatLongAltitude position) { Vector3 mapSpacePoint; if (m_coordinateSystem == CoordinateSystem.UnityWorld) { mapSpacePoint = m_frame.ECEFToLocalSpace(position.ToECEF()); } else { mapSpacePoint = (position.ToECEF() - m_originECEF).ToSingleVector(); } return(m_root.transform.TransformPoint(mapSpacePoint)); }
public bool TryFetchLatLongAltitudeForPositioner(Positioner positioner, out LatLongAltitude latLongAlt) { LatLongAltitudeInterop latLongAltInterop = new LatLongAltitudeInterop(); latLongAlt = new LatLongAltitude(); var success = NativePositionerApi_TryFetchLatLongAltitude(NativePluginRunner.API, positioner.Id, out latLongAltInterop); if (success) { latLongAlt = latLongAltInterop.ToLatLongAltitude(); return(true); } return(false); }
private void UpdatePointOnPath() { if (m_pathfindResult == null) { return; } var parameterizedDistanceAlongPath = CalcParameterizedDistanceAlongPath(m_time, m_prevSampleTime, m_currentSampleTime); var pointEcef = m_transportApi.GetPointEcefOnPath(m_pathfindResult, parameterizedDistanceAlongPath); var directionEcef = m_transportApi.GetDirectionEcefOnPath(m_pathfindResult, parameterizedDistanceAlongPath); var headingDegrees = m_spacesApi.HeadingDegreesFromDirectionAtPoint(directionEcef, pointEcef); m_capsule.SetActive(true); m_capsule.transform.localPosition = m_spacesApi.GeographicToWorldPoint(LatLongAltitude.FromECEF(pointEcef)); m_capsule.transform.localEulerAngles = new Vector3(90.0f, (float)headingDegrees, 0.0f); }
/// <summary> /// Moves the camera to view the supplied interest point instantaneously, without any animation. Requires that a camera has been set using SetControlledCamera. /// </summary> /// <param name="interestPoint">The latitude and longitude of the point on the ground which the camera should look at.</param> /// <param name="cameraPosition">The latitude, longitude and altitude from which the camera will look at the interest point.</param> /// <returns>Whether the camera successfully moved or not.</returns> public bool MoveTo( LatLong interestPoint, LatLongAltitude cameraPosition) { if (m_controlledCamera == null) { throw new ArgumentNullException("Camera", m_nonNullCameraMessage); } double distance; double headingDegrees; double tiltDegrees; GetTiltHeadingAndDistanceFromCameraAndTargetPosition(interestPoint, cameraPosition, out tiltDegrees, out headingDegrees, out distance); return(MoveTo(interestPoint, distance, headingDegrees, tiltDegrees)); }
private void OnPointOnGraphChanged() { if (m_transportPositioner.IsMatched()) { var pointOnGraph = m_transportPositioner.GetPointOnGraph(); var outputLLA = LatLongAltitude.FromECEF(pointOnGraph.PointOnWay); const double verticalOffset = 1.0; outputLLA.SetAltitude(outputLLA.GetAltitude() + verticalOffset); var outputPosition = Api.Instance.SpacesApi.GeographicToWorldPoint(outputLLA); m_sphereOutput.transform.position = outputPosition; m_directionIndicatorOutput.transform.localPosition = outputPosition; m_directionIndicatorOutput.transform.eulerAngles = new Vector3(0.0f, (float)pointOnGraph.HeadingOnWayDegrees, 0.0f); m_sphereOutput.SetActive(true); m_directionIndicatorOutput.SetActive(true); } }
private void CreatePathLines(TransportPathfindResult result) { var points = new List <Vector3>(); foreach (var pointEcef in result.PathPoints) { var lla = LatLongAltitude.FromECEF(pointEcef); lla.SetAltitude(lla.GetAltitude() + m_lineVerticalOffsetMeters); var worldPoint = Api.Instance.SpacesApi.GeographicToWorldPoint(lla); points.Add(worldPoint); } #if UNITY_5_6_OR_NEWER m_pathLineRenderer.positionCount = points.Count; #else m_pathLineRenderer.numPositions = points.Count; #endif m_pathLineRenderer.SetPositions(points.ToArray()); }
public ApiImplementation(string apiKey, CoordinateSystem coordinateSystem, Transform parentTransformForStreamedObjects, ConfigParams configParams) { m_nativePluginRunner = new NativePluginRunner(apiKey, parentTransformForStreamedObjects, configParams); m_coordinateSystem = coordinateSystem; var defaultStartingLocation = LatLongAltitude.FromDegrees( configParams.LatitudeDegrees, configParams.LongitudeDegrees, coordinateSystem == CoordinateSystem.ECEF ? configParams.DistanceToInterest : 0.0); if (coordinateSystem == CoordinateSystem.ECEF) { m_originECEF = defaultStartingLocation.ToECEF(); } else { m_frame = new UnityWorldSpaceCoordinateFrame(defaultStartingLocation); } m_cameraController = new CameraApi(this); }
public void SetOriginPoint(LatLongAltitude lla) { m_originECEF = lla.ToECEF(); if (m_coordinateSystem == CoordinateSystem.ECEF) { if (m_cameraController.HasControlledCamera) { m_cameraController.MoveTo(lla.GetLatLong()); } else { UpdateTransforms(); } } else { m_frame.SetCentralPoint(lla); UpdateTransforms(); } }
private void Start() { var ct = Controller.HoverTracker(this); //ct.onTriggerDown += OnTriggerDown; var positionOpt = new Wrld.Space.Positioners.PositionerOptions(); //Api.Instance.PositionerApi.CreatePositioner(positionOpt); startLatLongAlt = Api.Instance.SpacesApi.WorldToGeographicPoint(new Vector3(0, 100, 0)); Debug.Log(startLatLongAlt.GetLatitude()); Debug.Log(startLatLongAlt.GetLongitude()); Debug.Log(startLatLongAlt.GetAltitude()); latitude = 0; longitude = 0; altitudeInMetres = 0; latLongAlt = startLatLongAlt; dialogSetLat.Set("Slider", transform.rotation.eulerAngles.y, onChange: value => { latitude = value / 9000f; SetPosition(); }); dialogSetLong.Set("Slider", transform.rotation.eulerAngles.y, onChange: value => { longitude = value / 9000f; SetPosition(); }); dialogSetAlt.Set("Slider", transform.rotation.eulerAngles.y, onChange: value => { altitudeInMetres = value; SetPosition(); }); }