예제 #1
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);
    }
예제 #2
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();
            }
        }
    }
예제 #3
0
    private void Update()
    {
        if (!playing)
        {
            return;
        }

        // If there is no location provider, or spline, do nothing
        if (locationProvider == null || spline == null || !locationProvider.isEnabled)
        {
            return;
        }

        // Get spline point at current parameter
        var s = spline.Length * u;

        var data = spline.GetPointAndTangentAtArcLength(s);
        var tan  = data.tangent;

        // Move object to the point
        var smoothMove    = GetComponent <SmoothMove>();
        var useSmoothMove = !(smoothMove == null || locationProvider.provider.isRawTime());

        if (useSmoothMove)
        {
            smoothMove.Target = data.point - translation;
        }
        else
        {
            transform.localPosition = data.point - translation;
        }

        // Set orientation
        transform.localRotation = Quaternion.LookRotation(new Vector3(tan.x, tan.y, tan.z), up);

        // Check if we reached the end of the spline
        u = u + (speed * Time.deltaTime) / spline.Length;
        if (u >= 1 && !loop)
        {
            u       = 0;
            playing = false;
        }
        else
        {
            u = u % 1.0f;
        }

        // If there is a line renderer, render the path
        if (lineRenderer != null)
        {
            lineRenderer.useWorldSpace = true;
            var t = arLocationRoot.GetComponent <Transform>();
            spline.DrawCurveWithLineRenderer(lineRenderer, p => t.TransformVector(p - translation));
        }

        if (showDebugInfo)
        {
            var text = name + "\n"
                       + "POS: " + transform.position + "\n"
                       + "LPOS: " + transform.localPosition + "\n"
                       + "PathLength: " + s + "\n"
                       + "PathParam: " + u + "\n"
                       + "DST: " + Vector3.Distance(transform.position, Camera.main.transform.position);

            ARLocationDebugInfo.UpdateDebugInfoPanelScreenPositionAndText(gameObject, debugInfoPanel, text);
        }
    }