Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        Application.targetFrameRate = 60;

        // Find the LocationProvider
        locationProvider = ARLocationProvider.Instance;
        if (locationProvider == null)
        {
            Debug.LogError("[ARFoundation+GPSLocation][ARLocatedObjectsManager]: LocationProvider GameObject or Component not found.");
            return;
        }

        // Add the initially set objects
        foreach (var entry in objects)
        {
            Add(entry);
        }

        // Register callback for handling location updates
        locationProvider.OnLocationUpdated(HandleLocationUpdatedDelegate);

        // Register callback for handling new camera frames
#if !ARGPS_USE_VUFORIA
        ARSubsystemManager.cameraFrameReceived += frameHandler;
#endif
        // Cart onStart delegates
        hasStarted = true;
        if (onStartDelegate != null)
        {
            onStartDelegate();
        }
    }
Exemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
            mainCamera       = GameObject.FindGameObjectWithTag("MainCamera");
            isMainCameraNull = mainCamera == null;

            locationProvider = ARLocationProvider.Instance;

            redArrow             = GameObject.Find(gameObject.name + "/Panel/CompassImage/RedArrow");
            trueNorthLabel       = GameObject.Find(gameObject.name + "/Panel/TrueNorthLabel");
            magneticNorthLabel   = GameObject.Find(gameObject.name + "/Panel/MagneticNorthLabel");
            headingAccuracyLabel = GameObject.Find(gameObject.name + "Panel/HeadingAccuracyLabel");
            latitudeLabel        = GameObject.Find(gameObject.name + "/Panel/LatitudeLabel");
            longitudeLabel       = GameObject.Find(gameObject.name + "/Panel/LongitudeLabel");
            altitudeLabel        = GameObject.Find(gameObject.name + "Panel/AltitudeLabel");
            compassImage         = GameObject.Find(gameObject.name + "Panel/CompassImage");

            text  = trueNorthLabel.GetComponent <Text>();
            text1 = magneticNorthLabel.GetComponent <Text>();
            text2 = headingAccuracyLabel.GetComponent <Text>();
            text3 = latitudeLabel.GetComponent <Text>();
            text4 = longitudeLabel.GetComponent <Text>();
            text5 = altitudeLabel.GetComponent <Text>();

            rectTransform1 = compassImage.GetComponent <RectTransform>();
            rectTransform  = redArrow.GetComponent <RectTransform>();
        }
 // Start is called before the first frame update
 void Start()
 {
     locationProvider    = ARLocationProvider.Instance;
     arLocationManager   = ARLocationManager.Instance;
     arLocationRoot      = arLocationManager.gameObject.transform;
     mainCameraTransform = arLocationManager.MainCamera.transform;
     locationProvider.OnLocationUpdatedEvent(locationUpdatedHandler);
     locationProvider.OnProviderRestartEvent(ProviderRestarted);
 }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        locationProvider = ARLocationProvider.Instance;

        if (canvas == null)
        {
            return;
        }

        canvas.renderMode = RenderMode.ScreenSpaceOverlay;
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        orientation      = FindObjectOfType <ARLocationOrientation>();
        locationProvider = ARLocationProvider.Instance;

        redArrow             = GameObject.Find(gameObject.name + "/Panel/CompassImage/RedArrow");
        blueArrow            = GameObject.Find(gameObject.name + "/Panel/CompassImage/BlueArrow");
        trueNorthLabel       = GameObject.Find(gameObject.name + "/Panel/TrueNorthLabel");
        magneticNorthLabel   = GameObject.Find(gameObject.name + "/Panel/MagneticNorthLabel");
        headingAccuracyLabel = GameObject.Find(gameObject.name + "Panel/HeadingAccuracyLabel");
        compassImage         = GameObject.Find(gameObject.name + "Panel/CompassImage");
    }
Exemplo n.º 6
0
 private void Awake()
 {
     //waterMesh = GetComponent<WaterMesh>();
     delaunayMesh  = GetComponent <DelaunayMesh>();
     wallPlacement = GetComponent <WallPlacement>();
     entireCSVData = CSV_extended.ParseCsvFileUsingResources(pathToCSV);
     generateMeshButton.interactable = true;
     informationCanvas.enabled       = false;
     settingsCanvas.enabled          = false;
     aRTransformationManager         = ARTransformationManager.Instance;
     aRLocationProvider = ARLocationProvider.Instance;
     DisableInformationText();
 }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas/Provider").GetComponent <Text>());
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas/Latitude").GetComponent <Text>());
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas/Longitude").GetComponent <Text>());
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas/Altitude").GetComponent <Text>());
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas/Time").GetComponent <Text>());
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas/Status").GetComponent <Text>());
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas Right/DistanceWalked").GetComponent <Text>());
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas Right/CameraPosition").GetComponent <Text>());
        texts.Add(GameObject.Find(gameObject.name + "/Panel/Canvas Right/MagneticSensor").GetComponent <Text>());

        locationProvider = ARLocationProvider.Instance;

        accuracyBar = GameObject.Find(gameObject.name + "/Panel/Canvas/LoadingBar").GetComponent <LoadingBar>();
    }
Exemplo n.º 8
0
    public void Start()
    {
        locationProvider    = ARLocationProvider.Instance;
        arLocationManager   = ARLocationManager.Instance;
        arLocationRoot      = arLocationManager.gameObject.transform;
        mainCameraTransform = arLocationManager.MainCamera.transform;
        locationProvider.OnLocationUpdatedEvent(locationUpdatedHandler);
        locationProvider.OnProviderRestartEvent(ProviderRestarted);
        csv          = GetComponent <CSV>();
        delaunayMesh = GetComponent <DelaunayMesh>();

        if (locationProvider == null)
        {
            Debug.LogError("[AR+GPS][PlaceAtLocation]: LocationProvider GameObject or Component not found.");
            return;
        }
    }
Exemplo n.º 9
0
    private void updateDebugInfoPanelScreenPosition(int id, GameObject panel)
    {
        ARLocationProvider locationProvider = ARLocationProvider.Instance;

        var entry    = manager.GetEntry(id);
        var instance = entry.instance;
        var location = entry.location;

        var text =
            // instance.name + "\n"
            //+ "LAT: " + location.latitude + "\n"
            //+ "LNG: " + location.longitude + "\n"
            //+ "ALT: " + location.altitude + "\n"
            //+ "POS: " + instance.transform.position
            location.label + "\n"
            + "╟е╦╝: " + Convert.ToInt16(Location.HorizontalDistance(locationProvider.currentLocation.ToLocation(), location)) + "╧лем";

        ARLocationDebugInfo.UpdateDebugInfoPanelScreenPositionAndText(instance, panel, text);
    }
Exemplo n.º 10
0
    void Start()
    {
        if (locationPath == null)
        {
            throw new Exception("null location path");
        }

        pointCount = locationPath.locations.Length;
        points     = new Vector3[pointCount];

        locationProvider = ARLocationProvider.Instance;
        locationProvider.OnLocationUpdated(LocationUpdated);

        manager = ARLocationManager.Instance;
        manager.OnRestart(OnRestartHandler);

        arLocationRoot = Utils.FindAndLogError("ARLocationRoot", "[ARLocationMoveAlongPath]: ARLocationRoot GameObject not found.");

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

        transform.SetParent(arLocationRoot.transform);

        playing = autoPlay;

        if (showDebugInfo)
        {
            arLocationDebugInfo = Utils.FindAndGetComponent <ARLocationDebugInfo>("ARLocationRoot");

            if (arLocationDebugInfo == null)
            {
                showDebugInfo = false;
            }
            else if (lineRenderer != null)
            {
                SetupDebugObjects();
            }
        }
    }
Exemplo n.º 11
0
    private void Start()
    {
        string RecLocation = PlayerPrefs.GetString("LocationPath");

        List <Location> locations = new List <Location>();
        string          word      = "|";

        string[] words = RecLocation.Split(new string[] { word }, StringSplitOptions.None);
        int      cnt   = words.Length;

        string[] val = RecLocation.Split('|');
        string[] val2;

        locationProvider = ARLocationProvider.Instance;

        manager = ARLocationManager.Instance;

        if (manager == null)
        {
            Debug.LogError("[ARFoundation+GPSLocation][PlaceAtLocations]: ARLocatedObjectsManager Component not found.");
            return;
        }

        for (int i = 0; i < cnt; i++)
        {
            Location location1 = new Location();
            if (i == cnt - 1)
            {
                val2 = val[i - 1].Split(',');
                location1.longitude = Convert.ToDouble(val2[0]);
                location1.latitude  = Convert.ToDouble(val2[1]);
                location1.altitude  = 1;
                location1.label     = "µµÂøÁö";
                locations.Add(location1);
            }
            else
            {
                continue;
            }
        }

        locations.ForEach(AddLocation);
    }
Exemplo n.º 12
0
    // Use this for initialization
    void Start()
    {
        latValueText      = GameObject.Find("LatValue");
        lngValueText      = GameObject.Find("LngValue");
        headingValueText  = GameObject.Find("HeadingValue");
        altitudeValueText = GameObject.Find("AltValue");
        debugText         = GameObject.Find("DebugText");


        locationProvider = ARLocationProvider.Instance;

        //locationProvider.onLocationUpdated((Location location, Location _, Vector3 __, float accuracy) =>
        //{
        //    setLat(location.latitude, accuracy);
        //    setLng(location.longitude);
        //    setAltitude(location.altitude);
        //});

        //locationProvider.onCompassUpdated(setHeading);
    }
Exemplo n.º 13
0
    //public void RecvLocation(string RecLoc)
    //{
    //    RecLocation1 = RecLoc;
    //}

    // Use this for initialization
    private void Start()
    {
        //if (locationPath == null)
        //{
        //    throw new System.Exception("null location path");
        //}

        string RecLocation = PlayerPrefs.GetString("LocationPath");

        string word = "|";

        string[] words = RecLocation.Split(new string[] { word }, StringSplitOptions.None);
        int      cnt   = words.Length;

        pointCount = cnt;
        points     = new Vector3[pointCount];

        locationProvider = ARLocationProvider.Instance;
        locationProvider.OnLocationUpdated(LocationUpdated);

        manager = ARLocationManager.Instance;
        manager.OnRestart(OnRestartHandler);

        arLocationRoot = Utils.FindAndLogError("ARLocationRoot", "[ARLocationMoveAlongPath]: ARLocationRoot GameObject not found.");

        transform.SetParent(arLocationRoot.transform);

        if (showDebugInfo)
        {
            arLocationDebugInfo = Utils.FindAndGetComponent <ARLocationDebugInfo>("ARLocationRoot");

            if (arLocationDebugInfo == null)
            {
                showDebugInfo = false;
            }
            else
            {
                SetupDebugObjects();
            }
        }
    }
Exemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        // Look for the LocationProvider
        locationProvider = ARLocationProvider.Instance;

        target = Camera.main.transform.rotation.eulerAngles.y;

        // Register compass update delegate
        locationProvider.OnCompassUpdated((newHeading, lastHeading) =>
        {
            if (!newHeading.isMagneticHeadingAvailable)
            {
                return;
            }

            var isRawTime = locationProvider.provider.isRawTime();

            var trueHeading = newHeading.heading + TrueNorthCalibrationOffset;

            // If measureOnlyAtStartup is true, and we already averaged once, do nothing
            if (measureOnlyAtStartup && !firstRun)
            {
                return;
            }

            // Get current heading value
            float currentCameraHeading = Camera.main.transform.rotation.eulerAngles.y;
            float value = Utils.GetNormalizedDegrees(currentCameraHeading - ((float)trueHeading));

            if (isRawTime)
            {
                transform.localRotation = Quaternion.AngleAxis(value, Vector3.up);
                target = value;
                return;
            }

            // If N = 1, only apply the raw value
            if (averageCount <= 1)
            {
                // transform.localRotation = Quaternion.AngleAxis(value, Vector3.up);
                target = value;

                if (firstRun)
                {
                    firstRun = false;
                }

                return;
            }

            // Add current value to the values list, for averaging
            values.Add(value);

            measurementCount++;

            // If it's the very first call, apply the value
            if (firstCall && Mathf.Abs(value) >= 0.00001f)
            {
                // transform.localRotation = Quaternion.AngleAxis(value, Vector3.up);
                target    = value;
                firstCall = false;
            }

            if (useRawUntilFirstAverage && firstRun)
            {
                if (noSmoothingBeforeFirstAverage)
                {
                    transform.localRotation = Quaternion.AngleAxis(value, Vector3.up);
                }

                target = value;
            }

            // If we measured enough, calculate the average and apply it
            if (measurementCount >= averageCount)
            {
                var average = Utils.FloatListAverage(values);

                measurementCount = 0;
                values.Clear();

                target = average;

                if (firstRun)
                {
                    firstRun = false;
                }
            }
        });

        var debugCanvasObject = GameObject.Find("ARLocationDebugCanvas");

        if (debugCanvasObject != null)
        {
            debugCanvas = debugCanvasObject.GetComponent <ARLocationDebugCanvas>();
        }
    }