void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            instantTrackable.OnTrackFail();
            return;
        }

        Trackable track = trackingResult.GetTrackable(0);

        instantTrackable.OnTrackSuccess(track.GetId(), track.GetName(), track.GetPose());

                #if UNITY_EDITOR
        if (Input.GetMouseButtonDown(0))
        {
            if (linePointCount < 100)
            {
                linePoint [linePointCount++] = TrackerManager.GetInstance().GetWorldPositionFromScreenCoordinate(Input.mousePosition);
                lineRenderer.positionCount   = linePointCount;
                lineRenderer.SetPositions(linePoint);
            }
        }
                #else
        if (Input.touchCount > 0)
        {
            if (linePointCount < 100)
            {
                linePoint [linePointCount++] = TrackerManager.GetInstance().GetWorldPositionFromScreenCoordinate(Input.GetTouch(0).position);
                lineRenderer.positionCount   = linePointCount;
                lineRenderer.SetPositions(linePoint);
            }
        }

        if (Input.GetTouch(0).phase == TouchPhase.Ended)
        {
            linePointCount = 0;
        }
                #endif
    }
Ejemplo n.º 2
0
    void Update()
    {
        DisableAllTrackables();

        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        TrackingResult trackingResult = state.GetTrackingResult();

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            //Debug.Log("Trackable add: " + trackable.GetName());

            bool isNotFound = true;

            foreach (var key in QrCodeTrackablesMap.Keys)
            {
                if (key.Length < 1)
                {
                    continue;
                }

                if (trackable.GetName().Contains(key))
                {
                    foreach (var qrCodeTrackable in QrCodeTrackablesMap[key])
                    {
                        qrCodeTrackable.OnTrackSuccess(
                            "", trackable.GetName(), trackable.GetPose());
                    }

                    isNotFound = false;
                    break;
                }
            }

            if (isNotFound && QrCodeTrackablesMap.ContainsKey(defaultSearchingWords))
            {
                foreach (var qrCodeTrackable in QrCodeTrackablesMap[defaultSearchingWords])
                {
                    qrCodeTrackable.OnTrackSuccess(
                        "", trackable.GetName(), trackable.GetPose());
                }
            }
        }
    }
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_SLAM);
            startTrackerDone = true;
        }

        EnableChildrenRenderer(false);

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            return;
        }

                #if UNITY_EDITOR
        if (Input.GetMouseButtonDown(0))
        {
            if (linePointCount < 100)
            {
                linePoint [linePointCount++] = anchor.transform.position;
                lineRenderer.positionCount   = linePointCount;
                lineRenderer.SetPositions(linePoint);
            }
        }
                #else
        if (Input.touchCount > 0)
        {
            if (linePointCount < 100)
            {
                linePoint [linePointCount++] = anchor.transform.position;
                lineRenderer.positionCount   = linePointCount;
                lineRenderer.SetPositions(linePoint);
            }
        }
                #endif


        EnableChildrenRenderer(true);
    }
    void Update()
    {
        DisableAllTrackables();

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            imageTrackablesMap[trackable.GetName()].OnTrackSuccess(
                trackable.GetId(), trackable.GetName(), trackable.GetPose());
        }
    }
Ejemplo n.º 5
0
    void Update()
    {
        DisableAllTrackables();

        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        int fusionState = TrackerManager.GetInstance().GetFusionTrackingState();

        if (fusionState == -1)
        {
            guideView.SetActive(true);
            return;
        }
        else
        {
            guideView.SetActive(false);
        }

        TrackingResult trackingResult = state.GetTrackingResult();

        string recognizedID = null;

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            int       markerId  = -1;
            if (int.TryParse(trackable.GetName(), out markerId))
            {
                if (markerTrackableMap.ContainsKey(markerId))
                {
                    markerTrackableMap[markerId].OnTrackSuccess(
                        trackable.GetId(), trackable.GetName(), trackable.GetPose());

                    recognizedID += trackable.GetId().ToString() + ", ";
                }
            }
        }

        Debug.Log("Recognized Marker id : " + recognizedID);
    }
    void Update()
    {
        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        int fusionState = TrackerManager.GetInstance().GetFusionTrackingState();

        if (fusionState == -1)
        {
            guideView.SetActive(true);
            return;
        }
        else
        {
            guideView.SetActive(false);
        }

        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            instantTrackable.OnTrackFail();
            return;
        }

        if (Input.touchCount > 0)
        {
            UpdateTouchDelta(Input.GetTouch(0).position);
        }

        if (instantTrackable == null)
        {
            return;
        }

        Trackable trackable  = trackingResult.GetTrackable(0);
        Matrix4x4 poseMatrix = trackable.GetPose() * Matrix4x4.Translate(touchSumPosition);

        instantTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), poseMatrix);
    }
Ejemplo n.º 7
0
    void Update()
    {
        DisableAllTrackables();

        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        int fusionState = TrackerManager.GetInstance().GetFusionTrackingState();

        if (fusionState == -1)
        {
            guideView.SetActive(true);
            return;
        }
        else
        {
            guideView.SetActive(false);
        }

        TrackingResult trackingResult = state.GetTrackingResult();

        GuideInfo guideInfo = TrackerManager.GetInstance().GetGuideInfo();

        TagAnchor[] anchors = guideInfo.GetTagAnchors();

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);

            if (!objectTrackablesMap.ContainsKey(trackable.GetName()))
            {
                return;
            }

            objectTrackablesMap[trackable.GetName()].OnTrackSuccess(trackable.GetId(), trackable.GetName(),
                                                                    trackable.GetPose());
        }
    }
Ejemplo n.º 8
0
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_IMAGE);
            startTrackerDone = true;
        }

        DisableAllTrackables();

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            imageTrackablesMap[trackable.GetName()].OnTrackSuccess(
                trackable.GetId(), trackable.GetName(), trackable.GetPose());
        }

        if (Application.platform != RuntimePlatform.WindowsEditor &&
            Application.platform != RuntimePlatform.OSXEditor)
        {
            if (nonARObject != null)
            {
                if (Screen.orientation == ScreenOrientation.Portrait)
                {
                    nonARObject.transform.rotation = Quaternion.Euler(new Vector3(0, -90.0f, 0));
                }
                else
                {
                    nonARObject.transform.rotation = Quaternion.identity;
                }
            }
        }
    }
    void Update()
    {
        if (instantTrackable == null)
        {
            return;
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        if (trackingResult.GetCount() == 0)
        {
            instantTrackable.OnTrackFail();
            instantPlaneGrid.EnableDrawing(false);
            return;
        }

        instantPlaneGrid.EnableDrawing(true);

        Trackable trackable = trackingResult.GetTrackable(0);

        planMatrix = trackable.GetPose();
        Matrix4x4 poseMatrix = trackable.GetPose() * Matrix4x4.Translate(touchSumPosition);

        instantTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), poseMatrix);

        if (Input.touchCount > 0 && !rotationController.getRotationState() && !zoomInOut.getScaleState())
        {
            UpdateTouchDelta(Input.GetTouch(0).position);
        }
    }
    void Update()
    {
        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_IMAGE);
            startTrackerDone = true;
        }

        DisableAllTrackables();

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            imageTrackablesMap[trackable.GetName()].OnTrackSuccess(
                trackable.GetId(), trackable.GetName(), trackable.GetPose());
        }
    }
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_MARKER);
            startTrackerDone = true;
        }

        DisableAllTrackables();

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        string recognizedID = null;

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            int       markerId  = -1;
            if (int.TryParse(trackable.GetName(), out markerId))
            {
                if (markerTrackableMap.ContainsKey(markerId))
                {
                    markerTrackableMap[markerId].OnTrackSuccess(
                        trackable.GetId(), trackable.GetName(), trackable.GetPose());

                    recognizedID += trackable.GetId().ToString() + ", ";
                }
            }
        }

        Debug.Log("Recognized Marker id : " + recognizedID);
    }
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        if (instantTrackable == null)
        {
            return;
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            instantTrackable.OnTrackFail();
            return;
        }

        if (Input.touchCount > 0)
        {
            UpdateTouchDelta(Input.GetTouch(0).position);
        }

        Trackable trackable  = trackingResult.GetTrackable(0);
        Matrix4x4 poseMatrix = trackable.GetPose() * Matrix4x4.Translate(touchSumPosition);

        instantTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), poseMatrix);
    }
Ejemplo n.º 13
0
        void FixedUpdate()
        {
            TrackingState trackingState = TrackerManager.GetInstance().UpdateTrackingState();

            if (trackingState == null)
            {
                return;
            }
            cameraBackgroundBehaviour.UpdateCameraBackgroundImage(trackingState);

            TrackingResult trackingResult = trackingState.GetTrackingResult();

            // state flag
            bool arCodeTracked = trackingResult.GetCount() > 0;

            // events flags (state changing)
            bool arCodeFound = arCode == null && arCodeTracked;
            bool arCodeLost = arCode != null && !arCodeTracked;
            // Debug.Log("tracked + " + arCodeFound);

            // update
            if (arCodeTracked)
            {
                arCode = trackingResult.GetTrackable(0);
                arCodeUpdate.Invoke(arCode.GetPose());
            }

            // call events handlers
            if (arCodeFound)
            {
                this.arCodeFound.Invoke();
            }
            else if (arCodeLost)
            {
                Debug.Log("LOST");
                arCode = null;
                this.arCodeLost.Invoke();
            }
        }
Ejemplo n.º 14
0
    void Update()
    {
        DisableAllTrackables();

        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        TrackedImage image = state.GetImage();

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() > 0)
        {
            Trackable trackable = trackingResult.GetTrackable(0);
            if (cloudTrackablesMap.ContainsKey(trackable.GetCloudName()))
            {
                foreach (var cloudTrackable in cloudTrackablesMap[trackable.GetCloudName()])
                {
                    cloudTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), trackable.GetPose());
                }
            }
            else
            {
                if (cloudTrackablesMap.ContainsKey("_MaxstCloud_"))
                {
                    foreach (var cloudTrackable in cloudTrackablesMap["_MaxstCloud_"])
                    {
                        cloudTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), trackable.GetPose());
                    }
                }
            }
        }
    }
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_SLAM);
            startTrackerDone = true;
        }

        EnableChildrenRenderer(false);

        Debug.Log(TrackerManager.GetInstance().GetGuideInfo().GetInitializingProgress().ToString());


        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            return;
        }

        EnableChildrenRenderer(true);

        Trackable trackable = trackingResult.GetTrackable(0);

        Matrix4x4 poseMatrix = trackable.GetPose();

        transform.position   = MatrixUtils.PositionFromMatrix(poseMatrix);
        transform.rotation   = MatrixUtils.QuaternionFromMatrix(poseMatrix);
        transform.localScale = MatrixUtils.ScaleFromMatrix(poseMatrix);
    }
Ejemplo n.º 16
0
    void Update()
    {
        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        if (trackingResult.GetCount() == 0)
        {
            foreach (var trackable in instantTrackables)
            {
                trackable.OnTrackFail();
            }
            return;
        }

#if UNITY_EDITOR
        if (Input.GetMouseButton(0))
        {
            PointerEventData eventData = new PointerEventData(EventSystem.current);
            eventData.position = Input.mousePosition;
            List <RaycastResult> raycastResults = new List <RaycastResult>();
            EventSystem.current.RaycastAll(eventData, raycastResults);
            if (raycastResults.Count > 0)
            {
                for (int j = 0; j < raycastResults.Count; j++)
                {
                    Button btn = raycastResults [j].gameObject.GetComponent <Button> ();
                    if (btn == null)
                    {
                        return;
                    }
                }
            }

            touchSumPositions[id] = TrackerManager.GetInstance().GetWorldPositionFromScreenCoordinate(Input.mousePosition);
        }
#else
        if (Input.touchCount > 0)
        {
            PointerEventData eventData = new PointerEventData(EventSystem.current);
            eventData.position = Input.GetTouch(0).position;
            List <RaycastResult> raycastResults = new List <RaycastResult>();
            EventSystem.current.RaycastAll(eventData, raycastResults);
            if (raycastResults.Count > 0)
            {
                for (int j = 0; j < raycastResults.Count; j++)
                {
                    Button btn = raycastResults[j].gameObject.GetComponent <Button>();
                    if (btn == null)
                    {
                        return;
                    }
                }
            }

            UpdateTouchPositionDelta(id);
        }
#endif

        for (int i = 0; i < instantTrackables.Count; i++)
        {
            Trackable track      = trackingResult.GetTrackable(0);
            Matrix4x4 poseMatrix = track.GetPose() * Matrix4x4.Translate(touchSumPositions[i]);
            instantTrackables[i].OnTrackSuccess(track.GetId(), track.GetName(), poseMatrix);
        }
    }
    void Update()
    {
        if (goEarth.GetComponent <VisibleObject>().GetVisible())
        {
            goArrow.SetActive(false);
        }
        else
        {
            if (GuideStep.ContentAugment == CurrentStep)
            {
                goArrow.SetActive(true);
            }
        }

        DisableAllTrackables();

        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        int fusionState = TrackerManager.GetInstance().GetFusionTrackingState();

        if (fusionState == -1)
        {
            if (GuideStep.Initializing != CurrentStep)
            {
                SetGuidePopup(GuideStep.Initializing);
            }
            return;
        }

        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            if (GuideStep.Recognizing != CurrentStep)
            {
                SetGuidePopup(GuideStep.Recognizing);
            }
        }
        else
        {
            if (GuideStep.ContentAugment != CurrentStep)
            {
                SetGuidePopup(GuideStep.ContentAugment);
            }
        }

        if (goResultGuideImage.activeSelf)
        {
            if (isGuideResultPlayerEnded == false)
            {
                return;
            }
            else
            {
                goResultGuideImage.SetActive(false);
            }
        }

        Debug.Log("EARTH VISIBLE = " + goEarth.GetComponent <VisibleObject>().GetVisible());


        //if (goEarth.GetComponent<VisibleObject>().GetVisible())
        //    goArrow.SetActive(false);
        //else
        //    goArrow.SetActive(true);

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            imageTrackablesMap[trackable.GetName()].OnTrackSuccess(
                trackable.GetId(), trackable.GetName(), trackable.GetPose());
        }
    }