Пример #1
0
    public void LoadPhoto(SorroundPhotoLocation photoLocation)
    {
        //TODO: Load path from database?
        _active = true;
        _currentLoadedPhotoLocation = photoLocation;
        PlayerUIController.Instance.PhotoClicked();
        PlayerController.Instance.CurrentPlayerState = PlayerController.PlayerState.SorroundViewing;
        _camera.enabled = true;
        DateTime firstTimestamp = photoLocation.Timestamps[0];
        string   sId            = photoLocation.PictureId.ToString("D4", CultureInfo.InvariantCulture);
        string   imagePath      = string.Format("{0}/{1}/{2}_{3}", _cameraFolderPath, MazeMapController.Instance.CampusId, sId,
                                                firstTimestamp.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture));

        foreach (KeyValuePair <Camera, MeshRenderer> camera in _cameraPlanes)
        {
            string path = string.Format("{0}/{1}/IMAG{2}.JPG", imagePath, camera.Key, sId);
            StartCoroutine(RenderPhoto(path, camera.Value));
        }

        //Load history
        if (_photoLocations[photoLocation.PictureId].Timestamps.Count > 2)
        {
            PlayerUIController.Instance.ResetTimeSlider();
            PlayerUIController.Instance.SetSliderVisibility(true);
            DateTime lastTimestamp = _photoLocations[photoLocation.PictureId].Timestamps[_photoLocations[photoLocation.PictureId].Timestamps.Count - 1];
            double   secondsBetweenFirstAndLast = lastTimestamp.Subtract(firstTimestamp).TotalSeconds;

            for (int i = 0; i < _photoLocations[photoLocation.PictureId].Timestamps.Count; i++)
            {
                DateTime timePosition     = _photoLocations[photoLocation.PictureId].Timestamps[i];
                double   secondsFromFirst = timePosition.Subtract(firstTimestamp).TotalSeconds;
                float    position         = 0;
                if (i > 0)
                {
                    position = (float)(secondsFromFirst / secondsBetweenFirstAndLast);
                }

                PlayerUIController.Instance.InstantiateTimeSliderPoint(position, timePosition);
            }
        }
        else
        {
            PlayerUIController.Instance.SetSliderVisibility(false);
        }
    }
Пример #2
0
    public void InitialisePhotoLocations(int campusId)
    {
        _photoLocations = new Dictionary <int, SorroundPhotoLocation>();
        string path = string.Format("{0}/{1}/", _cameraFolderPath, campusId);

        if (!Directory.Exists(path))
        {
            return;
        }

        string[] directories = Directory.GetDirectories(path);

        foreach (string directory in directories)
        {
            DirectoryInfo dirInfo   = new DirectoryInfo(directory);
            string[]      split     = dirInfo.Name.Split('_');
            int           id        = int.Parse(split[0]);
            DateTime      timestamp = DateTime.ParseExact(split[1], "dd-MM-yyyy", CultureInfo.InvariantCulture);

            SorroundPictureMeta metaData = JsonUtility.FromJson <SorroundPictureMeta>(File.ReadAllText(directory + "/meta.json"));

            if (!_photoLocations.ContainsKey(id))
            {
                GameObject photoLocationObject = Instantiate(_sorroundPhotoLocationPrefab,
                                                             metaData.GpsCoordinate.ToUTM().ToUnity(), Quaternion.Euler(metaData.Orientation));
                photoLocationObject.name = "SorroundPhoto_" + id;
                photoLocationObject.transform.SetParent(transform, true);

                SorroundPhotoLocation sorroundPhotoLocation = photoLocationObject.GetComponent <SorroundPhotoLocation>();
                sorroundPhotoLocation.PictureId = id;
                sorroundPhotoLocation.OnClick  += LoadPhoto;
                _photoLocations.Add(id, sorroundPhotoLocation);
            }

            _photoLocations[id].Timestamps.Add(timestamp);
            _photoLocations[id].Timestamps = _photoLocations[id].Timestamps.OrderBy(time => time).ToList();
        }
    }