Esempio n. 1
0
    /// <summary>
    /// Updates the object position.
    /// </summary>
    /// <param name="instance">Instance.</param>
    /// <param name="instanceLocation">Instance location.</param>
    /// <param name="instanceOptions">Instance options.</param>
    /// <param name="deviceLocation">Device location.</param>
    public void UpdateObjectPosition(
        ARLocationManagerEntry entry,
        Location deviceLocation,
        DVector3 delta,
        bool forceDisableSmooth = false
        )
    {
        var instance         = entry.instance;
        var instanceLocation = entry.location;
        var instanceOptions  = entry.options;
        var smoothMove       = instance.GetComponent <SmoothMove>();

        var useSmoothMove = !(smoothMove == null || forceDisableSmooth || locationProvider.provider.isRawTime());


        if (useSmoothMove)
        {
            smoothMove.Target = Location.GetGameObjectPositionForLocation(
                Camera.main.transform, deviceLocation, instanceLocation, instanceOptions.isHeightRelative
                );
        }
        else
        {
            Location.PlaceGameObjectAtLocation(
                instance.transform, Camera.main.transform, deviceLocation, instanceLocation, instanceOptions.isHeightRelative
                );
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Registers a new entry in the ARLocationManager.
    /// </summary>
    /// <param name="entry">Entry.</param>
    public int Add(ARLocationManagerEntry entry)
    {
        int id = -1;

        if (entry.options.createInstance)
        {
            var instance = Instantiate(entry.instance, transform);
            entry.instance = instance;
            id             = Mathf.Abs(instance.transform.GetInstanceID());
            entries.Add(id, entry);
        }
        else
        {
            entry.instance.transform.SetParent(transform);
            id = entry.instance.transform.GetInstanceID();
            entries.Add(id, entry);
        }

        // Check if we use smooth movement
        if (entry.options.movementSmoothingFactor > 0)
        {
            entry.instance.AddComponent <SmoothMove>();
            entry.instance.GetComponent <SmoothMove>().smoothing = entry.options.movementSmoothingFactor;
        }

        if (onObjectAddedDelegates != null)
        {
            onObjectAddedDelegates(entry);
        }

        entry.isDirty = true;

        return(id);
    }
Esempio n. 3
0
    private void Start()
    {
        manager = ARLocationManager.Instance;

        points = new Vector3[path.locations.Length];

        for (var i = 0; i < points.Length; i++)
        {
            points[i] = path.locations[i].ToVector3();
        }

        spline = Utils.BuildSpline(path.splineType, points, splineSampleSize, path.alpha);

        var sample = spline.SamplePoints(objectCount);

        entries = new ARLocationManagerEntry[sample.Length];

        for (var i = 0; i < entries.Length; i++)
        {
            entries[i] = new ARLocationManagerEntry
            {
                instance = prefab,
                location = new Location(sample[i].z, sample[i].x, sample[i].y),
                options  = new ARLocationObjectOptions
                {
                    isHeightRelative        = isHeightRelative,
                    movementSmoothingFactor = movementSmoothingFactor,
                    showDebugInfoPanel      = showDebugInfoPanel,
                    createInstance          = true
                }
            };

            manager.Add(entries[i]);
        }
    }
Esempio n. 4
0
        public void UpdateOnClickUID(ARLocationManagerEntry aRLocationManagerEntry)
        {
            Location location = aRLocationManagerEntry.location;
            string   json     = JsonUtility.ToJson(location);

            databaseReference.Child("ARMessages").Child(location.key).SetRawJsonValueAsync(json);
        }
Esempio n. 5
0
    // Use this for initialization
    void Start()
    {
        Location currentLoc = new Location();

        currentLoc.longitude = Convert.ToDouble(Input.location.lastData.longitude);
        currentLoc.latitude  = Convert.ToDouble(Input.location.lastData.latitude);
        currentLoc.altitude  = 0;

        manager = ARLocationManager.Instance;

        entry = new ARLocationManagerEntry
        {
            instance = gameObject,
            location = currentLoc,
            options  = new ARLocationObjectOptions
            {
                isHeightRelative        = isHeightRelative,
                showDebugInfoPanel      = showDebugInfoPanel,
                movementSmoothingFactor = movementSmoothingFactor,
                createInstance          = false
            }
        };

        manager.Add(entry);
    }
Esempio n. 6
0
    void HandleOnObjectAddedDelegate(ARLocationManagerEntry entry)
    {
        if (!entry.options.showDebugInfoPanel)
        {
            return;
        }

        var label = Instantiate(debugInfoPrefab, canvas.transform);

        label.GetComponentInChildren <Text>().text = entry.instance.name;

        debugPanelIntances.Add(entry.instance.transform.GetInstanceID(), label);
    }
Esempio n. 7
0
 public void getClickObjectInform(int instanceID)            //오브젝트를 눌렀어.
 {
     this.ClickMessageInform = manager.GetEntry(instanceID); // 현재 클릭한 오브젝트의 정보 저장
     ClickGoodButton();
     // 이제 여기서 클릭된 오브젝트의 Location 객체를 마음껏 사용할 수 있음
 }