void Update() { // Update target position from input float latitudeDelta = Input.GetAxis("Vertical") * movementSpeed * Time.deltaTime; float longitudeDelta = Input.GetAxis("Horizontal") * movementSpeed * Time.deltaTime; targetPosition.SetLatitude(targetPosition.GetLatitude() + (latitudeDelta * 0.00006f)); targetPosition.SetLongitude(targetPosition.GetLongitude() + (longitudeDelta * 0.00006f)); // Command positioner to move using lat-long positioner.SetLocation(targetPosition.GetLatitude(), targetPosition.GetLongitude()); // Update physical location via GeometryTransform, with corrected ECEF fetched from positioner coordinateFrame.SetPosition(positioner.GetECEFLocation()); }
/// <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="distanceFromInterest">Optional. The distance in metres from the interest point at which the camera should sit. If unspecified/null the distance to the previous interest point is maintained.</param> /// <param name="headingDegrees">Optional. The heading in degrees (0, 360) with which to view the target point, with 0 facing north, 90 east, etc. If unspecified/null the heading with which the camera's previous interest point was viewed will be maintained.</param> /// <param name="tiltDegrees">Optional. The camera tilt in degrees, where a value of 0 represents a camera looking straight down at the interest point, along the direction of gravity.</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>Weather the camera sucessfully amimated or not.</returns> public bool AnimateTo( LatLong interestPoint, double?distanceFromInterest = null, double?headingDegrees = null, double?tiltDegrees = null, double?transitionDuration = null, bool jumpIfFarAway = true) { if (m_controlledCamera == null) { throw new ArgumentNullException("Camera", m_nonNullCameraMessage); } const bool animated = true; const bool modifyPosition = true; const bool allowInterruption = true; const double interestAltitude = 0.0; return(SetView( NativePluginRunner.API, animated, interestPoint.GetLatitude(), interestPoint.GetLongitude(), interestAltitude, modifyPosition, distanceFromInterest.HasValue ? distanceFromInterest.Value : 0.0, distanceFromInterest.HasValue, headingDegrees.HasValue ? headingDegrees.Value : 0.0, headingDegrees.HasValue, tiltDegrees.HasValue ? tiltDegrees.Value : 0.0, tiltDegrees.HasValue, transitionDuration.HasValue ? transitionDuration.Value : 0.0, transitionDuration.HasValue, jumpIfFarAway, allowInterruption )); }
//Check whether a given position is within the gamespace public bool inSpace(LatLong pos) { double lat = pos.GetLatitude(); double lon = pos.GetLongitude(); return(lat < tl.GetLatitude() && lat > bl.GetLatitude() && lon < tr.GetLongitude() && lon > tl.GetLongitude()); }
public static LatLongInterop FromLatLong(LatLong ll) { return(new LatLongInterop { LatitudeDegrees = ll.GetLatitude(), LongitudeDegrees = ll.GetLongitude(), }); }
private TransportPositioner CreatePositioner(LatLong location) { var options = new TransportPositionerOptionsBuilder() .SetInputCoordinates(location.GetLatitude(), location.GetLongitude()) .Build(); return(Api.Instance.TransportApi.CreatePositioner(options)); }
public static LatLonS SerializeLatLon(LatLong arg) { LatLonS ret = new LatLonS(); ret.lat = arg.GetLatitude(); ret.lon = arg.GetLongitude(); return(ret); }
private Positioner CreatePositionerForPoint(LatLong point) { var options = new PositionerOptions() .LatitudeDegrees(point.GetLatitude()) .LongitudeDegrees(point.GetLongitude()) .ElevationAboveGround(1.0); return(Api.Instance.PositionerApi.CreatePositioner(options)); }
private IEnumerator StartLocationService() { if (!Input.location.isEnabledByUser) { Debug.Log("GPS Not Enabled"); statusText.text = "Not Enabled"; //CHANGE TEST LOCATION HERE latLong = testLocation3; latitude = latLong.GetLatitude(); longitude = latLong.GetLongitude(); Api.Instance.CameraApi.MoveTo(latLong, distanceFromInterest: 300, headingDegrees: 0, tiltDegrees: 50); new Translation(latLong); Debug.Log("GPS Awake End"); yield break; } Input.location.Start(); int gpsWaitTime = 0; while (Input.location.status == LocationServiceStatus.Initializing && gpsWaitTime <= 30) { yield return(new WaitForSeconds(1)); gpsWaitTime++; } if (gpsWaitTime >= 30) { Debug.Log("GPS Initialization timed out"); statusText.text = "Timed out."; yield break; } if (Input.location.status == LocationServiceStatus.Failed) { Debug.Log("GPS Initialization Failed"); statusText.text = "Failed"; yield break; } Input.compass.enabled = true; while (!Input.compass.enabled) { yield return(new WaitForSeconds(1)); } latitude = Input.location.lastData.latitude; longitude = Input.location.lastData.longitude; latLong = new LatLong(latitude, longitude); running = true; Debug.Log("Starting: " + latLong.GetLatitude()); //Camera snap to location Api.Instance.CameraApi.MoveTo(latLong, distanceFromInterest: 300, headingDegrees: 0, tiltDegrees: 50); new Translation(latLong); Debug.Log("GPS Awake End"); yield break; }
private void OnEnable() { var positionerOptions = new PositionerOptions() .ElevationAboveGround(0) .LatitudeDegrees(targetPosition.GetLatitude()) .LongitudeDegrees(targetPosition.GetLongitude()); boxPositioner = Api.Instance.PositionerApi.CreatePositioner(positionerOptions); boxPositioner.OnTransformedPointChanged += OnPositionerPositionUpdated; }
private void OnEnable() { var positionerOptions = new PositionerOptions() .ElevationAboveGround(25) .LatitudeDegrees(targetPosition.GetLatitude()) .LongitudeDegrees(targetPosition.GetLongitude()); viewPositioner = Api.Instance.PositionerApi.CreatePositioner(positionerOptions); viewPositioner.OnPositionerPositionChangedDelegate += OnPositionerPositionChanged; }
public GameSpace(double size, LatLong centre) { double lat = centre.GetLatitude(); double lon = centre.GetLongitude(); double offset = size / 2.0; tl = new LatLong(Translation.Instance.offsetLat(lat, offset), Translation.Instance.offsetLon(lon, lat, -offset)); tr = new LatLong(Translation.Instance.offsetLat(lat, offset), Translation.Instance.offsetLon(lon, lat, offset)); bl = new LatLong(Translation.Instance.offsetLat(lat, -offset), Translation.Instance.offsetLon(lon, lat, -offset)); br = new LatLong(Translation.Instance.offsetLat(lat, -offset), Translation.Instance.offsetLon(lon, lat, offset)); }
void Update() { // Update movement angle from input movementAngle += Input.GetAxis("Horizontal") * turnSpeed * Time.deltaTime; coordinateFrame.SetHeading(movementAngle); // Update target position from input var latitudeDelta = Mathf.Cos(Mathf.Deg2Rad * movementAngle) * Input.GetAxis("Vertical") * movementSpeed * Time.deltaTime; var longitudeDelta = Mathf.Sin(Mathf.Deg2Rad * movementAngle) * Input.GetAxis("Vertical") * movementSpeed * Time.deltaTime; targetPosition.SetLatitude(targetPosition.GetLatitude() + (latitudeDelta * 0.00006f)); targetPosition.SetLongitude(targetPosition.GetLongitude() + (longitudeDelta * 0.00006f)); // Command GeographicTransform to move using lat-long coordinateFrame.SetPosition(targetPosition); }
void MakeBox(LatLong latLong) { double altitude; var success = Api.Instance.BuildingsApi.TryGetAltitudeAtLocation(latLong, out altitude); if (success) { var boxLocation = LatLong.FromDegrees(latLong.GetLatitude(), latLong.GetLongitude()); var boxAnchor = Instantiate(boxPrefab) as GameObject; boxAnchor.GetComponent <GeographicTransform>().SetPosition(boxLocation); var box = boxAnchor.transform.GetChild(0); box.localPosition = new Vector3(0.0f, (float)altitude, 0.0f); Destroy(boxAnchor, 2.0f); } }
private void OnEnable() { Api.Instance.IndoorMapsApi.OnIndoorMapEntered += IndoorMapsApi_OnIndoorMapEntered; Api.Instance.CameraApi.MoveTo(m_indoorMapLocation, distanceFromInterest: 30, headingDegrees: 0, tiltDegrees: 45); var positionerOptions = new PositionerOptions() .ElevationAboveGround(1.0f) .LatitudeDegrees(m_indoorMapLocation.GetLatitude()) .LongitudeDegrees(m_indoorMapLocation.GetLongitude()) .IndoorMapWithFloorId(m_indoorMapId, m_indoorMapFloorId); viewPositioner = Api.Instance.PositionerApi.CreatePositioner(positionerOptions); viewPositioner.OnScreenPointChanged += OnPositionerPositionUpdated; StartCoroutine(EnterMap()); }
void OnEnable() { Api.Instance.GeographicApi.RegisterGeographicTransform(coordinateFrame); targetPosition = startPosition; positioner = Api.Instance.PositionerApi.CreatePositioner(new PositionerOptions() .LatitudeDegrees(targetPosition.GetLatitude()) .LongitudeDegrees(targetPosition.GetLongitude()) .ElevationAboveGround(100)); Api.Instance.CameraApi.MoveTo(targetPosition, distanceFromInterest: 1700, headingDegrees: 0, tiltDegrees: 45); coordinateFrame.SetPosition(targetPosition); box.SetParent(coordinateFrame.transform); box.localPosition = new Vector3(0.0f, 0.0f, 0.0f); box.localRotation = Quaternion.identity; positioner.SetLocation(targetPosition.GetLatitude(), targetPosition.GetLongitude()); }
public void EnterIndoorMap() { Api.Instance.CameraApi.MoveTo(m_indoorMapLocation, distanceFromInterest: 30); Api.Instance.IndoorMapsApi.EnterIndoorMap("intercontinental_hotel_8628"); const int numberOfFloors = 5; for (int floorId = 0; floorId < numberOfFloors; ++floorId) { var options = new PropOptions() .LatitudeDegrees(m_indoorMapLocation.GetLatitude()) .LongitudeDegrees(m_indoorMapLocation.GetLongitude()) .IndoorMapWithFloorId("intercontinental_hotel_8628", floorId) .GeometryId("duck") .Name("my_prop" + floorId.ToString()) .ElevationAboveGround(0.0) .HeadingDegrees(90.0); m_props.Add(Api.Instance.PropsApi.CreateProp(options)); } }
public void displayAsset(LatLong gl, int i) { //Determine distance in longitude and latitude between player and object double latChangeDegrees = gl.GetLatitude() - GPS.Instance.latitude; double lonChangeDegrees = gl.GetLongitude() - GPS.Instance.longitude; Debug.Log("Distance: " + latToMeters(latChangeDegrees) + ", " + lonToMeters(lonChangeDegrees)); //If object is in range if (latToMeters(latChangeDegrees) <= Constants.VIEW_RANGE / 2 && latToMeters(latChangeDegrees) >= -(Constants.VIEW_RANGE / 2) && lonToMeters(lonChangeDegrees) <= Constants.VIEW_RANGE / 2 && lonToMeters(lonChangeDegrees) >= -(Constants.VIEW_RANGE / 2)) { //groundPlane.SetActive(true); Debug.Log("Visible"); assets[i - 1].gameObject.SetActive(true); //Set asset position within ground plane assets[i - 1].transform.localPosition = new Vector3((float)lonToMeters(lonChangeDegrees) / 20, assets[i - 1].transform.localPosition.y, (float)latToMeters(latChangeDegrees) / 20); } else { assets[i - 1].gameObject.SetActive(false); } }
/// <summary> /// Set the location of this Positioner, at the specified latitude and longitude. /// </summary> /// <param name="position">The desired position in LatLong form.</param> public void SetPosition(LatLong position) { m_position = position; m_positionerApiInternal.SetPositionerLocation(this, m_position.GetLatitude(), m_position.GetLongitude()); }
public double getStartLon() { return(startPosition.GetLongitude()); }
/// <summary> /// Highlights a building at a given location and returns the highlight geometry as a GameObject through the callback. This can only generate highlight geometry for buildings which have streamed in. /// </summary> /// <param name="location">The geographic point which intersects with the building to be highlighted.</param> /// <param name="material">The material to assign the highlight geometry.</param> /// <param name="callback">The callback where the highlight will be received.</param> public void HighlightBuildingAtLocation(LatLong location, Material material, HighlightReceivedCallback callback) { var latLongAlt = LatLongAltitude.FromDegrees(location.GetLatitude(), location.GetLongitude(), -1.0); HighlightBuildingAtLocation(latLongAlt, material, callback); }
/// <summary> /// Gets the altitude of a building at a given location. This can only retreive the altitude for buildings which have streamed in. /// </summary> /// <param name="location">The geographic location to query the altitude of a building at.</param> /// <param name="out_altitude">The altitude of the building at the location</param> /// <returns>Whether there was a building to obtain a height from at the given location.</returns> public bool TryGetAltitudeAtLocation(LatLong location, out double out_altitude) { return(GetBuildingAltitudeAtLatLong(NativePluginRunner.API, location.GetLatitude(), location.GetLongitude(), out out_altitude)); }
/// <summary> /// Gets the building at a given location and returns it through the callback. This will only retrieve a building that has streamed in. /// </summary> /// <param name="location">The geographic point which intersects with the building to be returned.</param> /// <param name="callback">The callback where the building will be received.</param> public void GetBuildingAtLocation(LatLong location, BuildingReceivedCallback callback) { var latLongAlt = LatLongAltitude.FromDegrees(location.GetLatitude(), location.GetLongitude(), -1.0); GetBuildingAtLocation(latLongAlt, callback); }