Topic: Positioning Hot Spots by location
When you have locations where the current and target panoramas are located, using uPano API you can convert the location to pan and tilt.
Example:
using System;
using InfinityCode.uPano;
using InfinityCode.uPano.HotSpots;
using UnityEngine;
public class CreateHotSpotByLocation : MonoBehaviour
{
public double panoLongitude;
public double panoLatitude;
public float panoAltitude;
public double hotSpotLongitude;
public double hotSpotLatitude;
public float hotSpotAltitude;
public GameObject hotSpotPrefab;
private HotSpot hotSpot;
private void Start()
{
HotSpotManager hotSpotManager = GetComponent<HotSpotManager>();
hotSpot = hotSpotManager.Create(0, 0, hotSpotPrefab);
UpdatePosition(hotSpot, hotSpotLongitude, hotSpotLatitude, hotSpotAltitude);
}
private void UpdatePosition(HotSpot hotSpot, double longitude, double latitude, float altitude)
{
double tx1, tx2, ty1, ty2;
GeoHelper.CoordinatesToTile(panoLongitude, panoLatitude, 20, out tx1, out ty1);
GeoHelper.CoordinatesToTile(longitude, latitude, 20, out tx2, out ty2);
double distance = GeoHelper.Distance(panoLongitude, panoLatitude, longitude, latitude) * 1000;
float pan = 90 + (float) MathHelper.Angle2D(tx1, ty1, tx2, ty2);
float tilt = 0;
float offset = altitude - panoAltitude;
if (Math.Abs(offset) > float.Epsilon)
{
tilt = (float)Math.Atan2(offset, distance) * Mathf.Rad2Deg;
}
hotSpot.SetPanTilt(pan, tilt);
}
}
Infinity Code Team.
Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.