public void CreateRoutePoints() { var startPoint = calculatedDevicePoint - Scholar.GPSCoorToPoint(startLocation); var targetPoint = calculatedDevicePoint - Scholar.GPSCoorToPoint(targetLocation); var stepPoints = new List <Vector3>() { new Vector3(0, 0, 0), new Vector3(targetPoint.x, 0, targetPoint.y) }; try { worldRouteRenderer.positionCount = stepPoints.Count; worldRouteRenderer.SetPositions(stepPoints.ToArray()); } catch (UnityException) { ThreadManager.ExecuteInUpdate(() => { worldRouteRenderer.positionCount = stepPoints.Count; worldRouteRenderer.SetPositions(stepPoints.ToArray()); }); } catch (Exception e) { Debug.LogError(e); } }
public void UpdateWorldPoints() { knownTargets.ForEach(target => { var position = calculatedDevicePoint - Scholar.GPSCoorToPoint(target.Location); target.transform.localPosition = new Vector3(position.x, 0, position.y); }); }
public void CreateRoutePoints() { var distance = Scholar.Distance(deviceLocation, TargetLocation, 'm'); var bearing = Scholar.BearingTo(deviceLocation, TargetLocation); // TODO: 179 ? var bearingRadians = Scholar.Deg2Rad(bearing) + 179; // Rotate POI's var xRot = -Math.Sin(bearingRadians) * (distance - 0) + 0; var zRot = +Math.Cos(bearingRadians) * (distance - 0) + 0; worldRouteRenderer.SetRoute(new Vector3(0, 0, 0), new Vector3((float)-xRot, 0, (float)zRot)); }
private void OnValidate() { //clamping distances and time gpsAccuracy = Mathf.Max(gpsAccuracy, 0.1f); searchRadius = Mathf.Max(searchRadius, 1.0f); deviceRadius = Mathf.Clamp(deviceRadius, 0.5f, searchRadius); updateDistance = Mathf.Max(updateDistance, 0.1f); updateInterval = Mathf.Max(updateInterval, 1.0f); //calcalute device coor in x and y calculatedDevicePoint = Scholar.GPSCoorToPoint(deviceLocation); calculatedTargetPoint = Scholar.GPSCoorToPoint(targetLocation); calculatedStartPoint = Scholar.GPSCoorToPoint(startLocation); }
public void CreateRoutePoints(GoogleRoute[] routes) { if (routes == null) { return; } var stepPoints = new List <Vector3>(); var pointPosition = new Vector3(); foreach (var route in routes) { foreach (var leg in route.legs) { pointPosition = calculatedDevicePoint - Scholar.GPSCoorToPoint(leg.start_location); stepPoints.Add(new Vector3(pointPosition.x, 0, pointPosition.y)); foreach (var step in leg.steps) { pointPosition = calculatedDevicePoint - Scholar.GPSCoorToPoint(step.end_location); stepPoints.Add(new Vector3(pointPosition.x, 0, pointPosition.y)); } } } try { worldRouteRenderer.positionCount = stepPoints.Count; worldRouteRenderer.SetPositions(stepPoints.ToArray()); } catch (UnityException) { ThreadManager.ExecuteInUpdate(() => { worldRouteRenderer.positionCount = stepPoints.Count; worldRouteRenderer.SetPositions(stepPoints.ToArray()); }); } catch (Exception e) { Debug.LogError(e); } lastUsedRoutes.Clear(); lastUsedRoutes.AddRange(routes); }
public void CreateWorldPoints(GooglePlace[] places) { knownTargets.Clear(); try { var allPlaces = places.Concat(predefinedPlaces); foreach (var place in allPlaces) { //excluding desired types var typesToInclude = typesToExclude.Except(place.types).ToArray(); if (!typesToInclude.SequenceEqual(typesToExclude)) { continue; } //calculating world position var position = calculatedDevicePoint - Scholar.GPSCoorToPoint(place.geometry.location); if (position.magnitude < deviceRadius) { continue; } var target = Instantiate(worldTargetPrefab); //setting new target target.transform.SetParent(worldRoot); target.transform.position = new Vector3(position.x, 0, position.y); target.Place = new PointOfInterest { name = place.name, address = new Address { location = place.geometry.location } }; //saving new target knownTargets.Add(target); } } catch (NullReferenceException e) { Debug.LogError(e); } }
public void UpdateWorldPlaces() { knownPlaces.ForEach(place => { //distance + bearing calculation var distance = Scholar.Distance(deviceLocation, place.Location, 'm'); var bearing = Scholar.BearingTo(deviceLocation, place.Location); place.Distance = (float)distance; place.Bearing = (float)bearing; // TODO: 179 ? var bearingRadians = Scholar.Deg2Rad(bearing) + 179; // Rotate POI's var xRot = -Math.Sin(bearingRadians) * (distance - 0) + 0; var zRot = +Math.Cos(bearingRadians) * (distance - 0) + 0; place.transform.localPosition = new Vector3((float)-xRot, 0, (float)zRot); }); knownPlaces.Sort((a, b) => a.Distance.CompareTo(b.Distance)); knownPlaces.ForEachWithIndex((place, index) => { SetPlaceSettingsAt(index); }); }