示例#1
0
        public void LoadLocationObjects(string message)
        {
            var opts = new PlaceAtLocation.PlaceAtOptions()
            {
                HideObjectUntilItIsPlaced  = true,
                MaxNumberOfLocationUpdates = 0,
                MovementSmoothing          = 0.05f,
                UseMovingAverage           = false
            };

            Debug.Log(message);
            var objects = JArray.Parse(message);

            foreach (JObject location in objects)
            {
                Debug.Log(location);

                double lat        = double.Parse((string)location["location"]["latitude"]);
                double lng        = double.Parse((string)location["location"]["longitude"]);
                JToken sensorData = location["data"];

                var entry = new Location()
                {
                    Latitude     = lat,
                    Longitude    = lng,
                    Altitude     = 0,
                    AltitudeMode = AltitudeMode.GroundRelative
                };

                //Create Game object
                GameObject newGameObject = Instantiate(Resources.Load("POIPrefab")) as GameObject;
                newGameObject.transform.SetParent(this.transform);


                //Create 3D text
                TextMeshPro textMesh = newGameObject.GetComponentsInChildren <TextMeshPro>(true)[0];
                foreach (JObject data in sensorData)
                {
                    textMesh.text = textMesh.text
                                    + (string)data["name"]
                                    + ": "
                                    + "<color=yellow>"
                                    + (string)data["value"]
                                    + "</color>"
                                    + System.Environment.NewLine;
                }

                //Put new Game Object to the Scene
                PlaceAtLocation.AddPlaceAtComponent(newGameObject, entry, opts);
                gameObjects.Add(entry, newGameObject);
                Debug.Log($"{lat}, {lng}, {name}");
            }
        }
示例#2
0
        void PlaceEntryAtLocation(Entry entry)
        {
            var prefab = PrefabDatabase.GetEntryById(entry.MeshId);

            if (prefab == null)
            {
                Debug.LogWarning($"Invalid prefab '{entry.MeshId}'");
                return;
            }

            var location = entry.Location;
            var options  = new PlaceAtLocation.PlaceAtOptions {
            };

            entry.Instance = PlaceAtLocation.CreatePlacedInstance(prefab, location, options, false);
            entry.Instance.transform.localEulerAngles = new Vector3(0, entry.Rotation, 0);
        }
    private void AddShipObject(string key, ShipData value)
    {
        if (!value.messageID.Equals("0"))
        {
            return;                                 //**원래라면 여기서 장애물 선별해야함.
        }
        ARLocation.Location newLocation = new ARLocation.Location()
        {
            Latitude     = double.Parse(value.latitude),
            Longitude    = double.Parse(value.longitude),
            Altitude     = 0,
            AltitudeMode = ARLocation.AltitudeMode.GroundRelative
        };

        //new object
        GameObject       copyPrefab = Instantiate <GameObject>(_shipObjPrefab);
        ShipObjectScript objSc      = copyPrefab.GetComponent <ShipObjectScript>();

        objSc._mapVC = _mapVC;

        ARLocation.PlaceAtLocation.PlaceAtOptions opts = new ARLocation.PlaceAtLocation.PlaceAtOptions()
        {
            HideObjectUntilItIsPlaced  = true,
            MaxNumberOfLocationUpdates = 1, //** 업데이트 횟 수 관리
            MovementSmoothing          = 0,
            UseMovingAverage           = true
        };

        objSc._mainSceneController = this;
        objSc._userKey             = key;
        objSc.SetShipData(value);

        objSc._placeAtLocationScript = ARLocation.PlaceAtLocation.AddPlaceAtComponentCustom(objSc._placeAtLocationScript, newLocation, opts);

        objSc._placeAtLocationScript.ObjectLocationUpdated.AddListener(ObjectUpdatedEvent); //이벤트 등록 (델리게이트)

        _shipObjs.Add(key, copyPrefab);
    }
示例#4
0
        void BuildGameObjects()
        {
            foreach (var entry in _dataEntries)
            {
                var Prefab = PrefabDatabase.GetEntryById(entry.meshId);

                if (!Prefab)
                {
                    Debug.LogWarning($"[ARLocation#WebMapLoader]: Prefab {entry.meshId} not found.");
                    continue;
                }

                var PlacementOptions = new PlaceAtLocation.PlaceAtOptions()
                {
                    MovementSmoothing          = entry.movementSmoothing,
                    MaxNumberOfLocationUpdates = entry.maxNumberOfLocationUpdates,
                    UseMovingAverage           = entry.useMovingAverage,
                    HideObjectUntilItIsPlaced  = entry.hideObjectUtilItIsPlaced
                };

                var location = new Location()
                {
                    Latitude     = entry.lat,
                    Longitude    = entry.lng,
                    Altitude     = entry.altitude,
                    AltitudeMode = entry.getAltitudeMode(),
                    Label        = entry.name
                };

                var instance = PlaceAtLocation.CreatePlacedInstance(Prefab,
                                                                    location,
                                                                    PlacementOptions,
                                                                    DebugMode);

                _stages.Add(instance);
            }
        }
    //바다정보 생성
    public void HttpItemsResultDelegate(bool isError, List <ItemInfo> datas)
    {
        if (isError)
        {
            _httpClass.SendItemsHttpLocation(_userLocation.latitude, _userLocation.longitude);
            return;
        }

        foreach (ItemInfo itemInfo in datas)
        {
            ARLocation.Location newLocation = new ARLocation.Location()
            {
                Latitude     = Double.Parse(itemInfo.LATI),
                Longitude    = Double.Parse(itemInfo.LONGI),
                Altitude     = 0,
                AltitudeMode = ARLocation.AltitudeMode.GroundRelative
            };
            ARLocation.PlaceAtLocation.PlaceAtOptions opts = new ARLocation.PlaceAtLocation.PlaceAtOptions()
            {
                HideObjectUntilItIsPlaced  = true,
                MaxNumberOfLocationUpdates = 1,
                MovementSmoothing          = 0,
                UseMovingAverage           = true
            };

            GameObject copyPrefab = null;

            string latA = itemInfo.LATI;
            string lonA = itemInfo.LONGI;
            //Debug.Log(itemInfo.DANGER_TYPE);
            if (itemInfo.DANGER_TYPE.Equals("1"))
            {
                copyPrefab = Instantiate <GameObject>(_itemObjPrefabA);
            }
            else if (itemInfo.DANGER_TYPE.Equals("2"))
            {
                copyPrefab = Instantiate <GameObject>(_itemObjPrefabB);
            }
            else if (itemInfo.DANGER_TYPE.Equals("3"))
            {
                copyPrefab = Instantiate <GameObject>(_itemObjPrefabC);
            }
            else if (itemInfo.DANGER_TYPE.Equals("4"))
            {
                copyPrefab = Instantiate <GameObject>(_itemObjPrefabD);
                latA       = "35.104148";
                lonA       = "129.063706";
            }
            else if (itemInfo.DANGER_TYPE.Equals("5"))
            {
                copyPrefab = Instantiate <GameObject>(_itemObjPrefabE);
                latA       = "35.106500";
                lonA       = "129.066195";
            }
            else
            {
                continue;
            }

            //좌현 33.3,   길이 1.9km
            //우현 213.3  길이 1.8km
            ItemObjectController objSc = copyPrefab.GetComponent <ItemObjectController>();
            objSc._mainSceneController = this;

            objSc.lat = latA;
            objSc.lon = lonA;

            objSc._placeAtLocationScript = ARLocation.PlaceAtLocation.AddPlaceAtComponentCustom(objSc._placeAtLocationScript, newLocation, opts);

            objSc._placeAtLocationScript.ObjectLocationUpdated.AddListener(ItemObjectUpdatedEvent); //이벤트 등록 (델리게이트)
        }
    }